Skip to content

Commit f74dce2

Browse files
committed
Run tests on CI with cargo-nextest
1 parent b8dd626 commit f74dce2

File tree

2 files changed

+74
-7
lines changed

2 files changed

+74
-7
lines changed

.config/nextest.toml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[store]
2+
# The directory under the workspace root at which nextest-related files are
3+
# written. Profile-specific storage is currently written to dir/<profile-name>.
4+
dir = "target/nextest"
5+
6+
# This section defines the default nextest profile. Custom profiles are layered
7+
# on top of the default profile.
8+
[profile.default]
9+
# "retries" defines the number of times a test should be retried. If set to a
10+
# non-zero value, tests that succeed on a subsequent attempt will be marked as
11+
# non-flaky. Can be overridden through the `--retries` option.
12+
retries = 2
13+
14+
# Show these test statuses in the output.
15+
#
16+
# The possible values this can take are:
17+
# * none: no output
18+
# * fail: show failed (including exec-failed) tests
19+
# * retry: show flaky and retried tests
20+
# * slow: show slow tests
21+
# * pass: show passed tests
22+
# * skip: show skipped tests (most useful for CI)
23+
# * all: all of the above
24+
#
25+
# Each value includes all the values above it; for example, "slow" includes
26+
# failed and retried tests.
27+
#
28+
# Can be overridden through the `--status-level` flag.
29+
status-level = "pass"
30+
31+
# "failure-output" defines when test failures are output to standard output.
32+
# Accepted values are
33+
# * "immediate": output failures as soon as they happen
34+
# * "final": output failures at the end of the test run
35+
# * "immediate-final": output failures as soon as they happen and at the end of
36+
# the test run
37+
# * "never": don't output failures at all
38+
#
39+
# For large test suites and CI it is generally useful to use "immediate-final".
40+
#
41+
# Can be overridden through the `--failure-output` option.
42+
failure-output = "immediate"
43+
44+
# "success-output" controls output on success. This should generally be set to
45+
# "never".
46+
success-output = "never"
47+
48+
# Cancel the test run on the first failure. For CI runs, consider setting this
49+
# to false.
50+
fail-fast = false
51+
52+
# Treat a test that takes longer than this as slow, and print a message.
53+
slow-timeout = "60s"
54+
55+
[profile.default.junit]
56+
# Output a JUnit report into the given file inside 'store.dir/<profile-name>'.
57+
# If unspecified, JUnit is not written out.
58+
59+
# path = "junit.xml"
60+
61+
# The name of the top-level "report" element in JUnit report. If aggregating
62+
# reports across different test runs, it may be useful to provide separate names
63+
# for each report.
64+
report-name = "nextest-run"

.github/workflows/ci.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ jobs:
163163
# needed to correctly format errors, see #1865
164164
components: rust-src
165165

166+
- name: Install cargo-nextest
167+
uses: taiki-e/install-action@nextest
168+
166169
- uses: Swatinem/rust-cache@v1
167170
with:
168171
key: cargo-${{ matrix.platform.python-architecture }}-${{ matrix.platform.os }}-${{ matrix.msrv }}
@@ -193,13 +196,13 @@ jobs:
193196
# Run tests (except on PyPy, because no embedding API).
194197
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
195198
name: Test (no features)
196-
run: cargo test --no-default-features --lib --tests
199+
run: cargo nextest run --no-default-features --lib --tests
197200

198201
# --no-default-features when used with `cargo build/test -p` doesn't seem to work!
199202
- name: Test pyo3-build-config (no features)
200203
run: |
201204
cd pyo3-build-config
202-
cargo test --no-default-features
205+
cargo nextest run --no-default-features
203206
204207
- name: Build (all additive features)
205208
run: cargo build --lib --tests --no-default-features --features "full ${{ matrix.extra_features }}"
@@ -211,23 +214,23 @@ jobs:
211214
# Run tests (except on PyPy, because no embedding API).
212215
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
213216
name: Test
214-
run: cargo test --no-default-features --features "full ${{ matrix.extra_features }}"
217+
run: cargo nextest run --no-default-features --features "full ${{ matrix.extra_features }}"
215218

216219
# Run tests again, but in abi3 mode
217220
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
218221
name: Test (abi3)
219-
run: cargo test --no-default-features --features "abi3 full ${{ matrix.extra_features }}"
222+
run: cargo nextest run --no-default-features --features "abi3 full ${{ matrix.extra_features }}"
220223

221224
# Run tests again, for abi3-py37 (the minimal Python version)
222225
- if: ${{ (!startsWith(matrix.python-version, 'pypy')) && (matrix.python-version != '3.7') }}
223226
name: Test (abi3-py37)
224-
run: cargo test --no-default-features --features "abi3-py37 full ${{ matrix.extra_features }}"
227+
run: cargo nextest run --no-default-features --features "abi3-py37 full ${{ matrix.extra_features }}"
225228

226229
- name: Test proc-macro code
227-
run: cargo test --manifest-path=pyo3-macros-backend/Cargo.toml
230+
run: cargo nextest run --manifest-path=pyo3-macros-backend/Cargo.toml
228231

229232
- name: Test build config
230-
run: cargo test --manifest-path=pyo3-build-config/Cargo.toml
233+
run: cargo nextest run --manifest-path=pyo3-build-config/Cargo.toml
231234

232235
- name: Test python examples and tests
233236
shell: bash

0 commit comments

Comments
 (0)