-
-
Notifications
You must be signed in to change notification settings - Fork 154
390 lines (366 loc) · 14.6 KB
/
ci.yml
File metadata and controls
390 lines (366 loc) · 14.6 KB
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
on:
push:
branches: [main, auto, canary]
pull_request:
branches:
- main
name: CI
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
RUSTFLAGS: -D warnings
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
- name: Set temp directory on Windows
if: ${{ runner.os == 'Windows' }}
run: |
mkdir -p "D:\a\_temp"
echo "TEMP=D:\a\_temp" >> $GITHUB_ENV
echo "TMP=D:\a\_temp" >> $GITHUB_ENV
shell: bash
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Lint (clippy)
run: cargo clippy --all-features --all-targets
- name: Lint (rustfmt)
run: cargo xfmt --check
- name: Install cargo readme
uses: taiki-e/install-action@c12d62a803cbdfe2e7263af15f5a9548065cb4f2 # v2.69.3
with:
tool: cargo-readme
- name: Run cargo readme
run: ./scripts/regenerate-readmes.sh
- name: Check for differences
run: git diff --exit-code
build-rustdoc:
name: Build documentation
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Build rustdoc
run: cargo doc --all-features --workspace
nextest-metadata-msrv:
name: Build nextest-metadata on MSRV
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
rust-version: ["1.78"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
- name: Build nextest-metadata-msrv
run: cd fixtures/nextest-metadata-msrv && cargo build
# It would be nice to run tests, but it seems hard to do that without some
# horrible patching of the various Cargo.toml files. It's also not really
# necessary, since we already run tests in the "Build and test" job below.
build:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
- macos-latest
- windows-latest
# 1.91 is the MSRV
rust-version: ["1.91", stable]
fail-fast: false
steps:
- name: Set temp directory on Windows
if: ${{ runner.os == 'Windows' }}
run: |
mkdir -p "D:\a\_temp"
echo "TEMP=D:\a\_temp" >> $GITHUB_ENV
echo "TMP=D:\a\_temp" >> $GITHUB_ENV
shell: bash
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
# Matrix instances (other than OS) need to be added to this explicitly
key: ${{ matrix.rust-version }}
- name: Install latest nextest release
uses: taiki-e/install-action@c12d62a803cbdfe2e7263af15f5a9548065cb4f2 # v2.69.3
with:
tool: nextest
- name: Build nextest-metadata
run: cargo build --package nextest-metadata
- name: Build cargo-nextest without self-update
run: cargo build --package cargo-nextest --no-default-features --features default-no-update
- name: Build cargo-nextest
run: cargo build --package cargo-nextest
- name: Build all targets
run: cargo build --all-targets
- name: Build all targets with all features
run: cargo build --all-targets --all-features
- name: Doctests
run: cargo test --doc
# Set up recording for the local nextest run.
- name: Create recording user config
shell: bash
run: |
mkdir -p "$RUNNER_TEMP/nextest-config"
printf '[experimental]\nrecord = true\n\n[record]\nenabled = true\n' \
> "$RUNNER_TEMP/nextest-config/config.toml"
cat "$RUNNER_TEMP/nextest-config/config.toml"
- name: Test with locally built nextest
shell: bash
env:
NEXTEST_STATE_DIR: ${{ runner.temp }}/nextest-state
run: cargo local-nt run --profile ci --user-config-file "$RUNNER_TEMP/nextest-config/config.toml"
- name: Create portable archive from recorded run
# Run this step even if the test step fails.
if: "!cancelled()"
env:
NEXTEST_STATE_DIR: ${{ runner.temp }}/nextest-state
shell: bash
run: |
cargo local-nt store export latest \
--user-config-file "$RUNNER_TEMP/nextest-config/config.toml" \
--archive-file "$RUNNER_TEMP/nextest-run-archive.zip"
- name: Upload recorded run archive
# Run this step even if the test step fails.
if: "!cancelled()"
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: nextest-run-${{ matrix.os }}-${{ matrix.rust-version }}
path: ${{ runner.temp }}/nextest-run-archive.zip
- name: Upload results
# Run this step even if the test step fails
if: "!cancelled()"
uses: trunk-io/analytics-uploader@95a0fb8b29e45b6068304261fb518644b426a803 # v2.0.8
with:
# Path to your test results.
junit-paths: target/nextest/ci/junit.xml
# Provide your Trunk organization slug.
org-slug: nextest-rs
# Provide your Trunk API token as a GitHub secret.
token: ${{ secrets.TRUNK_API_TOKEN }} # zizmor: ignore[secrets-outside-env]
continue-on-error: true
- name: Upload JUnit report
# Run this step even if the test step fails. Upload it right now because
# we're most interested in the JUnit report generated by the local
# version of nextest, not the latest release.
if: "!cancelled()"
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: junit-${{ matrix.os }}-${{ matrix.rust-version }}.xml
path: |
target/nextest/ci/junit.xml
if-no-files-found: error
- name: Test with latest nextest release
run: cargo nextest run --profile ci
- name: Test without double-spawning
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' || matrix.os == 'macos-latest' }}
env:
NEXTEST_DOUBLE_SPAWN: 0
run: cargo local-nt run --profile ci
- name: Test without rustup wrappers
env:
CARGO_NEXTEST: target/debug/cargo-nextest
RUSTUP_AVAILABLE: 1
shell: bash
run: ./scripts/nextest-without-rustup.sh run --profile ci
- name: Upload nextest binary
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cargo-nextest-${{ matrix.os }}-${{ matrix.rust-version }}
path: |
target/debug/cargo-nextest
target/debug/cargo-nextest.exe
if-no-files-found: error
test-archive-target-runner:
name: Test archives with a target runner
# We need at least 24.04 for updated wine and mingw. 22.04 has a wine that's too old (and the
# official WineHQ PPA breaks every so often).
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: x86_64-pc-windows-gnu
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Install wine and gcc-mingw-w64-x86-64-win32
run: |
sudo apt-get update
sudo apt-get install wine gcc-mingw-w64-x86-64-win32
- name: Build cargo-nextest
run: cargo build --package cargo-nextest
- name: Archive test fixtures
env:
CARGO_NEXTEST: target/debug/cargo-nextest
RUSTUP_AVAILABLE: 1
run: |
./scripts/nextest-without-rustup.sh archive --manifest-path fixtures/fixture-project/Cargo.toml \
--target x86_64-pc-windows-gnu --archive-file target/fixture-archive.tar.zst \
--package cdylib-example --package nextest-derive
# This ensures that for target binaries, we always use the libdir in the archive, never the
# one installed by rustup.
- name: Remove x86_64-pc-windows-gnu target from rustup
run: rustup target remove x86_64-pc-windows-gnu
- name: Run test fixtures
env:
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER: wine
run: cargo local-nt run --archive-file target/fixture-archive.tar.zst
# Completely uninstall rustup -- this is similar to running an archive on a machine without
# cargo.
- name: Uninstall rustup
run: rustup self uninstall -y
- name: Run test fixtures without rustup wrappers
env:
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER: wine
CARGO_NEXTEST: target/debug/cargo-nextest
run: ./scripts/nextest-without-rustup.sh run --archive-file target/fixture-archive.tar.zst
# Upload the archive for use in the next job.
- name: Upload archive
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: fixture-archive
path: target/fixture-archive.tar.zst
if-no-files-found: error
test-archive-runner-dest:
name: Test archives with a runner (destination)
strategy:
matrix:
data:
- os: ubuntu-24.04
# The artifact name is set by the upload job, which is ubuntu-latest.
artifact-name: ubuntu-latest
- os: windows-latest
artifact-name: windows-latest
runs-on: ${{ matrix.data.os }}
needs:
- test-archive-target-runner
- build
steps:
- name: Set temp directory on Windows
if: ${{ runner.os == 'Windows' }}
run: |
mkdir -p "D:\a\_temp"
echo "TEMP=D:\a\_temp" >> $GITHUB_ENV
echo "TMP=D:\a\_temp" >> $GITHUB_ENV
shell: bash
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Download nextest binary
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: cargo-nextest-${{ matrix.data.artifact-name }}-stable
path: nextest-bin
- name: Download archive
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: fixture-archive
path: fixture-archive
- name: Run test fixtures (host)
if: ${{ matrix.data.artifact-name == 'ubuntu-latest' }}
env:
CARGO_NEXTEST: nextest-bin/cargo-nextest
run: |
chmod +x $CARGO_NEXTEST
./scripts/nextest-without-rustup.sh run \
--archive-file fixture-archive/fixture-archive.tar.zst \
--workspace-remap $GITHUB_WORKSPACE/fixtures/fixture-project \
-E 'platform(host)'
- name: Run test fixtures (target)
if: ${{ matrix.data.artifact-name == 'windows-latest' }}
shell: bash
env:
CARGO_NEXTEST: nextest-bin/cargo-nextest.exe
run: |
./scripts/nextest-without-rustup.sh run \
--archive-file fixture-archive/fixture-archive.tar.zst \
--workspace-remap $GITHUB_WORKSPACE/fixtures/fixture-project \
-E 'platform(target)'
test-build-dir:
name: Test with Cargo build-dir
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Build cargo-nextest
run: cargo build --package cargo-nextest
# build.build-dir was stabilized in Cargo 1.91. The new layout is
# still nightly-only (-Zbuild-dir-new-layout).
- name: Run fixture tests with build-dir
env:
CARGO_NEXTEST: target/debug/cargo-nextest
RUSTUP_AVAILABLE: 1
CARGO_BUILD_BUILD_DIR: ${{ github.workspace }}/build-output
run: |
./scripts/nextest-without-rustup.sh run \
-Z build-dir-new-layout \
--manifest-path fixtures/fixture-project/Cargo.toml \
--package cdylib-link --package cdylib-example \
--package with-build-script
- name: Archive fixture tests with build-dir
env:
CARGO_NEXTEST: target/debug/cargo-nextest
RUSTUP_AVAILABLE: 1
CARGO_BUILD_BUILD_DIR: ${{ github.workspace }}/build-output
run: |
./scripts/nextest-without-rustup.sh archive \
-Z build-dir-new-layout \
--manifest-path fixtures/fixture-project/Cargo.toml \
--archive-file target/build-dir-archive.tar.zst \
--package cdylib-link --package cdylib-example \
--package with-build-script
# Run from the archive without build-dir env to verify archive
# portability. (build_directory is normalized to target_directory in the
# archive). Wipe both the target and build directories first to ensure
# the archive is self-contained.
- name: Run from archive without build-dir
env:
CARGO_NEXTEST: target/debug/cargo-nextest
# Do not set RUSTUP_AVAILABLE here, since running tests out of an
# archive should not require rustup or Cargo.
run: |
rm -r fixtures/fixture-project/target ${{ github.workspace }}/build-output
./scripts/nextest-without-rustup.sh run \
--archive-file target/build-dir-archive.tar.zst