Skip to content

Commit

Permalink
upgrade to Yarn 4 (#2222)
Browse files Browse the repository at this point in the history
closes: #2245 
refs: Agoric/agoric-sdk#451
refs: Agoric/ui-kit#105

## Description

Move from Yarn 1 to Yarn 4. Some advantages,

- actively maintained
- [workspace protocol](https://yarnpkg.com/protocol/workspace) (so we
don't have to maintain version numbers in all deps)
- [patch protocol](https://yarnpkg.com/protocol/patch) (so we don't need
patch-package)
- [constraints](https://yarnpkg.com/features/constraints) (e.g. to
enforce layering)
- path to adopt pnpm-style linker (without changing the UI) (see
#1722 )

However this defers workspace protocol until the publishing workflow can
support it.

### Security Considerations

This does a bulk update of `yarn.lock`. It was automated by Yarn 4.

### Scaling Considerations

n/a

### Documentation Considerations

I reviewed `yarn` commands in *.md and I think they're all accurate.

### Testing Considerations

This could interact with the publishing pipeline. @kriskowal may want to
push a draft before we merge. If problems are found, depending on the
severity, we could follow up in a separate PR to land this sooner reduce
merge conflicts.

This was failing on the Windows tests, something about corepack not
taking effect. I don't know whether Windows is officially supported by
Endo. We've since disabled them.
#2243 is the issue restore.


### Compatibility Considerations

Some CLI commands are slightly different. We are adopting it across the
org so we have to adjust sometime.

### Upgrade Considerations

n/a
  • Loading branch information
kriskowal authored Apr 26, 2024
2 parents 2afacc5 + 2c9c81f commit 89c9617
Show file tree
Hide file tree
Showing 17 changed files with 12,335 additions and 8,694 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/browser-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
node-version: 18
- name: Provide yarn # yarn is missing in the Selenium image
run: npm install -g yarn@legacy ## get yarn v1.x in the container
run: corepack enable
- name: Install dependencies
run: yarn install
- name: Build artifacts
Expand Down
128 changes: 41 additions & 87 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Echo node version
run: node --version

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache npm modules
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn --frozen-lockfile
run: yarn install --immutable

# end macro

Expand Down Expand Up @@ -87,28 +80,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Echo node version
run: node --version

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
shell: bash

- name: Cache npm modules
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn --frozen-lockfile
run: yarn install --immutable

# end macro

Expand Down Expand Up @@ -144,29 +129,22 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Echo node version
run: node --version

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache npm modules
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

# end macro

- name: Install dependencies
run: yarn --frozen-lockfile --ignore-engines
run: yarn install --immutable

- name: Run yarn build
run: yarn build
Expand All @@ -191,27 +169,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Echo node version
run: node --version

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache npm modules
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn --frozen-lockfile
run: yarn install --immutable

# end macro

Expand All @@ -237,27 +208,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Echo node version
run: node --version

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache npm modules
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn --frozen-lockfile
run: yarn install --immutable

# end macro

Expand All @@ -283,33 +247,29 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Echo node version
run: node --version

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache npm modules
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn --frozen-lockfile
run: yarn install --immutable

# end macro

- name: 'build'
run: yarn run build

# fails under Node v12
- run: corepack disable

- name: 'switch to node v12'
uses: actions/setup-node@v3
with:
Expand All @@ -318,8 +278,9 @@ jobs:
- name: Echo node version
run: node --version

- name: Run yarn test:platform-compatibility
run: cd packages/ses && yarn test:platform-compatibility
- name: Run test:platform-compatibility
# npm b/c Yarn 4 doesn't work in Node 12
run: cd packages/ses && npm run test:platform-compatibility

viable-release:
name: viable-release
Expand All @@ -337,27 +298,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Echo node version
run: node --version

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache npm modules
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn --frozen-lockfile
run: yarn install --immutable

# end macro

Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/depcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: 'true'

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable

- uses: actions/setup-node@v3
with:
node-version: 18.x
Expand All @@ -23,5 +27,9 @@ jobs:

- name: Check for cycles
run: scripts/check-dependency-cycles.sh 0
- name: check mismatched dependencies
run: yarn depcheck

# Under Yarn "classic" this job also checked for mismatchedWorkspaceDependencies
# (https://github.com/yarnpkg/yarn/blob/158d96dce95313d9a00218302631cd263877d164/src/cli/commands/workspaces.js#L49)
# but it's not supported in Berry and it's better solved by the "workspace:*" protocol.
# If we do want more workspace constraint enforcement, we can define arbitrarily with:
# https://yarnpkg.com/features/constraints
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ typings/
# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity
# Yarn
# see https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# dotenv environment variables file
.env
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git a/node_modules/@lerna/conventional-commits/lib/recommend-version.js b/node_modules/@lerna/conventional-commits/lib/recommend-version.js
index 4551feb..b678322 100644
--- a/node_modules/@lerna/conventional-commits/lib/recommend-version.js
+++ b/node_modules/@lerna/conventional-commits/lib/recommend-version.js
diff --git a/lib/recommend-version.js b/lib/recommend-version.js
index a982adfc92b52fe15987336390fa618afe83574e..90a19ead33f696421b818abbd7b33f31f4835888 100644
--- a/lib/recommend-version.js
+++ b/lib/recommend-version.js
@@ -82,6 +82,8 @@ function recommendVersion(pkg, type, { changelogPreset, rootPath, tagPrefix, pre
//
if (releaseType === "major") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git a/node_modules/@lerna/version/lib/git-add.js b/node_modules/@lerna/version/lib/git-add.js
index d24f8ca..9b9b38d 100644
--- a/node_modules/@lerna/version/lib/git-add.js
+++ b/node_modules/@lerna/version/lib/git-add.js
diff --git a/lib/git-add.js b/lib/git-add.js
index d24f8ca3b3d299b853f1c90f4375f5d4cf6cba35..9b9b38df525c5d8bd3f20058c0836c49cac09c03 100644
--- a/lib/git-add.js
+++ b/lib/git-add.js
@@ -24,12 +24,12 @@ function resolvePrettier() {
return resolvedPrettier;
}
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"engines": {
"node": ">=16"
},
"packageManager": "yarn@1.22.21",
"packageManager": "yarn@4.1.1",
"devDependencies": {
"@jessie.js/eslint-plugin": "^0.3.0",
"@octokit/core": "^3.4.0",
Expand All @@ -20,6 +20,7 @@
"eslint-plugin-jsdoc": "^48.2.2",
"lerna": "^5.6.2",
"lerna-update-wizard": "^0.17.5",
"prettier": "^3.0.0",
"ts-api-utils": "~1.0.1",
"type-coverage": "^2.26.3",
"typedoc": "^0.25.12",
Expand All @@ -30,29 +31,30 @@
"scripts": {
"clean": "lerna clean",
"cover": "lerna run cover",
"depcheck": "node scripts/check-mismatched-dependencies.js",
"docs": "typedoc",
"docs:markdown-for-agoric-documentation-repo": "typedoc --plugin typedoc-plugin-markdown --tsconfig tsconfig.build.json",
"update": "lernaupdate --dedupe",
"format": "yarn prettier --write .github packages",
"lint": "yarn prettier --check .github packages && lerna run lint",
"format": "prettier --write .github packages",
"lint": "prettier --check .github packages && lerna run lint",
"lint-fix": "lerna run --no-bail lint-fix",
"test": "lerna run --ignore @endo/skel test",
"test262": "lerna run test262",
"postinstall": "patch-package",
"patch-package": "patch-package",
"build": "lerna run build",
"build-ts": "tsc --build tsconfig.build.json"
},
"dependencies": {
"conventional-changelog-conventionalcommits": "^4.6.0",
"patch-package": "^8.0.0"
"conventional-changelog-conventionalcommits": "^4.6.0"
},
"prettier": {
"arrowParens": "avoid",
"singleQuote": true
},
"typeCoverage": {
"atLeast": 0
},
"resolutions": {
"@babel/types": "7.24.0",
"@lerna/version@npm:5.6.2": "patch:@lerna/version@npm%3A5.6.2#~/.yarn/patches/@lerna-version-npm-5.6.2-ce2d9cb2f5.patch",
"@lerna/conventional-commits@npm:5.6.2": "patch:@lerna/conventional-commits@npm%3A5.6.2#~/.yarn/patches/@lerna-conventional-commits-npm-5.6.2-a373ba4bc0.patch"
}
}
4 changes: 1 addition & 3 deletions packages/bundle-source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"description": "Create source bundles from ES Modules",
"type": "module",
"main": "src/index.js",
"bin": {
"bundle-source": "./src/tool.js"
},
"bin": "./src/tool.js",
"exports": {
".": "./src/index.js",
"./exported.js": "./exported.js",
Expand Down
Loading

0 comments on commit 89c9617

Please sign in to comment.