Conversation
There was a problem hiding this comment.
@GnaneshGnani
Do we want to update Cargo.lock autonomously in CI or is this just to catch devs forgetting to commit Cargo.lock?
cargo generate-lockfileresolves all deps to their latest compatible versions from crates.io. This will cause spurious CI failures whenever any transitive dep publishes a new compatible release, even with no code changes.
(from Claude)
|
@milindsrivastava1997, The goal is to catch
|
|
@GnaneshGnani Seems like |
|
@milindsrivastava1997, its a better option. We can add |
|
Great let's do that please. Thanks |
milindsrivastava1997
left a comment
There was a problem hiding this comment.
Please use --locked in existing cargo commands and remove cargo generate-lockfile
|
@milindsrivastava1997 , seems like adding --locked will fail because of git dependencies |
|
@GnaneshGnani Got it. Can you do a bit of research and suggest a few different options with tradeoffs? |
Solution 1: Generate Lockfile and Auto-CommitRun cargo generate-lockfile in CI. If Cargo.lock changed, commit and push it back to the branch. Pros:
Cons:
Solution 2: Pin Git DependenciesAdd rev = "commit-hash" to git dependencies in Cargo.toml. Pros:
Cons:
Solution 3: Publish Internal Crates to RegistryPublish dsrs and sketchlib-rust to crates.io or a private registry (e.g. GitHub Packages). Use versioned dependencies instead of git. Pros:
Cons:
Solution 4: Git Submodules + Path DependenciesAdd datasketches-rs and sketchlib-rust as git submodules. Switch to path dependencies in Cargo.toml. Pros:
Cons:
Solution 5: cargo generate-lockfile + DiffCopy Cargo.lock, run cargo generate-lockfile, diff against the copy, fail if different. Pros:
Cons:
@milindsrivastava1997 pls check these solutions. Solution 2 seems good for me |
|
Solution 3 might also work. ASAPQuery's CI already has the capability to push packages to ProjectASAP's ghcr, based on tags. |
So it seems Option 2: use --locked in CI, but only after pinning the git dependencies with rev = .... is better? Best path here seems to be: keep the cache-key improvement, remove cargo generate-lockfile validation, pin git dependencies with rev = ..., and then enforce --locked on the existing cargo commands. cargo generate-lockfile can rebuild to newer compatible versions and cause unrelated CI failures, while --locked gives the behavior we actually want once git deps are pinned. Regarding what if the rev = ... changes:
|
|
My only concern is remembering to update the git revs, but maybe that's a problem for later. |
|
@milindsrivastava1997, please review the changes. Pinned the git dependencies |
Rust CI
Summary
Enhances the Rust CI workflow with lockfile validation and improved caching to ensure consistent builds and catch dependency drift early.
Changes
.github/workflows/rust.ymlLockfile Validation: Added validation step in both
format-and-lintandtestjobsCache Key Improvement: Updated cargo cache key to include
**/Cargo.toml${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}Benefits
Testing