ci: Use lockfile as cache key

This ensures we don't keep stale builds of dependencies around.
This commit is contained in:
Dagur Valberg Johannsson 2026-02-02 11:52:09 +01:00
parent 2301b45887
commit 0388aa282e
No known key found for this signature in database
GPG key ID: FD701804AEE88107

View file

@ -1,13 +1,22 @@
variables:
CARGO_HOME: $CI_PROJECT_DIR/cargo
cache:
paths:
- $CARGO_HOME
- target/
# Default cache for Rust jobs - keyed on Cargo.lock to prune stale dependencies
.rust_cache: &rust_cache
cache:
key:
files:
- Cargo.lock
paths:
- $CARGO_HOME/bin/
- $CARGO_HOME/registry/index/
- $CARGO_HOME/registry/cache/
- $CARGO_HOME/git/db/
- target/
build-release:
image: rust:latest
<<: *rust_cache
script:
- cargo build --verbose --release
artifacts:
@ -17,17 +26,20 @@ build-release:
test:
image: rust:latest
<<: *rust_cache
script:
- cargo test --verbose --release
format_check:
image: rust:latest
<<: *rust_cache
script:
- rustup component add rustfmt
- cargo fmt -- --check
clippy:
image: rust:latest
<<: *rust_cache
script:
- rustup component add clippy
- cargo clippy -- -D warnings