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

chore: Prevent reusing Yarn cache across Yarn versions #21046

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Sep 26, 2023

Description

The Yarn cache will no longer be reused across Yarn versions in our CircleCI pipeline. This should prevent bugs in the event that the lockfile format changes again, or the checksum method used by Yarn.

We saw this problem when we upgraded from Yarn v3 to v4 on our main branch. We prepared a backport release that was still using v3, and it resulted in lockfile errors that we didn't catch until 2 releases later.

Manual testing steps

See that CI completes successfully using the correct cache key

Related issues

None

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained:
    • What problem this PR is solving.
    • How this problem was solved.
    • How reviewers can test my changes.
  • I’ve indicated what issue this PR is linked to: Fixes #???
  • I’ve included tests if applicable.
  • I’ve documented any added code.
  • I’ve applied the right labels on the PR (see labeling guidelines).
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

The Yarn cache will no longer be reused across Yarn versions in our
CircleCI pipeline. This should prevent bugs in the event that the
lockfile format changes again, or the checksum method used by Yarn.

We saw this problem when we upgraded from Yarn v3 to v4 on our main
branch. We prepared a backport release that was still using v3, and it
resulted in lockfile errors that we didn't catch until 2 releases
later.
@Gudahtt Gudahtt force-pushed the prevent-reusing-cache-across-yarn-versions branch from 91518bb to a80c3b1 Compare September 26, 2023 13:18
@Gudahtt Gudahtt marked this pull request as ready for review September 26, 2023 13:23
@Gudahtt Gudahtt requested review from kumavis, brad-decker and a team as code owners September 26, 2023 13:23
- run:
name: Save Yarn version
command: |
yarn --version > /tmp/YARN_VERSION
Copy link
Member Author

Choose a reason for hiding this comment

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

A file was used here rather than an environment variable because CircleCI doesn't support referencing dynamically-set environment variables from restore_cache keys. It only works for environment variables set statically for the entire workflow.

@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (5fffa65) 68.39% compared to head (a80c3b1) 68.39%.
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #21046   +/-   ##
========================================
  Coverage    68.39%   68.39%           
========================================
  Files         1007     1007           
  Lines        40252    40252           
  Branches     10764    10764           
========================================
  Hits         27529    27529           
  Misses       12723    12723           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@metamaskbot
Copy link
Collaborator

Builds ready [a80c3b1]
Page Load Metrics (1516 ± 396 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint882051333416
domContentLoaded842031273416
load9925121516826396
domInteractive842031273416
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@Gudahtt Gudahtt merged commit 07dff1d into develop Sep 26, 2023
9 checks passed
@Gudahtt Gudahtt deleted the prevent-reusing-cache-across-yarn-versions branch September 26, 2023 15:46
@github-actions github-actions bot locked and limited conversation to collaborators Sep 26, 2023
@metamaskbot metamaskbot added the release-11.3.0 Issue or pull request that will be included in release 11.3.0 label Sep 26, 2023
@HowardBraham
Copy link
Contributor

@Gudahtt @brad-decker @FrederikBolding I think there's a problem with this PR actually, because now we're restoring cache from
dependency-cache-{{ checksum "/tmp/YARN_VERSION" }}-{{ checksum "yarn.lock" }}
but saving cache to
dependency-cache-v1-{{ checksum "yarn.lock" }}
Thus, nothing ever comes back from the cache

@Gudahtt
Copy link
Member Author

Gudahtt commented Sep 28, 2023

Thanks @HowardBraham , good catch!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-11.3.0 Issue or pull request that will be included in release 11.3.0 team-extension-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants