1
1
# Working example showing how to use nextest to reuse builds and partition test runs on GitHub Actions.
2
2
# See workflow runs at https://github.com/nextest-rs/reuse-build-partition-example/actions/workflows/ci.yml.
3
3
4
+ name : CI
5
+
4
6
on :
7
+ pull_request :
8
+ branches : [main]
5
9
push :
6
10
branches : [main]
7
11
schedule :
8
12
# Run this every day at 01:00 UTC.
9
13
- cron : 0 1 * * *
10
14
15
+ env :
16
+ CARGO_TERM_COLOR : always
17
+
11
18
jobs :
12
19
build-test-artifacts :
13
20
name : Build test artifacts
@@ -24,21 +31,13 @@ jobs:
24
31
override : true
25
32
- name : Install nextest
26
33
uses : taiki-e/install-action@nextest
27
- - name : Create target directory
28
- run : mkdir -p target
29
- - name : Gather Cargo metadata
30
- run : cargo metadata --format-version=1 --all-features > target/cargo-metadata.json
31
- - name : Build tests and save binaries metadata
32
- run : |
33
- cargo nextest list --list-type binaries-only \
34
- --message-format json > target/binaries-metadata.json
35
- - name : Archive target directory
36
- run : tar -czf build-artifacts.tar.gz target
34
+ - name : Build and archive tests
35
+ run : cargo nextest archive --archive-file nextest-archive.tar.zst
37
36
- name : Upload archive to workflow
38
37
uses : actions/upload-artifact@v3
39
38
with :
40
- name : build-artifacts
41
- path : build-artifacts .tar.gz
39
+ name : nextest-archive
40
+ path : nextest-archive .tar.zst
42
41
43
42
run-tests-partitioned :
44
43
name : Run tests with partitioning
63
62
- name : Download archive
64
63
uses : actions/download-artifact@v3
65
64
with :
66
- name : build-artifacts
67
- # This example extracts artifacts to "build-artifacts/target" to demonstrate target-dir remapping.
68
- - name : Extract artifacts
69
- run : tar -xf build-artifacts.tar.gz --one-top-level=build-artifacts
65
+ name : nextest-archive
70
66
- name : Run tests
71
67
run : |
72
- ~/.cargo/bin/cargo-nextest nextest run --cargo-metadata build-artifacts/target/cargo-metadata.json \
73
- --binaries-metadata build-artifacts/target/binaries-metadata.json \
74
- --target-dir-remap build-artifacts/target \
68
+ ~/.cargo/bin/cargo-nextest nextest run --archive-file nextest-archive.tar.zst \
75
69
--partition count:${{ matrix.partition }}/2
0 commit comments