Skip to content

Commit e8db4ac

Browse files
committed
ci: unit testing workflows
1 parent 2a66704 commit e8db4ac

4 files changed

Lines changed: 267 additions & 22 deletions

File tree

‎.config/nextest.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[profile.ci]
2+
fail-fast = false

‎.github/workflows/ci.yaml‎

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,139 @@ jobs:
4242
uses: bitshift-systems/.github/actions/setup-repo@50b88cc93d8640157770512ec9e11750d6c06a31 # setup-repo-v2.2.0
4343
with:
4444
cache-key: audit
45+
install-args: rust aqua:EmbarkStudios/cargo-deny hk
4546

4647
- name: Run Audit
4748
run: mise run audit
4849

50+
rust-lint:
51+
if: >-
52+
${{ !(startsWith(github.head_ref, 'release-please--')
53+
&& github.event.pull_request.head.repo.full_name == github.repository) }}
54+
name: Rust Lint
55+
runs-on: ubuntu-26.04
56+
permissions:
57+
contents: read
58+
timeout-minutes: 10
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
62+
with:
63+
persist-credentials: false
64+
65+
- name: Setup Repo
66+
uses: bitshift-systems/.github/actions/setup-repo@50b88cc93d8640157770512ec9e11750d6c06a31 # setup-repo-v2.2.0
67+
with:
68+
cache-key: lint
69+
70+
- name: Install Rust components
71+
run: mise run rust-components
72+
73+
- name: Check formatting
74+
run: mise run fmt-check
75+
76+
- name: Run linter
77+
run: mise run clippy
78+
79+
- name: Run doctests
80+
run: cargo test --doc --workspace --all-features --locked
81+
82+
rust-build:
83+
if: >-
84+
${{ !(startsWith(github.head_ref, 'release-please--')
85+
&& github.event.pull_request.head.repo.full_name == github.repository) }}
86+
name: Rust Build
87+
runs-on: ubuntu-26.04
88+
permissions:
89+
contents: read
90+
timeout-minutes: 10
91+
steps:
92+
- name: Checkout
93+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
94+
with:
95+
persist-credentials: false
96+
97+
- name: Setup Repo
98+
uses: bitshift-systems/.github/actions/setup-repo@50b88cc93d8640157770512ec9e11750d6c06a31 # setup-repo-v2.2.0
99+
with:
100+
cache-key: build
101+
install-args: rust aqua:nextest-rs/nextest/cargo-nextest hk
102+
103+
- name: Build and archive tests
104+
run: mise run test-archive
105+
106+
- name: Upload workspace tests
107+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
108+
with:
109+
name: nextest-workspace
110+
path: target/nextest/workspace.tar.zst
111+
retention-days: 1
112+
compression-level: 0
113+
114+
rust-test:
115+
if: >-
116+
${{ !(startsWith(github.head_ref, 'release-please--')
117+
&& github.event.pull_request.head.repo.full_name == github.repository) }}
118+
name: Rust Test
119+
needs:
120+
- rust-build
121+
runs-on: ubuntu-26.04
122+
permissions:
123+
contents: read
124+
timeout-minutes: 10
125+
steps:
126+
- name: Checkout
127+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
128+
with:
129+
persist-credentials: false
130+
131+
- name: Setup Repo
132+
uses: bitshift-systems/.github/actions/setup-repo@50b88cc93d8640157770512ec9e11750d6c06a31 # setup-repo-v2.2.0
133+
with:
134+
cache-key: build
135+
install-args: aqua:nextest-rs/nextest/cargo-nextest hk
136+
137+
- name: Download tests
138+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
139+
with:
140+
name: nextest-workspace
141+
path: target/nextest
142+
143+
- name: Run unit tests
144+
run: mise run test-from-archive
145+
146+
integration-test:
147+
if: >-
148+
${{ !(startsWith(github.head_ref, 'release-please--')
149+
&& github.event.pull_request.head.repo.full_name == github.repository) }}
150+
name: Integration Test
151+
needs:
152+
- rust-build
153+
runs-on: ubuntu-26.04
154+
permissions:
155+
contents: read
156+
timeout-minutes: 10
157+
steps:
158+
- name: Checkout
159+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
160+
with:
161+
persist-credentials: false
162+
163+
- name: Setup Repo
164+
uses: bitshift-systems/.github/actions/setup-repo@50b88cc93d8640157770512ec9e11750d6c06a31 # setup-repo-v2.2.0
165+
with:
166+
cache-key: build
167+
install-args: aqua:nextest-rs/nextest/cargo-nextest hk
168+
169+
- name: Download tests
170+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
171+
with:
172+
name: nextest-workspace
173+
path: target/nextest
174+
175+
- name: Run unit tests
176+
run: mise run test-int-from-archive
177+
49178
workflow-lint:
50179
if: >-
51180
${{ !(startsWith(github.head_ref, 'release-please--')
@@ -69,6 +198,9 @@ jobs:
69198
name: Build Success
70199
needs:
71200
- cargo-audit
201+
- rust-lint
202+
- rust-test
203+
- integration-test
72204
- workflow-lint
73205
runs-on: ubuntu-26.04
74206
timeout-minutes: 10

‎.mise/config.toml‎

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,79 @@
22
rust = "1.99.1"
33
hk = { version = "2.11.0", workflow = "release.yml" }
44
oxfmt = "0.75.0"
5-
jactionlint = { version = "2.4.0", workflow = "release.yaml" }
5+
jactionlint = "2.4.0"
66
shellcheck = "0.11.0"
77

88
"aqua:EmbarkStudios/cargo-deny" = "0.20.2"
99
"aqua:nextest-rs/nextest/cargo-nextest" = "0.9.146"
10+
"packslip:jdx/jactionlint" = "2.4.0"
1011

1112
[hooks]
1213
postinstall = "hk install --mise"
1314

15+
[tasks.rust-components]
16+
description = "Install Rust components required by project tasks"
17+
run = "rustup component add rustfmt clippy"
18+
19+
[tasks.build]
20+
description = "Compile the whole workspace (debug, locked deps)"
21+
run = "cargo build --workspace --locked"
22+
23+
[tasks.build-release]
24+
description = "Compile the release binaries we ship (server, cli)"
25+
run = "cargo build --release --locked -p casrs-server -p casrs-cli"
26+
1427
[tasks.audit]
1528
description = "Supply-chain + license audit"
1629
run = "cargo deny check"
30+
31+
[tasks.test]
32+
description = "Hermetic test suite: unit + serde + validation; also compile-checks feature-gated targets"
33+
run = "cargo nextest run --workspace --locked"
34+
35+
[tasks.test-archive]
36+
description = "Build the workspace ONCE (--all-features) and pack its tests into nextest archives under target/nextest/ (what CI's test jobs and e2e shards run)"
37+
run = '''
38+
set -eu
39+
mkdir -p target/nextest
40+
cargo nextest archive --workspace --all-features --locked --archive-file target/nextest/workspace.tar.zst
41+
'''
42+
43+
[tasks.test-from-archive]
44+
description = "Run the hermetic suite from the archive `test-archive` built (no compile, no doctests)"
45+
run = '''
46+
cargo-nextest nextest run --profile ci --workspace-remap . \
47+
--archive-file target/nextest/workspace.tar.zst \
48+
--no-tests pass \
49+
-E 'not binary(/^integration/)'
50+
'''
51+
52+
[tasks.test-int-from-archive]
53+
description = "Run the integration tests from the archive `test-archive` built"
54+
run = '''
55+
cargo-nextest nextest run --profile ci --workspace-remap . \
56+
--archive-file target/nextest/workspace.tar.zst \
57+
--no-tests pass \
58+
--run-ignored all -E 'binary(/^integration/)'
59+
'''
60+
61+
[tasks.clippy]
62+
description = "Clippy across the workspace incl. feature-gated targets, warnings are errors"
63+
run = "cargo clippy --workspace --all-targets --all-features --locked -- -D warnings"
64+
65+
[tasks.fmt]
66+
description = "Format the workspace in place"
67+
run = "cargo fmt --all"
68+
69+
[tasks.fmt-check]
70+
description = "Verify formatting without changing files (CI gate)"
71+
run = "cargo fmt --all -- --check"
72+
73+
[tasks.ci]
74+
description = "The full local gate: the hermetic Rust suite"
75+
depends = [
76+
"fmt-check",
77+
"clippy",
78+
"build",
79+
"test",
80+
]

0 commit comments

Comments
 (0)