-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Bump Yarn to v4 #3612
Bump Yarn to v4 #3612
Changes from 7 commits
4b4cbe7
54f60dc
c26ba43
db29601
61b57b3
ff9e020
7f59063
2cceb92
aa08a3c
5cb41fb
62bf5e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,21 @@ jobs: | |
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
- name: Install Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- name: Install Yarn | ||
run: corepack enable | ||
- name: Restore Yarn cache | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: yarn | ||
- uses: actions/cache@v3 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
./packages/**/dist | ||
|
@@ -38,10 +44,21 @@ jobs: | |
runs-on: ubuntu-latest | ||
needs: publish-release | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
- uses: actions/cache@v3 | ||
- name: Install Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- name: Install Yarn | ||
run: corepack enable | ||
- name: Restore Yarn cache | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: yarn | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
./packages/**/dist | ||
|
@@ -50,7 +67,7 @@ jobs: | |
fail-on-cache-miss: true | ||
- name: Dry Run Publish | ||
# omit npm-token token to perform dry run publish | ||
uses: MetaMask/action-npm-publish@v4 | ||
uses: MetaMask/action-npm-publish@v5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Was there a reason for updating to v5 in this PR? Seems like a good idea but it wasn't obvious how that related to the Yarn v4 update. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, good question, I didn't highlight this. Yarn v4 now requires passing an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, makes sense! |
||
with: | ||
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
subteam: S042S7RE4AE # @metamask-npm-publishers | ||
|
@@ -62,18 +79,29 @@ jobs: | |
runs-on: ubuntu-latest | ||
needs: publish-npm-dry-run | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
- uses: actions/cache@v3 | ||
- name: Install Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- name: Install Yarn | ||
run: corepack enable | ||
- name: Restore Yarn cache | ||
Gudahtt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: yarn | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
./packages/**/dist | ||
./node_modules/.yarn-state.yml | ||
key: ${{ github.sha }} | ||
fail-on-cache-miss: true | ||
- name: Publish | ||
uses: MetaMask/action-npm-publish@v4 | ||
uses: MetaMask/action-npm-publish@v5 | ||
with: | ||
npm-token: ${{ secrets.NPM_TOKEN }} | ||
env: | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
compressionLevel: mixed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These options were added automatically by Yarn 4. As far as I can see, they disable default behavior that would otherwise be turned on: |
||
|
||
enableGlobalCache: false | ||
|
||
enableScripts: false | ||
|
||
enableTelemetry: 0 | ||
enableTelemetry: false | ||
|
||
logFilters: | ||
- code: YN0004 | ||
|
@@ -11,9 +15,3 @@ nodeLinker: node-modules | |
plugins: | ||
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs | ||
spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js" | ||
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All plugins are enabled by default, so there is no need to store these in the repo: yarnpkg/berry#3591 |
||
spec: "@yarnpkg/plugin-workspace-tools" | ||
- path: .yarn/plugins/@yarnpkg/plugin-constraints.cjs | ||
spec: "@yarnpkg/plugin-constraints" | ||
|
||
yarnPath: .yarn/releases/yarn-3.3.0.cjs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is no longer necessary to store the Yarn binary in the repo, as Yarn can rely on the version that Corepack installs: yarnpkg/berry#4254 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -408,6 +408,13 @@ gen_enforced_dependency(WorkspaceCwd, DependencyIdent, CorrectPeerDependencyRang | |
atom_concat('^', CurrentDependencyVersion, CorrectPeerDependencyRange) | ||
). | ||
|
||
% The root workspace (and only the root workspace) needs to specify the Yarn | ||
% version required for development. | ||
gen_enforced_field(WorkspaceCwd, 'packageManager', '[email protected]') :- | ||
WorkspaceCwd == '.'. | ||
gen_enforced_field(WorkspaceCwd, 'packageManager', null) :- | ||
WorkspaceCwd \= '.'. | ||
|
||
% All packages must specify a minimum Node version of 18. | ||
gen_enforced_field(WorkspaceCwd, 'engines.node', '^18.18 || >=20'). | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,12 @@ | |
"scripts": { | ||
"build": "yarn run build:source && yarn run build:types", | ||
"build:clean": "rimraf dist '**/*.tsbuildinfo' && yarn build", | ||
"build:docs": "yarn workspaces foreach --no-private --parallel --interlaced --verbose run build:docs", | ||
"build:source": "yarn workspaces foreach --no-private --parallel --interlaced --verbose run build", | ||
"build:docs": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run build:docs", | ||
"build:source": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run build", | ||
"build:types": "tsc --build tsconfig.build.json --verbose", | ||
"build:watch": "yarn run build --watch", | ||
"changelog:update": "yarn workspaces foreach --no-private --parallel --interlaced --verbose run changelog:update", | ||
"changelog:validate": "yarn workspaces foreach --no-private --parallel --interlaced --verbose run changelog:validate", | ||
"changelog:update": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:update", | ||
"changelog:validate": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:validate", | ||
"create-package": "ts-node scripts/create-package", | ||
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn constraints && yarn lint:dependencies", | ||
"lint:dependencies": "depcheck && yarn dedupe --check", | ||
|
@@ -29,13 +29,13 @@ | |
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path .gitignore", | ||
"prepack": "./scripts/prepack.sh", | ||
"prepare-preview-builds": "./scripts/prepare-preview-builds.sh", | ||
"publish-previews": "yarn workspaces foreach --no-private --parallel --verbose run publish:preview", | ||
"publish-previews": "yarn workspaces foreach --all --no-private --parallel --verbose run publish:preview", | ||
"setup": "yarn install", | ||
"test": "yarn test:scripts --silent --collectCoverage=false --reporters=jest-silent-reporter && yarn test:packages", | ||
"test:clean": "yarn workspaces foreach --parallel --verbose run test:clean && yarn test", | ||
"test:clean": "yarn workspaces foreach --all --parallel --verbose run test:clean && yarn test", | ||
"test:packages": "yarn test:verbose --silent --collectCoverage=false --reporters=jest-silent-reporter", | ||
"test:scripts": "yarn jest --config ./jest.config.scripts.js --silent", | ||
"test:verbose": "yarn workspaces foreach --parallel --verbose run test:verbose", | ||
"test:verbose": "yarn workspaces foreach --all --parallel --verbose run test:verbose", | ||
"update-readme-content": "ts-node scripts/update-readme-content.ts", | ||
"workspaces:list-versions": "./scripts/list-workspace-versions.sh" | ||
}, | ||
|
@@ -88,7 +88,7 @@ | |
"typescript": "~4.9.5", | ||
"yargs": "^17.7.2" | ||
}, | ||
"packageManager": "yarn@3.3.0", | ||
"packageManager": "yarn@4.2.2", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the latest version of Yarn. It's slightly further than what the module template has, but I will submit a PR to upgrade it there. |
||
"engines": { | ||
"node": "^18.18 || >=20" | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,6 @@ | |
"typedoc": "^0.24.8", | ||
"typescript": "~4.9.5" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": "^18.18 || >=20" | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,6 @@ | |
"typedoc": "^0.24.8", | ||
"typescript": "~4.9.5" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": "^18.18 || >=20" | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange that we're calling
setup-node
here twiceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is definitely strange, yes, but there is a reason for it. We need to call it once to be able to use Corepack to install Yarn (recent versions of Node ship with Corepack). However, we can't restore the Yarn cache in this step because we need the correct version of Yarn to do that, and we don't have it yet. So after we install Node once without restoring the Yarn cache, we then install Corepack. Then we run the
setup-node
action again, this time restoring the Yarn cache.The alternative for this would be to ship the Yarn binary with the repo as we did before instead of using Corepack. Lego seemed to not like this way because then we need to guarantee that the Yarn binary is correct everywhere (which we never did): MetaMask/metamask-module-template#243 (comment). But we could open up that discussion again.
See relevant module template PRs:
corepack enable
before installing dependencies metamask-module-template#244