Skip to content

Commit 361ef70

Browse files
authored
Run tests using cargo-nextest (#1710)
Install and configure [cargo-nextest](https://nexte.st/) to run tests in GitHub actions. ### Does this change impact existing behavior? No. ### Does this change need a changelog entry? Does it require a version change? No. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). --------- Signed-off-by: Alessandro Passaro <[email protected]>
1 parent a83e3f1 commit 361ef70

File tree

4 files changed

+76
-20
lines changed

4 files changed

+76
-20
lines changed

.config/nextest.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[profile.ci]
2+
# Do not cancel the test run on the first failure.
3+
fail-fast = false

.github/workflows/integration.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,18 @@ jobs:
9999
# setup-rust-toolchain sets "-D warnings" by default, and Rust treats any warning as compile error.
100100
# We need to do this currently because `mountpoint-s3-fuser` contains some warnings and it breaks the build.
101101
rustflags: ""
102+
- name: Install nextest
103+
uses: taiki-e/install-action@v2
104+
with:
105+
tool: nextest
102106
- name: Install operating system dependencies
103107
uses: ./.github/actions/install-dependencies
104108
with:
105109
fuseVersion: ${{ matrix.fuseVersion }}
106110
- name: Build tests
107-
run: cargo test ${{ env.packages }} --features '${{ env.features }}' --no-run
111+
run: cargo nextest run --profile ci ${{ env.packages }} --features '${{ env.features }}' --no-run
108112
- name: Run tests
109-
run: cargo test ${{ env.packages }} --features '${{ env.features }}'
113+
run: cargo nextest run --profile ci ${{ env.packages }} --features '${{ env.features }}'
110114
- name: Save dump files
111115
if: ${{ failure() && matrix.runner.name == 'AL2 arm' }}
112116
run: ./.github/actions/scripts/save-coredump.sh
@@ -159,15 +163,19 @@ jobs:
159163
# setup-rust-toolchain sets "-D warnings" by default, and Rust treats any warning as compile error.
160164
# We need to do this currently because `mountpoint-s3-fuser` contains some warnings and it breaks the build.
161165
rustflags: ""
166+
- name: Install nextest
167+
uses: taiki-e/install-action@v2
168+
with:
169+
tool: nextest
162170
- name: Install operating system dependencies
163171
uses: ./.github/actions/install-dependencies
164172
with:
165173
# not required for client tests. TODO: make it optional.
166174
fuseVersion: 2
167175
- name: Build tests
168-
run: cargo test ${{ env.packages }} --features '${{ env.features }}' --no-run
176+
run: cargo nextest run --profile ci ${{ env.packages }} --features '${{ env.features }}' --no-run
169177
- name: Run tests
170-
run: cargo test ${{ env.packages }} --features '${{ env.features }}'
178+
run: cargo nextest run --profile ci ${{ env.packages }} --features '${{ env.features }}'
171179
- name: Save dump files
172180
if: ${{ failure() && matrix.runner.name == 'AL2 arm' }}
173181
run: ./.github/actions/scripts/save-coredump.sh
@@ -249,6 +257,10 @@ jobs:
249257
# We need to do this currently because `mountpoint-s3-fuser` contains some warnings and it breaks the build.
250258
rustflags: ""
251259
components: rust-src
260+
- name: Install nextest
261+
uses: taiki-e/install-action@v2
262+
with:
263+
tool: nextest
252264
- name: Install operating system dependencies
253265
uses: ./.github/actions/install-dependencies
254266
with:

.github/workflows/tests.yml

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Tests
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ "main", "wf-changes/**" ]
66
pull_request:
77
merge_group:
88
types: [ "checks_requested" ]
@@ -40,6 +40,10 @@ jobs:
4040
# setup-rust-toolchain sets "-D warnings" by default, and Rust treats any warning as compile error.
4141
# We need to do this currently because `mountpoint-s3-fuser` contains some warnings and it breaks the build.
4242
rustflags: ""
43+
- name: Install nextest
44+
uses: taiki-e/install-action@v2
45+
with:
46+
tool: nextest
4347
- name: Cargo cache
4448
uses: actions/cache@v3
4549
with:
@@ -51,9 +55,40 @@ jobs:
5155
target/
5256
key: ${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-fuse${{ matrix.fuseVersion }}-cargo-${{ hashFiles('**/Cargo.lock') }}
5357
- name: Build tests
54-
run: cargo test --features $RUST_FEATURES --no-run
58+
run: cargo nextest run --profile ci --features $RUST_FEATURES --no-run
5559
- name: Run tests
56-
run: cargo test --features $RUST_FEATURES
60+
run: cargo nextest run --profile ci --features $RUST_FEATURES
61+
62+
doc-tests:
63+
name: Doc-Tests
64+
runs-on: ubuntu-22.04
65+
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v6
69+
with:
70+
submodules: true
71+
- name: Install operating system dependencies
72+
uses: ./.github/actions/install-dependencies
73+
with:
74+
fuseVersion: 2
75+
- name: Set up Rust toolchain
76+
uses: actions-rust-lang/setup-rust-toolchain@v1
77+
with:
78+
rustflags: ""
79+
- name: Cargo cache
80+
uses: actions/cache@v3
81+
with:
82+
path: |
83+
~/.cargo/bin/
84+
~/.cargo/registry/index/
85+
~/.cargo/registry/cache/
86+
~/.cargo/git/db/
87+
target/
88+
key: ${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-cargo-${{ hashFiles('**/Cargo.lock') }}
89+
- name: Run doc-tests
90+
# Skip `mountpoint-s3-fuser` and `mountpoint-s3-crt-sys` (prevents C docs being interpreted as rustdoc tests).
91+
run: cargo test --doc --workspace --exclude mountpoint-s3-crt-sys --exclude mountpoint-s3-fuser --features $RUST_FEATURES
5792

5893
macos-test:
5994
name: Tests (MacOS)
@@ -79,6 +114,10 @@ jobs:
79114
# setup-rust-toolchain sets "-D warnings" by default, and Rust treats any warning as compile error.
80115
# We need to do this currently because `mountpoint-s3-fuser` contains some warnings and it breaks the build.
81116
rustflags: ""
117+
- name: Install nextest
118+
uses: taiki-e/install-action@v2
119+
with:
120+
tool: nextest
82121
- name: Cargo cache
83122
uses: actions/cache@v3
84123
with:
@@ -90,10 +129,10 @@ jobs:
90129
target/
91130
key: ${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-cargo-${{ hashFiles('**/Cargo.lock') }}
92131
- name: Build tests
93-
run: cargo test --no-run
132+
run: cargo nextest run --profile ci --no-run
94133
- name: Run tests
95134
# Skip `mountpoint-s3-fuser` tests on macOS.
96-
run: cargo test --workspace --exclude mountpoint-s3-fuser
135+
run: cargo nextest run --profile ci --workspace --exclude mountpoint-s3-fuser
97136

98137
check:
99138
name: Check all targets
@@ -174,6 +213,10 @@ jobs:
174213
# setup-rust-toolchain sets "-D warnings" by default, and Rust treats any warning as compile error.
175214
# We need to do this currently because `mountpoint-s3-fuser` contains some warnings and it breaks the build.
176215
rustflags: ""
216+
- name: Install nextest
217+
uses: taiki-e/install-action@v2
218+
with:
219+
tool: nextest
177220
- name: Install operating system dependencies
178221
uses: ./.github/actions/install-dependencies
179222
with:
@@ -189,7 +232,7 @@ jobs:
189232
target/
190233
key: ${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-cargo-${{ hashFiles('**/Cargo.lock') }}
191234
- name: Run Shuttle tests
192-
run: cargo test -p mountpoint-s3-fs --features shuttle -- shuttle
235+
run: cargo nextest run --profile ci -p mountpoint-s3-fs --features shuttle -- shuttle
193236

194237
rustfmt:
195238
name: Formatting
@@ -343,6 +386,7 @@ jobs:
343386
runs-on: ubuntu-latest
344387
needs:
345388
- test
389+
- doc-tests
346390
- macos-test
347391
- check
348392
- bench

Makefile

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
CRATES = mountpoint-s3-crt-sys mountpoint-s3-crt mountpoint-s3-client mountpoint-s3-fs mountpoint-s3
66
RUST_FEATURES ?= fuse_tests
7+
PACKAGES = $(shell echo "${CRATES}" | sed -E 's/(^| )/ -p /g')
78

89
.PHONY: all
910
all:
@@ -19,49 +20,45 @@ check:
1920

2021
.PHONY: test
2122
test:
22-
@packages=`echo "$(CRATES)" | sed -E 's/(^| )/ -p /g'`; \
23-
cargo test $$packages
23+
cargo nextest run ${PACKAGES}
2424

2525
# Run a test that we know should fail if ASan is enabled
2626
.PHONY: test-asan-working
2727
test-asan-working:
28-
@packages=`echo "$(CRATES)" | sed -E 's/(^| )/ -p /g'`; \
2928
RUSTFLAGS="-Zsanitizer=address" \
3029
RUSTC_BOOTSTRAP=1 \
31-
cargo test -Z build-std --target `rustc -vV | grep 'host:' | cut -f2 -d' '` --lib --features $(RUST_FEATURES) $$packages -- --ignored test_asan_working 2>&1 \
30+
cargo test -Z build-std --target `rustc -vV | grep 'host:' | cut -f2 -d' '` --lib --features ${RUST_FEATURES} ${PACKAGES} -- --ignored test_asan_working 2>&1 \
3231
| tee /dev/stderr \
3332
| grep "heap-use-after-free" \
3433
&& echo "ASan is working" || (echo "ASan did not find the use-after-free; something's wrong"; exit 1)
3534

3635
.PHONY: test-asan
3736
test-asan:
38-
@packages=`echo "$(CRATES)" | sed -E 's/(^| )/ -p /g'`; \
3937
LSAN_OPTIONS=suppressions="$$(pwd)/lsan-suppressions.txt" \
4038
RUSTFLAGS="-Zsanitizer=address" \
4139
RUSTC_BOOTSTRAP=1 \
4240
cargo test -Z build-std --target `rustc -vV | grep 'host:' | cut -f2 -d' '` \
4341
--lib --bins --tests \
44-
--features $(RUST_FEATURES) $$packages -- \
42+
--features ${RUST_FEATURES} ${PACKAGES} -- \
4543
--skip reftest_ \
4644
--skip proptest_ \
4745
--skip fork_test \
4846
--skip sequential_read_large
4947

5048
.PHONY: fmt
5149
fmt:
52-
@for crate in $(CRATES); do \
50+
@for crate in ${CRATES}; do \
5351
cargo fmt --manifest-path $$crate/Cargo.toml; \
5452
done
5553

5654
.PHONY: fmt-check
5755
fmt-check:
5856
@fail=0; \
59-
for crate in $(CRATES); do \
57+
for crate in ${CRATES}; do \
6058
cargo fmt --manifest-path $$crate/Cargo.toml -- --check || fail=1; \
6159
done; \
6260
exit $$fail
6361

6462
.PHONY: clippy
6563
clippy:
66-
@packages=`echo "$(CRATES)" | sed -E 's/(^| )/ -p /g'`; \
67-
cargo clippy $$packages --no-deps --all-targets --all-features -- -D warnings -D clippy::all
64+
cargo clippy ${PACKAGES} --no-deps --all-targets --all-features -- -D warnings -D clippy::all

0 commit comments

Comments
 (0)