Fix Cargo cache key to include source checksum (v4)#1930
Fix Cargo cache key to include source checksum (v4)#1930rileyseaburg merged 1 commit intoproductionfrom
Conversation
The cache key now includes both Cargo.lock AND template_renderer.rs checksums. This ensures source code changes trigger a rebuild, not just dependency changes. Previous cache keys only used Cargo.lock which didn't change when the Rust source code was modified.
There was a problem hiding this comment.
Pull request overview
This PR addresses a caching issue in CircleCI where Rust source code changes weren't triggering rebuilds. The cache key previously only included Cargo.lock, causing the CI to use stale compiled libraries when source files changed. The solution adds template_renderer.rs checksum to the cache key and bumps the cache version from v3 to v4.
Key Changes:
- Added
template_renderer.rschecksum to the Cargo cache key - Bumped cache version from v3 to v4 to force fresh builds
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| keys: | ||
| - v3-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }} | ||
| - v3-cargo- | ||
| - v4-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }}-{{ checksum "ext/widget_renderer/src/template_renderer.rs" }} |
There was a problem hiding this comment.
The cache key only includes the checksum of template_renderer.rs, but the Rust project has multiple source files (form_data.rs, lib.rs, and template_renderer.rs). Changes to form_data.rs or lib.rs would not invalidate the cache, potentially causing stale builds. Consider using a checksum of the entire src directory or all .rs files instead of just template_renderer.rs. CircleCI supports checksumming directories, e.g., checksum "ext/widget_renderer/src" which would hash all files in the directory.
| - v4-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }}-{{ checksum "ext/widget_renderer/src/template_renderer.rs" }} | |
| - v4-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }}-{{ checksum "ext/widget_renderer/src" }} |
| - ~/.cargo/registry | ||
| - ~/.cargo/git | ||
| key: v3-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }} | ||
| key: v4-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }}-{{ checksum "ext/widget_renderer/src/template_renderer.rs" }} |
There was a problem hiding this comment.
The cache key only includes the checksum of template_renderer.rs, but the Rust project has multiple source files (form_data.rs, lib.rs, and template_renderer.rs). Changes to form_data.rs or lib.rs would not invalidate the cache, potentially causing stale builds. Consider using a checksum of the entire src directory or all .rs files instead of just template_renderer.rs. CircleCI supports checksumming directories, e.g., checksum "ext/widget_renderer/src" which would hash all files in the directory.
Summary
Fix the CircleCI Cargo cache key to include source file checksum, ensuring Rust source changes trigger rebuilds.
Problem
The cache key only included
Cargo.lockchecksum. Whentemplate_renderer.rswas modified butCargo.lockdidn't change, CircleCI restored the cached (old) compiled library.Solution
Cache key now includes both:
Cargo.lockchecksum (dependency changes)template_renderer.rschecksum (source code changes)Also bumped version to v4 to guarantee a fresh build.