Skip to content

Commit

Permalink
Replace yarn 1 with pnpm (#19870)
Browse files Browse the repository at this point in the history
Due to the end of support for Yarn 1 and several bugs that were
impacting our workflows, we realized a need to update the package
manager. After discussion and analysis (p9dueE-2MY-p2) we decided to go
with pnpm as the replacement.

See docs/yarn-upgrade.md for further notes.

Other side effects of this PR:

* Update a bunch of indirect dependencies.
* Add some missing dependencies.
* Move the js-test-runner into its own "project", like the Jetpack CLI,
  so we can remove its deps from the monorepo-root package.json.
* Deprecated a bunch of scripts in the monorepo-root package.json.
* Our CI now uses the published version of action-required-review.
  • Loading branch information
anomiex authored Jun 1, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent db6329a commit 4615a94
Showing 112 changed files with 29,061 additions and 65,197 deletions.
6 changes: 3 additions & 3 deletions .github/files/build-all-projects.sh
Original file line number Diff line number Diff line change
@@ -19,9 +19,9 @@ fi
echo "::set-output name=build-base::$BUILD_BASE"
[[ -n "$GITHUB_ENV" ]] && echo "BUILD_BASE=$BUILD_BASE" >> $GITHUB_ENV

# Install Yarn generally, and changelogger.
# Install JS generally, and changelogger.
echo "::group::Monorepo setup"
yarn install
pnpm install
echo "::endgroup::"
echo "::group::Changelogger setup"
(cd projects/packages/changelogger && composer install)
@@ -74,7 +74,7 @@ for SLUG in "${SLUGS[@]}"; do
OLDLOCK=
fi
fi
if (cd $BASE && yarn jetpack build "${SLUG}" -v --production); then
if (cd $BASE && pnpx jetpack build "${SLUG}" -v --production); then
FAIL=false
else
FAIL=true
10 changes: 5 additions & 5 deletions .github/files/check-lock-files.sh
Original file line number Diff line number Diff line change
@@ -23,14 +23,14 @@ for FILE in $(git ls-files 'composer.lock' '**/composer.lock'); do
cd "$BASE"
done

for FILE in $(git ls-files 'yarn.lock' '**/yarn.lock'); do
for FILE in $(git ls-files 'pnpm-lock.yaml' '**/pnpm-lock.yaml'); do
cd $(dirname "$FILE")
echo "::group::$FILE - yarn install"
yarn install
echo "::group::$FILE - pnpm install"
pnpm install
echo "::endgroup::"
if ! git diff --exit-code yarn.lock; then
if ! git diff --exit-code pnpm-lock.yaml; then
echo "---" # Bracket message containing newlines for better visibility in GH's logs.
echo "::error file=$FILE::$FILE is not up to date!%0AYou can probably fix this by running \`yarn install\` in the appropriate directory."
echo "::error file=$FILE::$FILE is not up to date!%0AYou can probably fix this by running \`pnpm install\` in the appropriate directory."
echo "---"
EXIT=1
fi
2 changes: 1 addition & 1 deletion .github/files/lint-project-structure.sh
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ tools/check-renovate-ignore-list.js
debug "Checking .nvmrc vs package.json engines"
RANGE="$(jq -r '.engines.node' package.json)"
VER="$(<.nvmrc)"
if ! yarn run semver --range "$RANGE" "$VER" &>/dev/null; then
if ! pnpx semver --range "$RANGE" "$VER" &>/dev/null; then
EXIT=1
echo "::error file=.nvmrc::Node version $VER in .nvmrc does not satisfy requirement $RANGE from package.json"
fi
4 changes: 2 additions & 2 deletions .github/files/renovate-helper.sh
Original file line number Diff line number Diff line change
@@ -72,8 +72,8 @@ fi

# Add a change file for every project touched in the PR, if any.
BASE=$PWD
echo "::group::Monorepo yarn install, for prettier"
yarn install
echo "::group::Monorepo JS install, for prettier"
pnpm install
echo "::endgroup::"
echo "::group::Installing changelogger"
cd projects/packages/changelogger
1 change: 1 addition & 0 deletions .github/pnpm-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
23 changes: 13 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -20,10 +20,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Read PHP and Node versions
- name: Read tool versions
id: versions
run: |
echo "::set-output name=php-version::$(<.github/php-version)"
echo "::set-output name=pnpm-version::$(<.github/pnpm-version)"
echo "::set-output name=node-version::$(<.nvmrc)"
- name: Setup PHP
@@ -51,16 +52,18 @@ jobs:
restore-keys: |
${{ runner.os }}-composer-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Use yarn cache
- name: Use pnpm cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ steps.versions.outputs.node-version }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-pnpm-${{ steps.versions.outputs.node-version }}-
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ steps.versions.outputs.pnpm-version }}

- name: Tool versions
run: |
@@ -70,8 +73,8 @@ jobs:
composer --version
which node
node --version
which yarn
yarn --version
which pnpm
pnpm --version
which jq
jq --version
77 changes: 56 additions & 21 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -49,10 +49,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Read PHP and Node versions
- name: Read tool versions
id: versions
run: |
echo "::set-output name=php-version::$(<.github/php-version)"
echo "::set-output name=pnpm-version::$(<.github/pnpm-version)"
echo "::set-output name=node-version::$(<.nvmrc)"
- name: Setup PHP
@@ -80,16 +81,18 @@ jobs:
restore-keys: |
${{ runner.os }}-composer-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Use yarn cache
- name: Use pnpm cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ steps.versions.outputs.node-version }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-pnpm-${{ steps.versions.outputs.node-version }}-
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ steps.versions.outputs.pnpm-version }}

- name: Tool versions
run: |
@@ -99,25 +102,25 @@ jobs:
composer --version
which node
node --version
which yarn
yarn --version
which pnpm
pnpm --version
which jq
jq --version
- name: Build Production Jetpack
run: |
yarn install
yarn jetpack build plugins/jetpack -v --production
pnpm install
pnpx jetpack build plugins/jetpack -v --production
- name: Environment set-up
working-directory: projects/plugins/jetpack/tests/e2e
env:
CONFIG_KEY: ${{ secrets.E2E_CONFIG_KEY }}
run: |
yarn install
yarn test-decrypt-config
yarn env-start
yarn tunnel-on
pnpm install
pnpm run test-decrypt-config
pnpm run env-start
pnpm run tunnel-on
- name: Set up Gutenberg
if: matrix.group == 'gutenberg'
@@ -126,15 +129,15 @@ jobs:

- name: Run ${{ matrix.group }} tests
working-directory: projects/plugins/jetpack/tests/e2e
run: yarn test-e2e --group=${{ matrix.group }}
run: pnpm run test-e2e -- --group=${{ matrix.group }}

- name: Environment tear-down
if: ${{ always() }}
working-directory: projects/plugins/jetpack/tests/e2e
continue-on-error: true
run: |
yarn tunnel-off
yarn pm2 logs --nostream --lines 10000 > output/logs/tunnel.log
pnpm run tunnel-off
pnpm run pm2 -- logs --nostream --lines 10000 > output/logs/tunnel.log
- name: Upload test artifacts
if: ${{ always() }}
@@ -172,9 +175,41 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Read tool versions
id: versions
run: |
echo "::set-output name=php-version::$(<.github/php-version)"
echo "::set-output name=pnpm-version::$(<.github/pnpm-version)"
echo "::set-output name=node-version::$(<.nvmrc)"
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.versions.outputs.node-version }}

- name: Use pnpm cache
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ steps.versions.outputs.node-version }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-pnpm-${{ steps.versions.outputs.node-version }}-
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ steps.versions.outputs.pnpm-version }}

- name: Tool versions
run: |
which node
node --version
which pnpm
pnpm --version
- name: Send Slack notification
working-directory: projects/plugins/jetpack/tests/e2e
run: |
yarn install
yarn test-decrypt-config
pnpm install
pnpm run test-decrypt-config
NODE_ENV=test node ./bin/slack.js job ${{needs.e2e-tests.result}}
23 changes: 13 additions & 10 deletions .github/workflows/gardening.yml
Original file line number Diff line number Diff line change
@@ -35,34 +35,37 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Read PHP and Node versions
- name: Read tool versions
id: versions
run: |
echo "::set-output name=php-version::$(<.github/php-version)"
echo "::set-output name=pnpm-version::$(<.github/pnpm-version)"
echo "::set-output name=node-version::$(<.nvmrc)"
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.versions.outputs.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Use yarn cache
- name: Use pnpm cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ steps.versions.outputs.node-version }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-pnpm-${{ steps.versions.outputs.node-version }}-
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ steps.versions.outputs.pnpm-version }}

- name: Tool versions
run: |
which node
node --version
which yarn
yarn --version
which pnpm
pnpm --version
which jq
jq --version
Loading

0 comments on commit 4615a94

Please sign in to comment.