From 0cf1ea24b7f1aba7cf4f3932cd3f02f5846a5f54 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Mon, 6 Jun 2022 12:54:41 -0700 Subject: [PATCH] chore(ci): move CI into one workflow, fix skipping (#66) Signed-off-by: Eliza Weisman --- .github/workflows/ci.yml | 252 ++++++++++++++++++++++++++++++++++++ .github/workflows/lints.yml | 46 ------- .github/workflows/loom.yml | 88 ------------- .github/workflows/miri.yaml | 31 ----- .github/workflows/tests.yml | 96 -------------- README.md | 7 +- 6 files changed, 254 insertions(+), 266 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/lints.yml delete mode 100644 .github/workflows/loom.yml delete mode 100644 .github/workflows/miri.yaml delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e983a1a --- /dev/null +++ b/.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 \ No newline at end of file diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml deleted file mode 100644 index aae3dce..0000000 --- a/.github/workflows/lints.yml +++ /dev/null @@ -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 }} diff --git a/.github/workflows/loom.yml b/.github/workflows/loom.yml deleted file mode 100644 index 9b7f085..0000000 --- a/.github/workflows/loom.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/.github/workflows/miri.yaml b/.github/workflows/miri.yaml deleted file mode 100644 index 75313ca..0000000 --- a/.github/workflows/miri.yaml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index fb3d153..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index d34eb69..a71aad5 100644 --- a/README.md +++ b/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