Skip to content

Commit

Permalink
fix: Yarn 1.22.22 (#9143)
Browse files Browse the repository at this point in the history
## **Description**

Prevent engineers using different Yarn versions with different features
causing our CI dedupe step to break
- [x] Bump package.json Yarn engine from ^1.22.0 to 1.22.22 
- [x] Bump BitRise Yarn version from 1.22.19 to 1.22.22
- [x] Lock project Yarn version to 1.22.22
- [x] Add Yarn config file comment RE @lavamoat/allow-scripts setup
- [x] Run `yarn deduplicate` and commit
- [x] Revert Bump BitRise Yarn version from 1.22.19 to 1.22.22
([thread](#9143 (review)))
- [x] Bump BitRise Yarn version from 1.22.19 to 1.22.22
  - [x] Fix yarnpkg/yarn#9050
  - [x] Switch to <s>NPM or</s> Corepack

Nb: our metamask-extension setup
-
https://github.com/MetaMask/metamask-extension/blob/develop/package.json#L616
-
https://github.com/MetaMask/metamask-extension/blob/develop/package.json#L681
-
https://github.com/MetaMask/metamask-extension/blob/develop/.yarn/releases/yarn-4.0.2.cjs
-
https://github.com/MetaMask/metamask-extension/blob/develop/.yarnrc.yml#L142

https://classic.yarnpkg.com/lang/en/docs/package-json/#toc-engines
> The engines specify versions of clients that must be used with your
package. This checks against `process.versions` as well as the current
version of yarn.

https://classic.yarnpkg.com/lang/en/docs/yarnrc/#toc-yarn-path
> Instructs yarn to defer to another Yarn binary for execution. Useful
if you want to bundle Yarn into your repository and have everyone use
the same version for consistency. This was introduced in Yarn 1.0, so
all developers must have Yarn >= 1.0 installed.

https://yarnpkg.com/getting-started/qa

> `.yarn/plugins` and `.yarn/releases` contain the Yarn releases used in
the current repository (as defined by [yarn
](https://yarnpkg.com/cli/set/version)[set
version](https://yarnpkg.com/cli/set/version)). You will want to keep
them versioned (this prevents potential issues if, say, two engineers
use different Yarn versions with different features).

https://yarnpkg.com/cli/set/version

> Lock the Yarn version used by the project.

https://nodejs.org/dist/latest-v15.x/docs/api/all.html (introduced in
Node v16 only)

https://nodejs.org/dist/latest-v16.x/docs/api/all.html#all_packages_packagemanager
from testing our repo (on Node v18), this appears to have no effect
enforcing the version

from testing our repo, we could revert
c7d67e6
to keep our structure simpler
since the package.json engine field is enough to enforce the version
but these 2 files are generated by running `yarn set version 1.22.22`

Yarn v1.22 update
- PR: yarnpkg/yarn#9023
- Commit:
yarnpkg/yarn@88d5e44
- Picked into branch: https://github.com/yarnpkg/yarn/tree/1.22-stable

## **Related issues**

Fixes: CI dedupe step consistently failing

## **Manual testing steps**

- ensure `yarn --version` is below 1.22.22
- or e.g. `yarn set version 1.22.21`
- run `yarn`
- Yarn errors correctly ^1.22.22+ is expected

Nb: after doing this too many times, you can use a VPN as a workaround

<img width="1806" alt="Screenshot 2024-04-04 at 6 40 35 PM"
src="https://github.com/MetaMask/metamask-mobile/assets/1881059/41cf015c-2aed-4c63-8f24-041a5cf98ef3">

## **Screenshots/Recordings**

<img width="987" alt="Screenshot 2024-04-04 at 8 32 00 PM"
src="https://github.com/MetaMask/metamask-mobile/assets/1881059/901ca091-02db-4a69-8137-0ec1b6b3c07d">

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.

---------

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
  • Loading branch information
leotm and legobeat committed Apr 30, 2024
1 parent 48c9c80 commit 93dc225
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
17 changes: 10 additions & 7 deletions bitrise.yml
Expand Up @@ -200,15 +200,15 @@ workflows:
inputs:
- content: |-
#!/usr/bin/env bash
echo "Node and Yarn being installed"
echo "Node $NODE_VERSION being installed with asdf"
asdf list all nodejs
asdf install nodejs "$NODE_VERSION"
asdf global nodejs "$NODE_VERSION"
asdf plugin add yarn
asdf list all yarn
asdf install yarn "$YARN_VERSION"
asdf global yarn "$YARN_VERSION"
title: Install node and yarn
echo "Corepack being installed with npm"
npm i -g "corepack@$COREPACK_VERSION"
echo "Corepack enabling $YARN_VERSION"
corepack enable
title: Install node, yarn and corepack

# Notifications utility workflows
# Provides values for commit or branch message and path depending on commit env setup initialised or not
Expand Down Expand Up @@ -1346,7 +1346,10 @@ app:
NODE_VERSION: 18.18.2
- opts:
is_expand: false
YARN_VERSION: 1.22.19
YARN_VERSION: 1.22.22
- opts:
is_expand: false
COREPACK_VERSION: 0.28.0
meta:
bitrise.io:
stack: osx-xcode-15.0.x
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -511,7 +511,7 @@
},
"engines": {
"node": "~18.18.2",
"yarn": "^1.22.0"
"yarn": "^1.22.22"
},
"lavamoat": {
"allowScripts": {
Expand Down Expand Up @@ -553,5 +553,6 @@
"@metamask/sdk-communication-layer>bufferutil": false,
"@metamask/sdk-communication-layer>utf-8-validate": false
}
}
},
"packageManager": "yarn@1.22.22"
}

0 comments on commit 93dc225

Please sign in to comment.