Skip to content

Commit

Permalink
chore(ci): test workflow embetterments (tokio-rs#2176)
Browse files Browse the repository at this point in the history
This branch makes the following changes to the CI test workflows:

- Consolidate all tests into a single workflow again. We had previously
  broken things out to allow restarting only some failed checks, but now
  GitHub Actions allows restarting individual jobs, which is much nicer,
  and we can combine everything into one workflow.
- Gate starting any tests/checks on an initial `cargo check` run. This
  should mean that if code doesn't compile, we don't spin up a huge
  number of test jobs that all end up failing, and delaying other PRs'
  CI runs.
- Use `cargo nextest` for running tests. This should make test runs a
  bit quicker, and also get us other nice features like retries for
  flaky tests.
- Switch to `taiki-e/install-action` for installing stuff like
  `cargo-hack`, `nextest`, and `wasm-pack`. This is a bit nicer than
  just `curl`ing stuff.
- Use a matrix for testing across toolchains/OSes, instead of having
  separate jobs. This reduces the complexity of the CI workflow a bit.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw authored and kaffarell committed May 22, 2024
1 parent 7503650 commit e672bde
Showing 2 changed files with 143 additions and 102 deletions.
143 changes: 143 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -26,6 +26,9 @@ env:
RUSTUP_MAX_RETRIES: 10
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
MSRV: 1.49.0
# TODO: remove this once tracing's MSRV is bumped.
APPENDER_MSRV: 1.53.0

jobs:
### check jobs ###
@@ -85,6 +88,71 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --examples --tests --benches -- -D warnings

style:
# Check style.
name: cargo fmt
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
profile: minimal
override: true
- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

warnings:
# Check for any warnings. This is informational and thus is allowed to fail.
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
profile: minimal
- name: Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --examples --tests --benches -- -D warnings

minimal-versions:
# Check for minimal-versions errors where a dependency is too
# underconstrained to build on the minimal supported version of all
# dependencies in the dependency graph.
name: cargo check (-Zminimal-versions)
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
override: true
- name: install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: "check --all-features -Z minimal-versions"
run: |
# Remove dev-dependencies from Cargo.toml to prevent the next `cargo update`
# from determining minimal versions based on dev-dependencies.
cargo hack --remove-dev-deps --workspace
# Update Cargo.lock to minimal version dependencies.
cargo update -Z minimal-versions
cargo hack check \
--package tracing \
--package tracing-core \
--package tracing-subscriber \
--all-features --ignore-private
cargo-hack:
needs: check
name: cargo check (feature combinations)
@@ -143,6 +211,81 @@ jobs:
name: "cargo check (+MSRV -Zminimal-versions)"
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "install Rust ${{ env.MSRV }}"
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.MSRV }}
profile: minimal
- name: "install Rust nightly"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
- name: Select minimal versions
uses: actions-rs/cargo@v1
with:
command: update
args: -Z minimal-versions
toolchain: nightly
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
# skip the following crates:
# - tracing-appender, as it has its own MSRV.
# TODO(eliza): remove this when appender is on the same MSRV as
# everything else
# - the examples, as they are not published & we don't care about
# MSRV support for them.
# - tracing-futures, as it depends on ancient tokio versions.
# TODO(eliza): remove this when the ancient tokio deps are dropped
args: >-
--workspace --all-features --locked
--exclude=tracing-appender
--exclude=tracing-examples
--exclude=tracing-futures
toolchain: ${{ env.MSRV }}

# TODO: remove this once tracing's MSRV is bumped.
check-msrv-appender:
# Run `cargo check` on our minimum supported Rust version (1.53.0).
name: "cargo check (tracing-appender MSRV)"
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "install Rust ${{ env.APPENDER_MSRV }}"
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.APPENDER_MSRV }}
profile: minimal
- name: "install Rust nightly"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
- name: Select minimal versions
uses: actions-rs/cargo@v1
with:
command: update
args: -Z minimal-versions
toolchain: nightly
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features --locked -p tracing-appender
toolchain: ${{ env.APPENDER_MSRV }}

### test jobs #############################################################

test:
# Test against stable Rust across macOS, Windows, and Linux, and against
# beta and nightly rust on Ubuntu.
name: "cargo test (${{ matrix.rust }} on ${{ matrix.os }})"
needs: check
strategy:
matrix:
# cargo hack --feature-powerset will have a significant permutation
102 changes: 0 additions & 102 deletions .github/workflows/check_msrv.yml

This file was deleted.

0 comments on commit e672bde

Please sign in to comment.