Skip to content

ci: add cargo caching to pre-commit workflow #2351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

devin-ai-integration[bot]
Copy link
Contributor

Add Rust caching to pre-commit workflow

This PR adds caching for Rust dependencies and build artifacts to speed up pre-commit CI checks. The cache:

  • Stores cargo registry, git cache, and target directories
  • Uses a cache key based on:
    • OS
    • Cargo.lock files
    • pre-commit config
    • Rust toolchain versions
  • Includes fallback cache keys for partial matches

Link to Devin run: https://app.devin.ai/sessions/659feaadc2d24d07854347f7ab39d3d5
Requested by: Jayant

Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link

vercel bot commented Feb 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 7:04pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 7:04pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 7:04pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
component-library ⬜️ Ignored (Inspect) Visit Preview Feb 7, 2025 7:04pm
entropy-debugger ⬜️ Ignored (Inspect) Visit Preview Feb 7, 2025 7:04pm
insights ⬜️ Ignored (Inspect) Visit Preview Feb 7, 2025 7:04pm

Copy link
Collaborator

@cprussin cprussin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth using something like https://github.com/Swatinem/rust-cache which may be able to do more sophisticated caching for us without us having to manage it?

~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('.pre-commit-config.yaml') }}-1.82.0-1.73.0-1.66.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any risk if we bump versions of stuff and forget to update here?

- Replace manual cargo caching with Swatinem/rust-cache
- Eliminates version management risk
- Provides more sophisticated caching behavior

Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz>
Copy link
Contributor Author

Switching to rust-cache action as suggested. This:

  • Provides more sophisticated caching without manual management
  • Automatically handles multiple toolchain versions (1.82.0, 1.73.0, 1.66.1)
  • Eliminates the risk of forgetting to update version numbers
  • Optimizes cache storage and cleanup

The action automatically uses rustc version and Cargo.lock/Cargo.toml hashes for cache keys, so we don't need to manually maintain version numbers in the cache key.

@jayantk jayantk merged commit 07f289d into main Feb 7, 2025
8 checks passed
@jayantk jayantk deleted the devin/1738953647-add-rust-cache-to-precommit branch February 7, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants