Skip to content

chore: improve CI caching#1822

Merged
igamigo merged 30 commits intonextfrom
tomasarrachea-ci-cache
Mar 3, 2026
Merged

chore: improve CI caching#1822
igamigo merged 30 commits intonextfrom
tomasarrachea-ci-cache

Conversation

@TomasArrachea
Copy link
Copy Markdown
Collaborator

@TomasArrachea TomasArrachea commented Feb 23, 2026

This PR introduces:

  1. Separate Swatinem cache keys by build profile: rust-release, rust-debug, rust-wasm, rust-nightly-release. Previously all jobs shared rust-build, causing collisions
  2. Binary caches for node-builder and note-transport: Small cache entries (~15 MB) keyed on Cargo.lock hash, so these survive Swatinem cache eviction. Scripts skip the build when the cached binary exists.

So for a single push to next, the resulting Rust cache entries would be:

  • Key: rust-release, size: 750 MB, used by: build, test, integration-tests, integration-tests-remote-prover
  • Key: rust-wasm, size: 490 MB, used by: build-wasm, clippy-wasm, wasm-bindgen-types, build-web-client
  • Binary: node-builder, size: 15 MB, used by: integration-tests, integration-tests-web-client, integration-tests-remote-prover
  • Binary: note-transport, size: 4 MB, used by: integration-tests
  • Binary remote-prover, size: 16 MB, used by integration-tests-remote-prover-web-client
  • Total Size: ~1.2 GB

@TomasArrachea TomasArrachea added no changelog This PR does not require an entry in the `CHANGELOG.md` file ci Related to the CI pipeline maintainer PRs that come from internal contributors or integration partners. They should be given priority. labels Feb 24, 2026
@TomasArrachea TomasArrachea changed the title feat: improve CI caching chore: improve CI caching Feb 24, 2026
@TomasArrachea TomasArrachea marked this pull request as ready for review February 24, 2026 18:50
Copy link
Copy Markdown
Collaborator

@SantiagoPittella SantiagoPittella left a comment

Choose a reason for hiding this comment

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

Can we do the same that we did with the node for the remote prover? it takes a couple minutes to compile it

Copy link
Copy Markdown
Contributor

@lima-limon-inc lima-limon-inc left a comment

Choose a reason for hiding this comment

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

LGTM ^_^

Comment thread .github/workflows/lint.yml Outdated
Comment thread .github/workflows/test.yml Outdated
- name: Build note-transport
if: steps.cache-note-transport.outputs.cache-hit != 'true'
run: |
git clone --depth=1 -b main https://github.com/0xMiden/miden-note-transport .tmp/miden-note-transport
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I'm not mistaken, temporary directories are created with the runner.temp variable, something like so:

Suggested change
git clone --depth=1 -b main https://github.com/0xMiden/miden-note-transport .tmp/miden-note-transport
git clone --depth=1 -b main https://github.com/0xMiden/miden-note-transport ${{ runner.temp }}/miden-note-transport

Here's the reference documentation where I got that from:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I simplified this to use cargo install --git instead of having a clone of the note-transport repo. I think it's cleaner this way and also we avoid the .tmp dir 8d0d217

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I simplified this to use cargo install --git instead of having a clone of the note-transport repo. I think it's cleaner this way and also we avoid the .tmp dir 8d0d217

Great idea! You cane even specify a specific directory to install the binaries in with cargo install --root <destination directory>. It doesn't seem necessary in this case, just thought I'd mention it.

Comment on lines -51 to -56
- name: Add Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: rust-build-wasm
prefix-key: ${{ env.RUST_CACHE_KEY }}
save-if: ${{ github.ref == 'refs/heads/next' }}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a benefit to keeping these but with save-if: false?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, save-if: false means the job still restores from the cache saved by the build job (which runs with save-if: ${{ github.ref == 'refs/heads/next' }}) but avoids redundant saves that waste time and could evict the canonical cache entry.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The rust-wasm cache entry gets written by the Build Web Client job, that compiles the wasm client with a different set of Rust flags and features (defined in the rolup config file) as the make build-wasm command. So IIUC that requires a recompilation anyway.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The same applies to the other cases, for the cache to make sense the jobs have to compile the Rust code with the same profile.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we look into standardizing those flags so that we can reuse the cache? Probably not doable, but wonder if you looked into it.

Comment thread .github/workflows/test.yml
@igamigo igamigo merged commit e05086c into next Mar 3, 2026
34 checks passed
@igamigo igamigo deleted the tomasarrachea-ci-cache branch March 3, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Related to the CI pipeline maintainer PRs that come from internal contributors or integration partners. They should be given priority. no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants