Skip to content

Commit

Permalink
chore: backport CI improvements (tokio-rs#2238)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbarsky authored and kaffarell committed May 22, 2024
1 parent e672e09 commit 95a9f00
Showing 1 changed file with 47 additions and 67 deletions.
114 changes: 47 additions & 67 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: CI
on:
push:
branches:
- master
- "v0.1.x"
pull_request: {}

Expand All @@ -27,9 +26,6 @@ env:
RUSTUP_MAX_RETRIES: 10
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
MSRV: 1.63.0
# TODO: remove this once tracing's MSRV is bumped.
APPENDER_MSRV: 1.63.0

jobs:
### check jobs ###
Expand Down Expand Up @@ -96,64 +92,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
profile: minimal
override: true
- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: cargo fmt --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@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
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@v3
- 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)
Expand Down Expand Up @@ -233,28 +192,47 @@ jobs:
- stable
steps:
- uses: actions/checkout@v3
- 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
- name: install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: "install Rust ${{ matrix.toolchain }}"
uses: dtolnay/rust-toolchain@master
with:
command: check
args: --all-features --locked -p tracing-appender
toolchain: ${{ env.APPENDER_MSRV }}
toolchain: ${{ matrix.toolchain }}
- name: install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: install cargo-minimal-versions
uses: taiki-e/install-action@cargo-minimal-versions
- name: cargo minimal-versions check
working-directory: ${{ matrix.subcrate }}
# tracing and tracing-subscriber have too many features to be checked by
# cargo-hack --feature-powerset with all features in the powerset, so
# exclude some
run: |
CARGO_MINVER=(cargo minimal-versions check --feature-powerset --no-dev-deps)
case "${{ matrix.subcrate }}" in
tracing)
EXCLUDE_FEATURES=(
max_level_off max_level_error max_level_warn max_level_info
max_level_debug max_level_trace release_max_level_off
release_max_level_error release_max_level_warn
release_max_level_info release_max_level_debug
release_max_level_trace
)
${CARGO_MINVER[@]} --exclude-features "${EXCLUDE_FEATURES[*]}"
;;
tracing-subscriber)
INCLUDE_FEATURES=(fmt ansi json registry env-filter)
${CARGO_MINVER[@]} --include-features "${INCLUDE_FEATURES[*]}"
;;
tracing-futures)
EXCLUDE_FEATURES=(futures-01 futures_01 tokio tokio_01)
${CARGO_MINVER[@]} --exclude-features "${EXCLUDE_FEATURES[*]}"
;;
*)
${CARGO_MINVER[@]}
;;
esac
shell: bash

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

Expand Down Expand Up @@ -426,15 +404,17 @@ jobs:
run: cargo test
- name: "Test static max level"
run: cargo test
working-directory: "tracing/test_static_max_level_features"
- name: "Test static max level (release)"
run: cargo test --release
working-directory: "tracing/test_static_max_level_features"
- name: "Test tracing-core no-std support"
run: cargo test --no-default-features
- name: "Test tracing no-std support"
run: cargo test --no-default-features
# this skips running doctests under the `--no-default-features` flag,
# as rustdoc isn't aware of cargo's feature flags.
- name: "Test tracing-subscriber no-std support"
- name: "Test tracing-subscriber with all features disabled"
run: cargo test --lib --tests --no-default-features

# all required checks except for the main test run (which we only require
Expand All @@ -450,4 +430,4 @@ jobs:
- test-wasm
- test-features-stable
steps:
- run: exit 0
- run: exit 0

0 comments on commit 95a9f00

Please sign in to comment.