ソースを参照

chore(ci): move CI into one workflow, fix skipping (#66)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Eliza Weisman 2 年 前
コミット
0cf1ea24b7

+ 252 - 0
.github/workflows/ci.yml

@@ -0,0 +1,252 @@
+on:
+  pull_request:
+  workflow_dispatch:
+  push:
+    branches: ["main"]
+
+env:
+  # disable incremental compilation.
+  #
+  # incremental compilation is useful as part of an edit-build-test-edit cycle,
+  # as it lets the compiler avoid recompiling code that hasn't changed. however,
+  # on CI, we're not making small edits; we're almost always building the entire
+  # project from scratch. thus, incremental compilation on CI actually
+  # introduces *additional* overhead to support making future builds
+  # faster...but no future builds will ever occur in any given CI environment.
+  #
+  # see https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
+  # for details.
+  CARGO_INCREMENTAL: 0
+  # allow more retries for network requests in cargo (downloading crates) and
+  # rustup (installing toolchains). this should help to reduce flaky CI failures
+  # from transient network timeouts or other issues.
+  CARGO_NET_RETRY: 10
+  RUSTUP_MAX_RETRIES: 10
+  # don't emit giant backtraces in the CI logs.
+  RUST_BACKTRACE: short
+  RUSTFLAGS: -Dwarnings
+  msrv: 1.57.0
+  LOOM_LOG: 'thingbuf=trace,debug'
+
+name: CI
+
+jobs:
+  changed_paths:
+    continue-on-error: true
+    runs-on: ubuntu-latest
+    outputs:
+      should_skip: ${{ steps.skip_check.outputs.should_skip }}
+    steps:
+      - id: skip_check
+        uses: fkirc/skip-duplicate-actions@master
+        with:
+          do_not_skip: '["workflow_dispatch", "push"]'
+          paths: '["**/*.rs", "**/Cargo.toml", ".github/workflows/ci.yml"]'
+
+  build_no_std:
+    name: Check no_std
+    needs: changed_paths
+    if: needs.changed_paths.outputs.should_skip != 'true'
+    strategy:
+      matrix:
+        feature: [alloc, static]
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Install toolchain
+      uses: actions-rs/toolchain@v1
+      with:
+        profile: minimal
+        toolchain: stable
+        override: true
+        components: rustfmt
+    - uses: actions-rs/cargo@v1
+      with:
+        command: check
+        args: --no-default-features --features ${{ matrix.feature }}
+
+  tests:
+    name: Tests
+    needs: changed_paths
+    if: needs.changed_paths.outputs.should_skip != 'true'
+    strategy:
+      matrix:
+        # test all Rust versions on Ubuntu
+        rust: [stable, 1.57.0]
+        os: [ubuntu-latest]
+        # test stable Rust on Windows and MacOS as well
+        include:
+          - rust: stable
+            os: windows-latest
+          - rust: stable
+            os: macos-latest
+    runs-on: ${{ matrix.os }}
+    steps:
+      - uses: actions/checkout@v2
+      - name: Install toolchain
+        uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: ${{ matrix.rust }}
+          override: true
+          components: rustfmt
+      - name: Run cargo test (with static APIs)
+        if: ${{ matrix.rust != env.msrv }}
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --all-features
+      - name: Run cargo test (no static APIs)
+        if: ${{ matrix.rust == env.msrv }}
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          # skip doctests, which require all features to be enabled
+          args: --lib --tests
+
+  benches:
+    name: Compile benchmarks
+    needs: changed_paths
+    if: needs.changed_paths.outputs.should_skip != 'true'
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Install stable toolchain
+        uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+          components: rustfmt
+      - name: Run cargo check
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: -p bench --benches
+
+  rustfmt:
+    runs-on: ubuntu-latest
+    needs: changed_paths
+    if: needs.changed_paths.outputs.should_skip != 'true'
+    steps:
+      - uses: actions/checkout@v2
+      - name: Install stable toolchain
+        uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+          components: rustfmt
+      - name: Run cargo fmt
+        uses: actions-rs/cargo@v1
+        with:
+          command: fmt
+          args: --all -- --check
+
+  clippy_check:
+    name: Clippy check
+    needs: changed_paths
+    if: needs.changed_paths.outputs.should_skip != 'true'
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Install stable toolchain
+        uses: actions-rs/toolchain@v1
+        with:
+            toolchain: stable
+            components: clippy
+            override: true
+      - uses: actions-rs/clippy-check@v1
+        with:
+          token: ${{ secrets.GITHUB_TOKEN }}
+
+  # Run particularly slow loom models individually
+  slow_models:
+    needs: changed_paths
+    if: needs.changed_paths.outputs.should_skip != 'true'
+    strategy:
+      matrix:
+        model:
+          - mpsc_send_recv_wrap
+          - mpsc_try_send_recv
+          - mpsc_try_recv_ref
+          - mpsc_async::rx_close_unconsumed
+          - mpsc_blocking::rx_close_unconsumed
+    name: model '${{ matrix.model }}''
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Install stable toolchain
+        uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+      - name: Run model
+        run: cargo test --profile loom --lib -- ${{ matrix.model }}
+        env:
+          # it would be nice to run these with more preemptions, but
+          # that makes these models super slow...and LOOM_MAX_PREEMPTIONS=1 is
+          # good enough for Tokio's CI, so...
+          LOOM_MAX_PREEMPTIONS: 1
+          RUSTFLAGS: "--cfg loom"
+
+  # Run other loom models by scope
+  models:
+    needs: changed_paths
+    if: needs.changed_paths.outputs.should_skip != 'true'
+    strategy:
+      matrix:
+        scope:
+          # NOTE: if adding loom models in a new module, that module needs to be
+          # added to this list!
+          - mpsc_blocking
+          - mpsc_async
+          - thingbuf
+          - util
+    name: models in '${{ matrix.scope }}'
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Install stable toolchain
+        uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+      - name: Run models
+        run: cargo test --profile loom --lib -- ${{ matrix.scope }}
+        env:
+          LOOM_MAX_PREEMPTIONS: 2
+          # `--cfg ci_skip_slow_models` will exclude the loom models that are
+          # tested in `slow-models`.
+          RUSTFLAGS: "--cfg loom --cfg ci_skip_slow_models"
+
+  # Dummy job that requires all loom models to pass
+  all_models:
+    name: all loom models
+    runs-on: ubuntu-latest
+    needs:
+      - slow_models
+      - models
+    steps:
+      - run: exit 0
+
+  miri:
+    name: Miri tests
+    needs: changed_paths
+    if: needs.changed_paths.outputs.should_skip != 'true'
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Install nightly toolchain
+        uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: nightly
+          override: true
+          components: miri
+      - name: Run Miri tests
+        run: cargo miri test --lib --no-fail-fast
+        env:
+          MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-tag-raw-pointers

+ 0 - 46
.github/workflows/lints.yml

@@ -1,46 +0,0 @@
-on:
-  push:
-    branches:
-      - main
-    paths:
-      - '**.rs'
-      - '.github/workflows/lints.yml'
-  workflow_dispatch:
-  pull_request:
-    paths:
-      - '**.rs'
-      - '.github/workflows/lints.yml'
-
-name: Lints
-jobs:
-  rustfmt:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - name: Install stable toolchain
-        uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: stable
-          override: true
-          components: rustfmt
-      - name: Run cargo fmt
-        uses: actions-rs/cargo@v1
-        with:
-          command: fmt
-          args: --all -- --check
-
-  clippy_check:
-    name: Clippy check
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - name: Install stable toolchain
-        uses: actions-rs/toolchain@v1
-        with:
-            toolchain: stable
-            components: clippy
-            override: true
-      - uses: actions-rs/clippy-check@v1
-        with:
-          token: ${{ secrets.GITHUB_TOKEN }}

+ 0 - 88
.github/workflows/loom.yml

@@ -1,88 +0,0 @@
-on:
-  push:
-    branches:
-      - main
-    paths:
-      - '**.rs'
-      - '**/Cargo.toml'
-      - '.github/workflows/loom.yml'
-  workflow_dispatch:
-  pull_request:
-    paths:
-      - '**.rs'
-      - '**/Cargo.toml'
-      - '.github/workflows/loom.yml'
-
-name: Loom Models
-
-env:
-  LOOM_LOG: loom=debug
-
-jobs:
-  # Run particularly slow loom models individually
-  slow_models:
-    strategy:
-      matrix:
-        model:
-          - mpsc_send_recv_wrap
-          - mpsc_try_send_recv
-          - mpsc_try_recv_ref
-          - mpsc_async::rx_close_unconsumed
-          - mpsc_blocking::rx_close_unconsumed
-    name: model '${{ matrix.model }}''
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - name: Install stable toolchain
-        uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: stable
-          override: true
-      - name: Run model
-        run: cargo test --profile loom --lib -- ${{ matrix.model }}
-        env:
-          # it would be nice to run these with more preemptions, but
-          # that makes these models super slow...and LOOM_MAX_PREEMPTIONS=1 is
-          # good enough for Tokio's CI, so...
-          LOOM_MAX_PREEMPTIONS: 1
-          RUSTFLAGS: "--cfg loom"
-
-  # Run other loom models by scope
-  models:
-    strategy:
-      matrix:
-        scope:
-          # NOTE: if adding loom models in a new module, that module needs to be
-          # added to this list!
-          - mpsc_blocking
-          - mpsc_async
-          - thingbuf
-          - util
-    name: models in '${{ matrix.scope }}'
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - name: Install stable toolchain
-        uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: stable
-          override: true
-      - name: Run models
-        run: cargo test --profile loom --lib -- ${{ matrix.scope }}
-        env:
-          LOOM_MAX_PREEMPTIONS: 2
-          # `--cfg ci_skip_slow_models` will exclude the loom models that are
-          # tested in `slow-models`.
-          RUSTFLAGS: "--cfg loom --cfg ci_skip_slow_models"
-
-  # Dummy job that requires all loom models to pass
-  all_models:
-    name: all loom models
-    runs-on: ubuntu-latest
-    needs:
-      - slow_models
-      - models
-    steps:
-      - run: exit 0

+ 0 - 31
.github/workflows/miri.yaml

@@ -1,31 +0,0 @@
-on:
-  push:
-    branches:
-      - main
-    paths:
-      - '**.rs'
-      - '.github/workflows/miri.yml'
-  workflow_dispatch:
-  pull_request:
-    paths:
-      - '**.rs'
-      - '.github/workflows/miri.yml'
-
-name: Miri
-jobs:
-  tests:
-    name: Miri tests
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - name: Install nightly toolchain
-        uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: nightly
-          override: true
-          components: miri
-      - name: Run Miri tests
-        run: cargo miri test --lib --no-fail-fast
-        env:
-          MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-tag-raw-pointers

+ 0 - 96
.github/workflows/tests.yml

@@ -1,96 +0,0 @@
-on:
-  push:
-    branches:
-      - main
-    paths:
-      - '**.rs'
-      - '**/Cargo.toml'
-      - '.github/workflows/tests.yml'
-  workflow_dispatch:
-  pull_request:
-    paths:
-      - '**.rs'
-      - '**/Cargo.toml'
-      - '.github/workflows/tests.yml'
-
-env:
-  RUSTFLAGS: -Dwarnings
-  RUST_BACKTRACE: 1
-  msrv: 1.57.0
-
-name: Tests
-jobs:
-  build_no_std:
-    name: Check no_std
-    strategy:
-      matrix:
-        feature: [alloc, static]
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-    - name: Install toolchain
-      uses: actions-rs/toolchain@v1
-      with:
-        profile: minimal
-        toolchain: stable
-        override: true
-        components: rustfmt
-    - uses: actions-rs/cargo@v1
-      with:
-        command: check
-        args: --no-default-features --features ${{ matrix.feature }}
-
-  tests:
-    name: Tests
-    strategy:
-      matrix:
-        # test all Rust versions on Ubuntu
-        rust: [stable, 1.57.0]
-        os: [ubuntu-latest]
-        # test stable Rust on Windows and MacOS as well
-        include:
-          - rust: stable
-            os: windows-latest
-          - rust: stable
-            os: macos-latest
-    runs-on: ${{ matrix.os }}
-    steps:
-      - uses: actions/checkout@v2
-      - name: Install toolchain
-        uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: ${{ matrix.rust }}
-          override: true
-          components: rustfmt
-      - name: Run cargo test (with static APIs)
-        if: ${{ matrix.rust != env.msrv }}
-        uses: actions-rs/cargo@v1
-        with:
-          command: test
-          args: --all-features
-      - name: Run cargo test (no static APIs)
-        if: ${{ matrix.rust == env.msrv }}
-        uses: actions-rs/cargo@v1
-        with:
-          command: test
-          # skip doctests, which require all features to be enabled
-          args: --lib --tests
-
-  benches:
-    name: Compile benchmarks
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - name: Install stable toolchain
-        uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: stable
-          override: true
-          components: rustfmt
-      - name: Run cargo check
-        uses: actions-rs/cargo@v1
-        with:
-          command: check
-          args: -p bench --benches

+ 2 - 5
README.md

@@ -8,7 +8,6 @@
 [![Documentation (HEAD)][docs-main-badge]][docs-main-url]
 [![MIT licensed][mit-badge]][mit-url]
 [![Test Status][tests-badge]][tests-url]
-[![Loom Models][loom-badge]][loom-url]
 [![Sponsor @hawkw on GitHub Sponsors][sponsor-badge]][sponsor-url]
 
 [crates-badge]: https://img.shields.io/crates/v/thingbuf.svg
@@ -19,10 +18,8 @@
 [docs-main-url]: https://thingbuf.elizas.website
 [mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
 [mit-url]: ../LICENSE
-[tests-badge]: https://github.com/hawkw/thingbuf/actions/workflows/tests.yml/badge.svg?branch=main
-[tests-url]: https://github.com/hawkw/thingbuf/actions/workflows/tests.yml
-[loom-badge]: https://github.com/hawkw/thingbuf/actions/workflows/loom.yml/badge.svg?branch=main
-[loom-url]: https://github.com/hawkw/thingbuf/actions/workflows/loom.yml
+[tests-badge]: https://github.com/hawkw/thingbuf/actions/workflows/ci.yml/badge.svg?branch=main
+[tests-url]: https://github.com/hawkw/thingbuf/actions/workflows/ci.yml
 [sponsor-badge]: https://img.shields.io/badge/sponsor-%F0%9F%A4%8D-ff69b4
 [sponsor-url]: https://github.com/sponsors/hawkw