Skip to content

Commit 8d16a59

Browse files
authored
ci(branch-checks): run Rust checks in Nix shells (#2876)
* ci(branch-checks): run Rust checks in Nix shells Signed-off-by: Simon Scatton <sscatton@nvidia.com> * ci(branch-checks): run Rust tests with nextest Signed-off-by: Simon Scatton <sscatton@nvidia.com> * ci(branch-checks): cache Rust workspace artifacts Signed-off-by: Simon Scatton <sscatton@nvidia.com> * ci(branch-checks): run cargo-deny in Nix shell Signed-off-by: Simon Scatton <sscatton@nvidia.com> --------- Signed-off-by: Simon Scatton <sscatton@nvidia.com>
1 parent 8be8b62 commit 8d16a59

3 files changed

Lines changed: 60 additions & 91 deletions

File tree

.config/nextest.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
[profile.ci]
5+
fail-fast = false
6+
status-level = "fail"
7+
final-status-level = "fail"
8+
failure-output = "immediate-final"

.github/workflows/branch-checks.yml

Lines changed: 50 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -84,129 +84,88 @@ jobs:
8484
needs: pr_metadata
8585
if: needs.pr_metadata.outputs.should_run == 'true'
8686
runs-on: linux-amd64-cpu8
87-
container:
88-
image: ghcr.io/nvidia/openshell/ci:latest
89-
credentials:
90-
username: ${{ github.actor }}
91-
password: ${{ secrets.GITHUB_TOKEN }}
87+
defaults:
88+
run:
89+
shell: nix develop .#devShells.x86_64-linux.default -c bash -euo pipefail {0}
9290
steps:
9391
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
9492

95-
- name: Install tools
96-
run: mise install --locked
93+
- uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31.11.1
94+
with:
95+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
96+
97+
- uses: cachix/cachix-action@5f2d7c5294214f71b873db4b969586b980625e71 # v17
98+
with:
99+
name: openshell
100+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
97101

98102
- name: Check dependencies
99-
run: mise run rust:deny:policy
103+
run: cargo deny check licenses bans sources
100104

101105
rust:
102-
name: Rust (${{ matrix.runner }})
106+
name: Rust (${{ matrix.system }})
103107
needs: pr_metadata
104108
if: needs.pr_metadata.outputs.should_run == 'true'
105109
strategy:
106110
fail-fast: false
107111
matrix:
108-
runner: [linux-amd64-cpu8, linux-arm64-cpu8]
112+
include:
113+
- runner: linux-amd64-cpu8
114+
system: x86_64-linux
115+
- runner: linux-arm64-cpu8
116+
system: aarch64-linux
117+
- runner: macos-15-xlarge
118+
system: aarch64-darwin
109119
runs-on: ${{ matrix.runner }}
110-
env:
111-
SCCACHE_GHA_ENABLED: "true"
112-
SCCACHE_GHA_VERSION: branch-checks-rust-${{ matrix.runner }}
113-
container:
114-
image: ghcr.io/nvidia/openshell/ci:latest
115-
credentials:
116-
username: ${{ github.actor }}
117-
password: ${{ secrets.GITHUB_TOKEN }}
120+
defaults:
121+
run:
122+
shell: nix develop .#devShells.${{ matrix.system }}.default -c bash -euo pipefail {0}
118123
steps:
119124
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
120125

121-
- name: Configure GHA sccache backend
122-
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
126+
- uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31.11.1
127+
with:
128+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
123129

124-
- name: Install tools
125-
run: mise install --locked
130+
- uses: cachix/cachix-action@5f2d7c5294214f71b873db4b969586b980625e71 # v17
131+
with:
132+
name: openshell
133+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
134+
135+
- name: Realize Nix development shell
136+
shell: bash
137+
run: nix build --no-link ".#devShells.${{ matrix.system }}.default"
126138

127139
- name: Cache Rust target and registry
128140
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
129141
with:
130-
# Keep branch-check caches partitioned by runner architecture; lint
142+
# Keep branch-check caches partitioned by target system; lint
131143
# and test intentionally share the same job-local target directory.
132-
shared-key: rust-checks-${{ matrix.runner }}
144+
shared-key: rust-checks-${{ matrix.system }}
133145
# Preserve compiled artifacts from failed lint/test runs so the next
134146
# push to the same PR branch does not start from a cold cache.
135147
cache-on-failure: "true"
148+
cache-workspace-crates: "true"
149+
cache-bin: "false"
150+
cmd-format: nix develop .#devShells.${{ matrix.system }}.default -c {0}
136151

137152
- name: Format
138-
run: mise run rust:format:check
139-
140-
- name: Lint
141-
run: mise run rust:lint
142-
143-
- name: Test
144-
run: mise run test:rust
145-
146-
- name: Verify telemetry can be compiled out
147-
run: mise run rust:verify:telemetry-off
148-
149-
- name: Verify system CA roots build mode compiles and excludes bundled Mozilla roots
150-
run: mise run rust:verify:system-ca-roots
151-
152-
- name: sccache stats
153-
if: always()
154-
run: |
155-
set +e
156-
stats_bin="${SCCACHE_PATH:-sccache}"
157-
"$stats_bin" --show-stats
158-
status=$?
159-
if [ "$status" -ne 0 ]; then
160-
echo "::warning::sccache stats unavailable (exit $status)"
161-
fi
162-
exit 0
163-
164-
rust-macos:
165-
name: Rust lint (macOS)
166-
needs: pr_metadata
167-
if: needs.pr_metadata.outputs.should_run == 'true'
168-
runs-on: macos-latest
169-
timeout-minutes: 20
170-
steps:
171-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
172-
173-
- name: Install mise
174153
run: |
175-
curl --proto '=https' --tlsv1.2 -sSf https://mise.run | MISE_VERSION=v2026.4.25 sh
176-
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
177-
echo "$HOME/.local/share/mise/shims" >> "$GITHUB_PATH"
178-
179-
- name: Configure GHA sccache backend
180-
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
154+
cargo fmt --all -- --check
155+
cargo fmt --manifest-path e2e/rust/Cargo.toml --all -- --check
156+
cargo fmt --manifest-path examples/governance-interceptor/Cargo.toml --all -- --check
181157
182-
- name: Install Rust and Clippy
158+
- name: Lint
183159
run: |
184-
mise install --locked rust
185-
rustup component add clippy
160+
cargo clippy --workspace --all-targets -- -D warnings
161+
cargo clippy --manifest-path e2e/rust/Cargo.toml --all-targets -- -D warnings
162+
cargo check --manifest-path examples/governance-interceptor/Cargo.toml --all-targets
186163
187-
- name: Cache Rust target and registry
188-
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
189-
with:
190-
shared-key: rust-clippy-macos
191-
cache-on-failure: "true"
192-
193-
- name: Lint macOS-sensitive crates
194-
# Formatting is target-independent and already checked by the Linux jobs.
195-
# The full mise lint covers every workspace/E2E target and requires extra
196-
# native dependencies such as Z3; keep this guard focused on macOS cfgs.
164+
- name: Test
165+
env:
166+
OPENSHELL_TELEMETRY_ENABLED: "false"
197167
run: |
198-
cargo clippy \
199-
-p openshell-sandbox \
200-
-p openshell-core \
201-
-p openshell-cli \
202-
-p openshell-driver-db-credstore \
203-
-p openshell-driver-docker \
204-
-p openshell-driver-kubernetes \
205-
-p openshell-driver-kubernetes-secrets \
206-
-p openshell-driver-podman \
207-
-p openshell-driver-vault \
208-
--all-targets \
209-
-- -D warnings
168+
cargo nextest run --profile ci --workspace --features openshell-server/test-support
210169
211170
python:
212171
name: Python (${{ matrix.runner }})

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
};
4747
testGuestPkgs = import nixpkgs-test-guest { inherit system; };
4848
commonDevShellPackages = with pkgs; [
49+
cargo-deny
50+
cargo-nextest
4951
# Assemble Debian artifacts on macOS and Linux.
5052
dpkg
5153
# Required to find packages.

0 commit comments

Comments
 (0)