Skip to content

Commit ed80f05

Browse files
committed
feat: add proper rust caching to github workflows and ensure cargo audit is installed in rust security nox session
1 parent ee1955a commit ed80f05

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

{{cookiecutter.project_name}}/.github/workflows/build-rust.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ jobs:
5454
with:
5555
targets: {{ "${{ matrix.platform.target }}" }}
5656

57+
- name: Cache Rust dependencies
58+
uses: Swatinem/rust-cache@v2
59+
with:
60+
workdir: rust/
61+
key: {{ "${{ matrix.platform.target }}" }}
62+
5763
- name: Set up cross-compilation toolchain (Linux)
5864
if: contains(matrix.platform.target, 'linux')
5965
run: |

{{cookiecutter.project_name}}/.github/workflows/lint-rust.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ jobs:
3333
with:
3434
components: "rustfmt,clippy"
3535

36+
- name: Cache Rust dependencies
37+
uses: Swatinem/rust-cache@v2
38+
with:
39+
workdir: rust/
40+
3641
- name: Set up uv
3742
uses: astral-sh/setup-uv@v6
3843

{{cookiecutter.project_name}}/.github/workflows/test-rust.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737
- name: Set up Rust
3838
run: rustup show
3939

40+
- name: Cache Rust dependencies
41+
uses: Swatinem/rust-cache@v2
42+
with:
43+
workdir: rust/
44+
4045
- name: Set up uv
4146
uses: astral-sh/setup-uv@v6
4247

{{cookiecutter.project_name}}/noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ def security_python(session: Session) -> None:
148148
@nox.session(python=False, name="security-rust", tags=[SECURITY, RUST])
149149
def security_rust(session: Session) -> None:
150150
"""Run code security checks (cargo audit)."""
151-
session.log("Installing security dependencies...")
152-
session.run("cargo", "install", "cargo-audit", external=True)
151+
session.log("Ensuring cargo-audit is available...")
152+
session.run("cargo", "install", "cargo-audit", "--locked", external=True)
153153
session.run("cargo", "audit", "--all", external=True)
154154

155155

0 commit comments

Comments
 (0)