-
Notifications
You must be signed in to change notification settings - Fork 722
318 lines (304 loc) · 10.3 KB
/
CI.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
name: CI
on:
push:
branches:
- master
pull_request: {}
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
jobs:
### check jobs ###
check:
# Run `cargo check` first to ensure that the pushed code at least compiles.
name: cargo check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Check
run: cargo check --all --tests --benches
style:
# Check style.
name: cargo fmt
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: rustfmt
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@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --examples --tests --benches -- -D warnings
cargo-hack:
needs: check
name: cargo check (feature combinations)
runs-on: ubuntu-latest
strategy:
matrix:
# cargo hack --feature-powerset will have a significant permutation
# number, we can't just use --all as it increases the runtime
# further than what we would like to
subcrate:
- tracing-attributes
- tracing-core
- tracing-futures
- tracing-log
- tracing-macros
- tracing-serde
- tracing-tower
- tracing
- tracing-subscriber
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: cargo hack 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_HACK=(cargo hack 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_HACK[@]} --exclude-features "${EXCLUDE_FEATURES[*]}"
;;
tracing-subscriber)
INCLUDE_FEATURES=(fmt ansi json registry env-filter)
${CARGO_HACK[@]} --include-features "${INCLUDE_FEATURES[*]}"
;;
*)
${CARGO_HACK[@]}
;;
esac
shell: bash
check-msrv:
# Run `cargo check` on our minimum supported Rust version (1.63.0). This
# checks with minimal versions; maximal versions are checked above.
name: "cargo check (+MSRV -Zminimal-versions)"
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
# cargo hack --feature-powerset will have a significant permutation
# number, we can't just use --all as it increases the runtime
# further than what we would like to
subcrate:
- tracing-appender
- tracing-attributes
- tracing-core
- tracing-futures
- tracing-log
- tracing-macros
- tracing-serde
- tracing-subscriber
- tracing-tower
- tracing
toolchain:
- 1.63.0
- stable
steps:
- uses: actions/checkout@v4
- name: install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: "install Rust ${{ matrix.toolchain }}"
uses: dtolnay/rust-toolchain@master
with:
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 #############################################################
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:
# test all Rust versions on ubuntu-latest
os: [ubuntu-latest]
rust: [stable, beta, nightly]
# test stable Rust on Windows and MacOS as well
include:
- rust: stable
os: windows-latest
- rust: stable
os: macos-latest
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: "install Rust ${{ matrix.rust }}"
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Run tests
run: cargo nextest run --profile ci --workspace
# TODO(eliza): punt on this for now because the generated JUnit report is
# missing some fields that this action needs to give good output.
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v3
# if: always() # always run even if the previous step fails
# with:
# report_paths: 'target/nextest/ci/junit.xml'
# check_name: "cargo test (Rust ${{ matrix.rust }} on ${{ matrix.os }})"
# check_title_template: "{{SUITE_NAME}}::{{TEST_NAME}}"
- name: Run doctests
run: cargo test --doc --workspace
test-build-wasm:
name: build tests (wasm)
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
# TODO(securityinsanity): slowly add wasm32 test runner to each crate, and move to seperate actions that run tests.
subcrate:
- tracing-appender
- tracing-attributes
- tracing-core
- tracing-error
- tracing-flame
- tracing-journald
- tracing-log
- tracing-macros
- tracing-serde
- tracing-subscriber
- tracing-tower
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown
- name: build all tests
run: cargo test --no-run -p ${{ matrix.subcrate }}
test-wasm:
name: cargo test (wasm)
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
subcrate:
- tracing
steps:
- uses: actions/checkout@v4
- name: Install Rust 1.81
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.81
target: wasm32-unknown-unknown
- name: install test runner for wasm
uses: taiki-e/install-action@wasm-pack
- name: run wasm tests
run: cd ${{ matrix.subcrate }} && wasm-pack test --node
test-features-stable:
# Feature flag tests that run on stable Rust.
name: cargo test (feature-specific)
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: "Test log support"
run: cargo test
- name: "Test static max level"
run: cargo test
- name: "Test static max level (release)"
run: cargo test --release
- 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 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
# specific matrix combinations from)
all_required:
name: "all systems go!"
runs-on: ubuntu-latest
needs:
- style
- cargo-hack
- check-msrv
- test-build-wasm
- test-wasm
- test-features-stable
steps:
- run: exit 0