Merge rust-bitcoin/rust-bitcoin#7075: ci: cache dependency build artifacts in the Test job
What changed, and why it matters
This commit only changes the project's GitHub Actions CI workflow to cache third-party dependency build artifacts during automated testing. It does not modify any library code, cryptographic logic, network handling, or user-facing behavior. There is no apparent security vulnerability introduced by this change.
No security action required. Review the pruning script for correctness and maintainability as a normal CI hygiene matter, but it does not pose a security risk.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds steps to .github/workflows/rust.yml that read the Rust compiler version, restore previously cached dependency artifacts before running tests, prune workspace-specific build artifacts after tests, and save the dependency cache on pushes to master. The cache key includes the runner OS, compiler version, dependency matrix value, and Cargo.lock hash. The pruning logic removes fingerprint and deps entries associated with workspace crates while keeping third-party dependency build outputs. This is a CI performance optimization with no direct security relevance.
Changed components
.github/workflows/rust.ymlInspect captured patch +40 / −0
### .github/workflows/rust.yml
@@ -28,8 +28,48 @@ jobs:
with:
persist-credentials: false
- uses: ./.github/actions/setup-rbmt
+ - name: "Read compiler version"
+ id: rustc
+ run: |
+ version=$(cargo rbmt toolchains --${{ matrix.toolchain }})
+ test -n "$version"
+ echo "version=$version" >> "$GITHUB_OUTPUT"
+ - name: "Restore dependency artifacts"
+ id: deps-cache
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: |
+ target
+ ~/.cargo/registry
+ key: test-deps-${{ runner.os }}-rustc-${{ steps.rustc.outputs.version }}-${{ matrix.dep }}-${{ hashFiles(format('Cargo-{0}.lock', matrix.dep)) }}
- name: "Run tests"
run: cargo rbmt test --toolchain ${{ matrix.toolchain }} --lock-file ${{ matrix.dep }}
+ - name: "Prune workspace artifacts"
+ id: prune
+ if: github.event_name == 'push' && steps.deps-cache.outputs.cache-hit != 'true'
+ continue-on-error: true
+ run: |
+ target=$(cargo metadata --format-version 1 --no-deps | jq -r .target_directory)
+ for profile in "$target"/*/ "$target"/*/*/; do
+ [ -d "$profile.fingerprint" ] || continue
+ for dep_info in "$profile"deps/*.d; do
+ grep -qs '^[^/#]' "$dep_info" || continue
+ hash=${dep_info%.d}
+ hash=${hash##*-}
+ rm -rf "$profile".fingerprint/*-"$hash" "$profile"deps/*-"$hash" "$profile"deps/*-"$hash".*
+ done
+ find "$profile" -maxdepth 1 -type f ! -name .cargo-lock -delete
+ rm -rf "$profile"examples "$profile"incremental
+ done
+ du -sh "$target" ~/.cargo/registry
+ - name: "Save dependency artifacts"
+ if: github.event_name == 'push' && steps.deps-cache.outputs.cache-hit != 'true' && steps.prune.outcome == 'success'
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: |
+ target
+ ~/.cargo/registry
+ key: ${{ steps.deps-cache.outputs.cache-primary-key }}
Check:
runs-on: ubuntu-24.04Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.