Skip to content

Commit bfd0e55

Browse files
authored
chore: refactor CI msrv & minver checks (#2238)
## Motivation Test msrv and minimal-versions compliance in the currently best-known fashion. ## Solution - Use cargo-hack and cargo-minimal-versions - Also I replaced uses of actions-rs (abandoned) while I was passing by
1 parent f6602ee commit bfd0e55

File tree

1 file changed

+81
-143
lines changed

1 file changed

+81
-143
lines changed

.github/workflows/CI.yml

Lines changed: 81 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ env:
2626
RUSTUP_MAX_RETRIES: 10
2727
# Don't emit giant backtraces in the CI logs.
2828
RUST_BACKTRACE: short
29-
MSRV: 1.49.0
30-
# TODO: remove this once tracing's MSRV is bumped.
31-
APPENDER_MSRV: 1.53.0
3229

3330
jobs:
3431
### check jobs ###
@@ -39,16 +36,9 @@ jobs:
3936
runs-on: ubuntu-latest
4037
steps:
4138
- uses: actions/checkout@v3
42-
- uses: actions-rs/toolchain@v1
43-
with:
44-
toolchain: stable
45-
profile: minimal
46-
override: true
39+
- uses: dtolnay/rust-toolchain@stable
4740
- name: Check
48-
uses: actions-rs/cargo@v1
49-
with:
50-
command: check
51-
args: --all --tests --benches
41+
run: cargo check --all --tests --benches
5242

5343
style:
5444
# Check style.
@@ -57,64 +47,27 @@ jobs:
5747
runs-on: ubuntu-latest
5848
steps:
5949
- uses: actions/checkout@v3
60-
- uses: actions-rs/toolchain@v1
50+
- uses: dtolnay/rust-toolchain@stable
6151
with:
62-
toolchain: stable
6352
components: rustfmt
64-
profile: minimal
65-
override: true
6653
- name: rustfmt
67-
uses: actions-rs/cargo@v1
68-
with:
69-
command: fmt
70-
args: --all -- --check
54+
run: cargo fmt --all -- --check
7155

7256
warnings:
7357
# Check for any warnings. This is informational and thus is allowed to fail.
7458
runs-on: ubuntu-latest
7559
needs: check
7660
steps:
7761
- uses: actions/checkout@v3
78-
- uses: actions-rs/toolchain@v1
62+
- uses: dtolnay/rust-toolchain@stable
7963
with:
80-
toolchain: stable
8164
components: clippy
82-
profile: minimal
8365
- name: Clippy
8466
uses: actions-rs/clippy-check@v1
8567
with:
8668
token: ${{ secrets.GITHUB_TOKEN }}
8769
args: --all --examples --tests --benches -- -D warnings
8870

89-
minimal-versions:
90-
# Check for minimal-versions errors where a dependency is too
91-
# underconstrained to build on the minimal supported version of all
92-
# dependencies in the dependency graph.
93-
name: cargo check (-Zminimal-versions)
94-
needs: check
95-
runs-on: ubuntu-latest
96-
steps:
97-
- uses: actions/checkout@v3
98-
- uses: actions-rs/toolchain@v1
99-
with:
100-
toolchain: nightly
101-
profile: minimal
102-
override: true
103-
- name: install cargo-hack
104-
uses: taiki-e/install-action@cargo-hack
105-
- name: "check --all-features -Z minimal-versions"
106-
run: |
107-
# Remove dev-dependencies from Cargo.toml to prevent the next `cargo update`
108-
# from determining minimal versions based on dev-dependencies.
109-
cargo hack --remove-dev-deps --workspace
110-
# Update Cargo.lock to minimal version dependencies.
111-
cargo update -Z minimal-versions
112-
cargo hack check \
113-
--package tracing \
114-
--package tracing-core \
115-
--package tracing-subscriber \
116-
--all-features --ignore-private
117-
11871
cargo-hack:
11972
needs: check
12073
name: cargo check (feature combinations)
@@ -137,11 +90,7 @@ jobs:
13790
- tracing-subscriber
13891
steps:
13992
- uses: actions/checkout@v3
140-
- uses: actions-rs/toolchain@v1
141-
with:
142-
toolchain: stable
143-
profile: minimal
144-
override: true
93+
- uses: dtolnay/rust-toolchain@stable
14594

14695
- name: install cargo-hack
14796
uses: taiki-e/install-action@cargo-hack
@@ -174,77 +123,80 @@ jobs:
174123
shell: bash
175124

176125
check-msrv:
177-
# Run `cargo check` on our minimum supported Rust version (1.49.0).
178-
name: "cargo check (MSRV on ubuntu-latest)"
179-
needs: check
180-
runs-on: ubuntu-latest
181-
steps:
182-
- uses: actions/checkout@v3
183-
- name: "install Rust ${{ env.MSRV }}"
184-
uses: actions-rs/toolchain@v1
185-
with:
186-
toolchain: ${{ env.MSRV }}
187-
profile: minimal
188-
- name: "install Rust nightly"
189-
uses: actions-rs/toolchain@v1
190-
with:
191-
toolchain: nightly
192-
profile: minimal
193-
- name: Select minimal versions
194-
uses: actions-rs/cargo@v1
195-
with:
196-
command: update
197-
args: -Z minimal-versions
198-
toolchain: nightly
199-
- name: Check
200-
uses: actions-rs/cargo@v1
201-
with:
202-
command: check
203-
# skip the following crates:
204-
# - tracing-appender, as it has its own MSRV.
205-
# TODO(eliza): remove this when appender is on the same MSRV as
206-
# everything else
207-
# - the examples, as they are not published & we don't care about
208-
# MSRV support for them.
209-
# - tracing-futures, as it depends on ancient tokio versions.
210-
# TODO(eliza): remove this when the ancient tokio deps are dropped
211-
args: >-
212-
--workspace --all-features --locked
213-
--exclude=tracing-appender
214-
--exclude=tracing-examples
215-
--exclude=tracing-futures
216-
toolchain: ${{ env.MSRV }}
217-
218-
# TODO: remove this once tracing's MSRV is bumped.
219-
check-msrv-appender:
220-
# Run `cargo check` on our minimum supported Rust version (1.53.0).
221-
name: "cargo check (tracing-appender MSRV)"
126+
# Run `cargo check` on our minimum supported Rust version (1.49.0). This
127+
# checks with minimal versions; maximal versions are checked above.
128+
name: "cargo check (+MSRV -Zminimal-versions)"
222129
needs: check
223130
runs-on: ubuntu-latest
131+
strategy:
132+
matrix:
133+
# cargo hack --feature-powerset will have a significant permutation
134+
# number, we can't just use --all as it increases the runtime
135+
# further than what we would like to
136+
subcrate:
137+
- tracing-attributes
138+
- tracing-core
139+
- tracing-futures
140+
- tracing-log
141+
- tracing-macros
142+
- tracing-serde
143+
- tracing-tower
144+
- tracing-opentelemetry
145+
- tracing
146+
- tracing-subscriber
147+
toolchain:
148+
- 1.49.0
149+
- stable
150+
# TODO(eliza): remove this when appender is on the same MSRV.
151+
exclude:
152+
- subcrate: tracing-appender
153+
toolchain: 1.49.0
154+
include:
155+
- subcrate: tracing-appender
156+
toolchain: 1.53.0
224157
steps:
225158
- uses: actions/checkout@v3
226-
- name: "install Rust ${{ env.APPENDER_MSRV }}"
227-
uses: actions-rs/toolchain@v1
228-
with:
229-
toolchain: ${{ env.APPENDER_MSRV }}
230-
profile: minimal
231-
- name: "install Rust nightly"
232-
uses: actions-rs/toolchain@v1
159+
- name: install Rust nightly
160+
uses: dtolnay/rust-toolchain@nightly
161+
- name: "install Rust ${{ matrix.toolchain }}"
162+
uses: dtolnay/rust-toolchain@master
233163
with:
234-
toolchain: nightly
235-
profile: minimal
236-
- name: Select minimal versions
237-
uses: actions-rs/cargo@v1
238-
with:
239-
command: update
240-
args: -Z minimal-versions
241-
toolchain: nightly
242-
- name: Check
243-
uses: actions-rs/cargo@v1
244-
with:
245-
command: check
246-
args: --all-features --locked -p tracing-appender
247-
toolchain: ${{ env.APPENDER_MSRV }}
164+
toolchain: ${{ matrix.toolchain }}
165+
- name: install cargo-hack
166+
uses: taiki-e/install-action@cargo-hack
167+
- name: install cargo-minimal-versions
168+
uses: taiki-e/install-action@cargo-minimal-versions
169+
- name: cargo minimal-versions check
170+
working-directory: ${{ matrix.subcrate }}
171+
# tracing and tracing-subscriber have too many features to be checked by
172+
# cargo-hack --feature-powerset with all features in the powerset, so
173+
# exclude some
174+
run: |
175+
CARGO_MINVER=(cargo minimal-versions check --feature-powerset --no-dev-deps)
176+
case "${{ matrix.subcrate }}" in
177+
tracing)
178+
EXCLUDE_FEATURES=(
179+
max_level_off max_level_error max_level_warn max_level_info
180+
max_level_debug max_level_trace release_max_level_off
181+
release_max_level_error release_max_level_warn
182+
release_max_level_info release_max_level_debug
183+
release_max_level_trace
184+
)
185+
${CARGO_MINVER[@]} --exclude-features "${EXCLUDE_FEATURES[*]}"
186+
;;
187+
tracing-subscriber)
188+
INCLUDE_FEATURES=(fmt ansi json registry env-filter)
189+
${CARGO_MINVER[@]} --include-features "${INCLUDE_FEATURES[*]}"
190+
;;
191+
tracing-futures)
192+
EXCLUDE_FEATURES=(futures-01 futures_01 tokio tokio_01)
193+
${CARGO_MINVER[@]} --exclude-features "${EXCLUDE_FEATURES[*]}"
194+
;;
195+
*)
196+
${CARGO_MINVER[@]}
197+
;;
198+
esac
199+
shell: bash
248200

249201
### test jobs #############################################################
250202

@@ -268,11 +220,10 @@ jobs:
268220
runs-on: ${{ matrix.os }}
269221
steps:
270222
- uses: actions/checkout@v3
271-
- uses: actions-rs/toolchain@v1
223+
- name: "install Rust ${{ matrix.rust }}"
224+
uses: dtolnay/rust-toolchain@master
272225
with:
273226
toolchain: ${{ matrix.rust }}
274-
profile: minimal
275-
override: true
276227
- name: install cargo-nextest
277228
uses: taiki-e/install-action@nextest
278229
- name: Run tests
@@ -312,16 +263,11 @@ jobs:
312263
fail-fast: false
313264
steps:
314265
- uses: actions/checkout@v3
315-
- uses: actions-rs/toolchain@v1
266+
- uses: dtolnay/rust-toolchain@stable
316267
with:
317268
target: wasm32-unknown-unknown
318-
toolchain: stable
319-
override: true
320269
- name: build all tests
321-
uses: actions-rs/cargo@v1
322-
with:
323-
command: test
324-
args: --no-run -p ${{ matrix.subcrate }}
270+
run: cargo test --no-run -p ${{ matrix.subcrate }}
325271

326272
test-wasm:
327273
name: cargo test (wasm)
@@ -333,11 +279,9 @@ jobs:
333279
- tracing
334280
steps:
335281
- uses: actions/checkout@v3
336-
- uses: actions-rs/toolchain@v1
282+
- uses: dtolnay/rust-toolchain@stable
337283
with:
338284
target: wasm32-unknown-unknown
339-
toolchain: stable
340-
override: true
341285
- name: install test runner for wasm
342286
uses: taiki-e/install-action@wasm-pack
343287
- name: run wasm tests
@@ -353,11 +297,7 @@ jobs:
353297
runs-on: ubuntu-latest
354298
steps:
355299
- uses: actions/checkout@v3
356-
- uses: actions-rs/toolchain@v1
357-
with:
358-
toolchain: stable
359-
profile: minimal
360-
override: true
300+
- uses: dtolnay/rust-toolchain@stable
361301
- name: "Test log support"
362302
run: cargo test
363303
working-directory: "tracing/test-log-support"
@@ -386,10 +326,8 @@ jobs:
386326
runs-on: ubuntu-latest
387327
needs:
388328
- style
389-
- minimal-versions
390329
- cargo-hack
391330
- check-msrv
392-
- check-msrv-appender
393331
- test-build-wasm
394332
- test-wasm
395333
- test-features-stable

0 commit comments

Comments
 (0)