11# Working example showing how to use nextest to reuse builds and partition test runs on GitHub Actions.
22# See workflow runs at https://github.com/nextest-rs/reuse-build-partition-example/actions/workflows/ci.yml.
33
4+ name : CI
5+
46on :
7+ pull_request :
8+ branches : [main]
59 push :
610 branches : [main]
711 schedule :
812 # Run this every day at 01:00 UTC.
913 - cron : 0 1 * * *
1014
15+ env :
16+ CARGO_TERM_COLOR : always
17+
1118jobs :
1219 build-test-artifacts :
1320 name : Build test artifacts
@@ -24,21 +31,13 @@ jobs:
2431 override : true
2532 - name : Install nextest
2633 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
3736 - name : Upload archive to workflow
3837 uses : actions/upload-artifact@v3
3938 with :
40- name : build-artifacts
41- path : build-artifacts .tar.gz
39+ name : nextest-archive
40+ path : nextest-archive .tar.zst
4241
4342 run-tests-partitioned :
4443 name : Run tests with partitioning
6362 - name : Download archive
6463 uses : actions/download-artifact@v3
6564 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
7066 - name : Run tests
7167 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 \
7569 --partition count:${{ matrix.partition }}/2
0 commit comments