Skip to content
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

ci: reduce cache misses by forking main cache for each pull request #691

Merged
merged 4 commits into from
Jun 16, 2023

Conversation

Handfish
Copy link
Contributor

In the case where multiple developers are pushing branches simultaneously and running the ci/cd, the present action just checks package differences against the most recently built cache. With this change, pull_requests will have their own branch of cache.

By including GITHUB_REF in our key and restore-key, we can essentially create a forked cache from the latest main cache.

Information:
The cache action searches the restore-keys in sequential order. When a key doesn't match directly, the action searches for keys prefixed with the restore key. If there are multiple partial matches for a restore key, the action returns the most recently created cache.

@vercel
Copy link

vercel bot commented Apr 28, 2023

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

Name Status Preview Comments Updated (UTC)
mud ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2023 0:08am

restore-keys: |
${{ runner.os }}-turbo-${{ github.ref_name }}-
${{ runner.os }}-turbo-main
Copy link
Contributor Author

@Handfish Handfish Apr 28, 2023

Choose a reason for hiding this comment

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

In the case of branch of a branch, maybe removing ${{ runner.os }}-turbo-main- and just matching to the most recent ${{ runner.os }}-turbo- might be better, as the CI/CD is becoming very fast and likely the devs approving these ci/cd processes will be focusing on individual problems at a time.

@holic
Copy link
Member

holic commented May 10, 2023

I noticed that turbo supports env vars: https://turbo.build/repo/docs/core-concepts/caching#altering-caching-based-on-environment-variables

So another approach could be adding GITHUB_REF or GITHUB_REF_NAME to our turbo config?

@alvrs alvrs marked this pull request as ready for review June 16, 2023 10:49
@alvrs alvrs requested review from alvrs and holic as code owners June 16, 2023 10:49
@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2023

⚠️ No Changeset found

Latest commit: 9419d6e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member

@alvrs alvrs left a comment

Choose a reason for hiding this comment

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

lgtm!

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.

3 participants