Skip to content

chore: Scope cirrus caches by branch, with fallback to main#24372

Merged
Gudahtt merged 3 commits intomainfrom
cirrus-branch-scoped-caches
Jan 16, 2026
Merged

chore: Scope cirrus caches by branch, with fallback to main#24372
Gudahtt merged 3 commits intomainfrom
cirrus-branch-scoped-caches

Conversation

@Gudahtt
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt commented Jan 9, 2026

Description

The cirruslabs/cache action we use is identical to actions/cache in most ways, except that it is not scoped by branch. actions/cache is scoped by branch with a fallback to main, but cirruslabs/cache uses "global" caches (by repository).

This means that the cache can get corrupted on a branch by accident fairly easily, e.g. if the data being cached is changed in a way not reflected by the cache key.

I believe this has led to cache corruption in the past (we had a few incidents where we never found the cause, but where this is a plausible explanation).

Our workflows have been updated to make our usage of cirruslabs/cache work like actions/cache does. It scopes caches by branch, first attempting to restore from the branch cache. If there is no hit, it tries to restore from the main cache but doesn't update it at the end of the workflow in the fallback case.

This ensures that any "cache corruption" is limited in scope just to a single branch, unless it gets merged to main. At least if it's merged to main we'll have an easier time finding and understanding the problem.

Changelog

CHANGELOG entry: null

Related issues

N/A

Manual testing steps

N/A

Screenshots/Recordings

N/A

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Aligns cirrus cache behavior with actions/cache to reduce cross-branch cache contamination and speed CI.

  • Branch-scoped cache keys for Android APKs, Gradle, iOS Xcode derived data, and iOS .app using github.ref_name
  • Adds fallback restore from main caches (read-only) when branch cache miss occurs
  • Updates build conditions to run only on double-miss and repack when either cache hits
  • Removes redundant post-build artifact caching steps

Written by Cursor Bugbot for commit 15e3beb. This will update automatically on new commits. Configure here.

@Gudahtt Gudahtt force-pushed the cirrus-branch-scoped-caches branch from efe1848 to f4b10f3 Compare January 9, 2026 17:36
@metamaskbot metamaskbot added the team-core-platform Core Platform team label Jan 9, 2026
@github-actions github-actions bot added the size-M label Jan 9, 2026
MM_INFURA_PROJECT_ID: ${{ secrets.MM_INFURA_PROJECT_ID }}

# Cache build artifacts with the pre-build fingerprint
- name: Cache build artifacts
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This step was redundant because the cache is already getting updated by the cirruslabs/cache step above, which has an identical path and key.

cirruslabs/cache restores when it's first run, than saves at the end of the workflow automatically.

@Gudahtt Gudahtt force-pushed the cirrus-branch-scoped-caches branch 3 times, most recently from 13f46f2 to 0a91a1f Compare January 13, 2026 15:52
@Gudahtt Gudahtt marked this pull request as ready for review January 13, 2026 16:56
@Gudahtt Gudahtt requested a review from a team as a code owner January 13, 2026 16:56
@Gudahtt Gudahtt added team-core-platform Core Platform team and removed team-core-platform Core Platform team labels Jan 13, 2026
@Qbandev Qbandev requested a review from Copilot January 14, 2026 10:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates GitHub Actions workflows to implement branch-scoped caching with a fallback to main, addressing potential cache corruption issues from the cirruslabs/cache action's global cache behavior.

Changes:

  • Modified cache keys to include github.ref_name for branch-specific scoping
  • Added separate restore steps for main branch fallback using cirruslabs/cache/restore
  • Updated build and repack conditions to check both branch and main cache hits

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/build-ios-e2e.yml Implements branch-scoped caching for Xcode derived data and iOS app builds with main fallback
.github/workflows/build-android-e2e.yml Implements branch-scoped caching for APKs and Gradle dependencies with main fallback

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Qbandev
Qbandev previously approved these changes Jan 14, 2026
Copy link
Copy Markdown
Contributor

@Qbandev Qbandev left a comment

Choose a reason for hiding this comment

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

LTGM! The Copilot naming comments seem valid.

@Gudahtt Gudahtt enabled auto-merge January 15, 2026 16:56
@Gudahtt Gudahtt added the skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run label Jan 15, 2026
@Gudahtt Gudahtt force-pushed the cirrus-branch-scoped-caches branch from 890381f to 3b15dfc Compare January 15, 2026 17:35
Gudahtt and others added 3 commits January 15, 2026 14:30
The `cirruslabs/cache` action we use is identical to `actions/cache` in
most ways, except that it is not scoped by branch. `actions/cache` is
scoped by branch with a fallback to `main`, but `cirruslabs/cache` uses
"global" caches (by repository).

This means that the cache can get corrupted on a branch by accident
fairly easily, e.g. if the data being cached is changed in a way not
reflected by the cache key.

I believe this has led to cache corruption in the past (we had a few
incidents where we never found the cause, but where this is a plausible
explanation).

Our workflows have been updated to make our usage of `cirruslabs/cache`
work like `actions/cache` does. It scopes caches by branch, first
attmepting to restore from the branch cache. If there is no hit, it
tries to restore from the `main` cache but doesn't update it at the end
of the workflow in the fallback case.

This ensures that any "cache corruption" is limited in scope just to a
single branch, unless it gets merged to `main`. At least if it's merged
to `main` we'll have an easier time finding and understanding the
problem.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Gudahtt Gudahtt force-pushed the cirrus-branch-scoped-caches branch from 3b15dfc to 15e3beb Compare January 15, 2026 18:00
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found

All E2E tests pre-selected.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@tommasini
Copy link
Copy Markdown
Contributor

Curious question, if cirrus cache now is pretty the same as action cache, what is the advantage to use cirrus cache?

@Gudahtt Gudahtt added this pull request to the merge queue Jan 16, 2026
Merged via the queue into main with commit 527eda7 Jan 16, 2026
97 checks passed
@Gudahtt Gudahtt deleted the cirrus-branch-scoped-caches branch January 16, 2026 12:21
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
@metamaskbot metamaskbot added the release-7.63.0 Issue or pull request that will be included in release 7.63.0 label Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.63.0 Issue or pull request that will be included in release 7.63.0 size-M skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants