chore: backport CI improvements (#2238)

This commit is contained in:
David Barsky 2023-11-06 20:03:57 -05:00 committed by Eliza Weisman
parent c6abc10c3a
commit abb23931ef

View File

@ -3,7 +3,6 @@ name: CI
on: on:
push: push:
branches: branches:
- master
- "v0.1.x" - "v0.1.x"
pull_request: {} pull_request: {}
@ -27,9 +26,6 @@ env:
RUSTUP_MAX_RETRIES: 10 RUSTUP_MAX_RETRIES: 10
# Don't emit giant backtraces in the CI logs. # Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short RUST_BACKTRACE: short
MSRV: 1.63.0
# TODO: remove this once tracing's MSRV is bumped.
APPENDER_MSRV: 1.63.0
jobs: jobs:
### check jobs ### ### check jobs ###
@ -40,16 +36,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1 - uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
profile: minimal
override: true
- name: Check - name: Check
uses: actions-rs/cargo@v1 run: cargo check --all --tests --benches
with:
command: check
args: --all --tests --benches
style: style:
# Check style. # Check style.
@ -58,17 +47,11 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1 - uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: stable
components: rustfmt components: rustfmt
profile: minimal
override: true
- name: rustfmt - name: rustfmt
uses: actions-rs/cargo@v1 run: cargo fmt --all -- --check
with:
command: fmt
args: --all -- --check
warnings: warnings:
# Check for any warnings. This is informational and thus is allowed to fail. # Check for any warnings. This is informational and thus is allowed to fail.
@ -76,46 +59,15 @@ jobs:
needs: check needs: check
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1 - uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: stable
components: clippy components: clippy
profile: minimal
- name: Clippy - name: Clippy
uses: actions-rs/clippy-check@v1 uses: actions-rs/clippy-check@v1
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
args: --all --examples --tests --benches -- -D warnings 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: cargo-hack:
needs: check needs: check
name: cargo check (feature combinations) name: cargo check (feature combinations)
@ -195,28 +147,47 @@ jobs:
- stable - stable
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: "install Rust ${{ env.APPENDER_MSRV }}" - name: install Rust nightly
uses: actions-rs/toolchain@v1 uses: dtolnay/rust-toolchain@nightly
- name: "install Rust ${{ matrix.toolchain }}"
uses: dtolnay/rust-toolchain@master
with: with:
toolchain: ${{ env.APPENDER_MSRV }} toolchain: ${{ matrix.toolchain }}
profile: minimal - name: install cargo-hack
- name: "install Rust nightly" uses: taiki-e/install-action@cargo-hack
uses: actions-rs/toolchain@v1 - name: install cargo-minimal-versions
with: uses: taiki-e/install-action@cargo-minimal-versions
toolchain: nightly - name: cargo minimal-versions check
profile: minimal working-directory: ${{ matrix.subcrate }}
- name: Select minimal versions # tracing and tracing-subscriber have too many features to be checked by
uses: actions-rs/cargo@v1 # cargo-hack --feature-powerset with all features in the powerset, so
with: # exclude some
command: update run: |
args: -Z minimal-versions CARGO_MINVER=(cargo minimal-versions check --feature-powerset --no-dev-deps)
toolchain: nightly case "${{ matrix.subcrate }}" in
- name: Check tracing)
uses: actions-rs/cargo@v1 EXCLUDE_FEATURES=(
with: max_level_off max_level_error max_level_warn max_level_info
command: check max_level_debug max_level_trace release_max_level_off
args: --all-features --locked -p tracing-appender release_max_level_error release_max_level_warn
toolchain: ${{ env.APPENDER_MSRV }} 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 ############################################################# ### test jobs #############################################################
@ -240,11 +211,10 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1 - name: "install Rust ${{ matrix.rust }}"
uses: dtolnay/rust-toolchain@master
with: with:
toolchain: ${{ matrix.rust }} toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: install cargo-nextest - name: install cargo-nextest
uses: taiki-e/install-action@nextest uses: taiki-e/install-action@nextest
- name: Run tests - name: Run tests
@ -283,16 +253,11 @@ jobs:
fail-fast: false fail-fast: false
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1 - uses: dtolnay/rust-toolchain@stable
with: with:
target: wasm32-unknown-unknown target: wasm32-unknown-unknown
toolchain: stable
override: true
- name: build all tests - name: build all tests
uses: actions-rs/cargo@v1 run: cargo test --no-run -p ${{ matrix.subcrate }}
with:
command: test
args: --no-run -p ${{ matrix.subcrate }}
test-wasm: test-wasm:
name: cargo test (wasm) name: cargo test (wasm)
@ -304,11 +269,9 @@ jobs:
- tracing - tracing
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1 - uses: dtolnay/rust-toolchain@stable
with: with:
target: wasm32-unknown-unknown target: wasm32-unknown-unknown
toolchain: stable
override: true
- name: install test runner for wasm - name: install test runner for wasm
uses: taiki-e/install-action@wasm-pack uses: taiki-e/install-action@wasm-pack
- name: run wasm tests - name: run wasm tests
@ -321,29 +284,23 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1 - uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
profile: minimal
override: true
- name: "Test log support" - name: "Test log support"
run: cargo test run: cargo test
- name: "Test static max level" - name: "Test static max level"
run: cargo test run: cargo test
working-directory: "tracing/test_static_max_level_features"
- name: "Test static max level (release)" - name: "Test static max level (release)"
run: cargo test --release run: cargo test --release
working-directory: "tracing/test_static_max_level_features"
- name: "Test tracing-core no-std support" - name: "Test tracing-core no-std support"
run: cargo test --no-default-features run: cargo test --no-default-features
- name: "Test tracing no-std support" - name: "Test tracing no-std support"
run: cargo test --no-default-features run: cargo test --no-default-features
# this skips running doctests under the `--no-default-features` flag, # this skips running doctests under the `--no-default-features` flag,
# as rustdoc isn't aware of cargo's feature flags. # 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 run: cargo test --lib --tests --no-default-features
- name: "Test tracing-subscriber with liballoc only"
run: cargo test --lib --tests --no-default-features --features "alloc"
- name: "Test tracing-subscriber with no default features"
run: cargo test --lib --tests --no-default-features --features "std"
# all required checks except for the main test run (which we only require # all required checks except for the main test run (which we only require
# specific matrix combinations from) # specific matrix combinations from)
@ -352,7 +309,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs:
- style - style
- minimal-versions
- cargo-hack - cargo-hack
- check-msrv - check-msrv
- test-build-wasm - test-build-wasm