-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Switch to pnpm #74689
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
Switch to pnpm #74689
Changes from all commits
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 |
|---|---|---|
| @@ -1,54 +1,102 @@ | ||
| name: 'Setup Node.js and install npm dependencies' | ||
| description: 'Configure Node.js and install npm dependencies while managing all aspects of caching.' | ||
| name: 'Setup Node.js and install dependencies' | ||
| description: 'Configure Node.js and install npm/pnpm dependencies while managing all aspects of caching.' | ||
| inputs: | ||
| node-version: | ||
| description: 'Optional. The Node.js version to use. When not specified, the version specified in .nvmrc will be used.' | ||
| required: false | ||
| type: string | ||
| outputs: | ||
| package-manager: | ||
| description: 'The detected package manager (npm or pnpm)' | ||
| value: ${{ steps.detect-pm.outputs.manager }} | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Detect package manager | ||
| id: detect-pm | ||
| run: | | ||
| if [ -f "pnpm-lock.yaml" ]; then | ||
| echo "manager=pnpm" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "manager=npm" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| shell: bash | ||
|
|
||
| - name: Install pnpm | ||
| if: steps.detect-pm.outputs.manager == 'pnpm' | ||
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | ||
|
|
||
| - name: Use desired version of Node.js | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | ||
| with: | ||
| node-version-file: ${{ inputs.node-version == '' && '.nvmrc' || '' }} | ||
| node-version: ${{ inputs.node-version }} | ||
| check-latest: true | ||
| cache: npm | ||
| cache: ${{ steps.detect-pm.outputs.manager }} | ||
|
|
||
| - name: Get Node.js and npm version | ||
| - name: Get Node.js version | ||
| id: node-version | ||
| run: | | ||
| echo "NODE_VERSION=$(node -v)" >> "$GITHUB_OUTPUT" | ||
| run: echo "NODE_VERSION=$(node -v)" >> "$GITHUB_OUTPUT" | ||
| shell: bash | ||
|
|
||
| # pnpm caching | ||
| - name: Get pnpm store directory | ||
| if: steps.detect-pm.outputs.manager == 'pnpm' | ||
| id: pnpm-cache | ||
| run: echo "STORE_PATH=$(pnpm store path)" >> "$GITHUB_OUTPUT" | ||
| shell: bash | ||
|
|
||
| - name: Cache pnpm store | ||
| if: steps.detect-pm.outputs.manager == 'pnpm' | ||
| id: cache-pnpm-store | ||
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | ||
| with: | ||
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||
| key: pnpm-store-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.NODE_VERSION }}-${{ hashFiles('pnpm-lock.yaml') }} | ||
| restore-keys: | | ||
| pnpm-store-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.NODE_VERSION }}- | ||
|
|
||
| - name: Install pnpm dependencies | ||
| if: steps.detect-pm.outputs.manager == 'pnpm' | ||
| run: pnpm install | ||
| shell: bash | ||
|
|
||
| # npm caching | ||
| - name: Cache node_modules | ||
| if: steps.detect-pm.outputs.manager == 'npm' | ||
| id: cache-node_modules | ||
| uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2 | ||
| with: | ||
| path: '**/node_modules' | ||
| key: node_modules-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.NODE_VERSION }}-${{ hashFiles('package-lock.json', 'patches/**') }} | ||
|
|
||
| - name: Install npm dependencies | ||
| if: ${{ steps.cache-node_modules.outputs.cache-hit != 'true' }} | ||
| run: | | ||
| npm ci | ||
| if: steps.detect-pm.outputs.manager == 'npm' && steps.cache-node_modules.outputs.cache-hit != 'true' | ||
| run: npm ci | ||
| shell: bash | ||
| - name: Upload npm logs as an artifact on failure | ||
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | ||
| if: failure() | ||
| with: | ||
| name: npm-logs | ||
| path: C:\npm\cache\_logs | ||
|
|
||
| # On cache hit, we run the post-install script to match the native `npm ci` behavior. | ||
| # An example of this is to patch `node_modules` using patch-package. | ||
| - name: Post-install | ||
| if: ${{ steps.cache-node_modules.outputs.cache-hit == 'true' }} | ||
| - name: Post-install (npm) | ||
| if: steps.detect-pm.outputs.manager == 'npm' && steps.cache-node_modules.outputs.cache-hit == 'true' | ||
| run: | | ||
| # Run the post-install script for the root project. | ||
| npm run postinstall | ||
| # Run the post-install scripts for workspaces. | ||
| npx lerna run postinstall | ||
| shell: bash | ||
|
|
||
| - name: Upload pnpm logs as an artifact on failure | ||
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
| if: failure() && steps.detect-pm.outputs.manager == 'pnpm' | ||
| with: | ||
| name: pnpm-logs | ||
| path: ~/.local/share/pnpm/store | ||
|
|
||
| - name: Upload npm logs as an artifact on failure | ||
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | ||
| if: failure() && steps.detect-pm.outputs.manager == 'npm' | ||
| with: | ||
| name: npm-logs | ||
| path: C:\npm\cache\_logs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,8 +144,6 @@ jobs: | |
| run: | | ||
| jq --tab --arg version "${VERSION}" '.version = $version' package.json > package.json.tmp | ||
| mv package.json.tmp package.json | ||
| jq --tab --arg version "${VERSION}" '.version = $version | .packages[""].version = $version' package-lock.json > package-lock.json.tmp | ||
| mv package-lock.json.tmp package-lock.json | ||
| sed -i "s/${OLD_VERSION}/${VERSION}/g" gutenberg.php | ||
|
|
||
| - name: Commit the version bump to the release branch | ||
|
|
@@ -154,7 +152,7 @@ jobs: | |
| TARGET_BRANCH: ${{ steps.get_version.outputs.release_branch }} | ||
| VERSION: ${{ steps.get_version.outputs.new_version }} | ||
| run: | | ||
| git add gutenberg.php package.json package-lock.json | ||
| git add gutenberg.php package.json | ||
| git commit -m "Bump plugin version to ${VERSION}" | ||
| git push --set-upstream origin "$TARGET_BRANCH" | ||
| echo "version_bump_commit=$(git rev-parse --verify --short HEAD)" >> "$GITHUB_OUTPUT" | ||
|
|
@@ -201,11 +199,15 @@ jobs: | |
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Install pnpm | ||
|
Member
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. Does this need to happen after configuring the desired version of Node.js to ensure it's installed & configured correctly? Running it prior would result in the default version of Node.js on the Actions runner being used instead when installing, which could be problematic in some scenarios. |
||
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | ||
|
|
||
| - name: Use desired version of Node.js | ||
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| check-latest: true | ||
| cache: pnpm | ||
|
|
||
| - name: Build Gutenberg plugin ZIP file | ||
| run: ./bin/build-plugin-zip.sh | ||
|
|
@@ -225,7 +227,7 @@ jobs: | |
| run: | | ||
| IFS='.' read -r -a VERSION_ARRAY <<< "${VERSION}" | ||
| MILESTONE="Gutenberg ${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}" | ||
| npm run other:changelog -- --milestone="$MILESTONE" --unreleased > release-notes.txt | ||
| pnpm run other:changelog --milestone="$MILESTONE" --unreleased > release-notes.txt | ||
| sed -ie '1,6d' release-notes.txt | ||
| if [[ "${VERSION}" != *"rc"* ]]; then | ||
| # Include previous RCs' release notes, if any | ||
|
|
@@ -378,17 +380,24 @@ jobs: | |
| git config user.name "Gutenberg Repository Automation" | ||
| git config user.email gutenberg@wordpress.org | ||
|
|
||
| - name: Install pnpm | ||
|
Member
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. Same question here. Should this happen after setting up Node.js? |
||
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | ||
| with: | ||
| package_json_file: 'main/package.json' | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | ||
| with: | ||
| node-version-file: 'main/.nvmrc' | ||
| registry-url: 'https://registry.npmjs.org' | ||
| check-latest: true | ||
| cache: pnpm | ||
|
Member
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. When building production assets, caches should never be used to avoid cache poisoning. |
||
| cache-dependency-path: 'main/pnpm-lock.yaml' | ||
|
|
||
| - name: Publish packages to npm ("latest" dist-tag) | ||
| run: | | ||
| cd main | ||
| npm ci | ||
| pnpm install | ||
| ./bin/plugin/cli.js npm-latest --semver minor --ci --repository-path ../publish | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,12 +55,15 @@ jobs: | |
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | ||
|
|
||
| - name: Use desired version of Node.js | ||
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| check-latest: true | ||
| cache: npm | ||
| package-manager-cache: true | ||
|
Member
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. Looking at the documentation, this is what it says for
The description makes it seem that this only controls caching for npm? I don't see any indication in the Action logs that it successfully detected pnpm and configured caching accorrdingly. It's possible that just |
||
|
|
||
| - uses: preactjs/compressed-size-action@946a292cd35bd1088e0d7eb92b69d1a8d5b5d76a # v2.8.0 | ||
| with: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,24 +41,33 @@ jobs: | |
| - name: Setup Node.js and install dependencies | ||
| uses: ./.github/setup-node | ||
|
|
||
| - name: Npm build | ||
| run: npm run build -- --skip-types | ||
| - name: Detect package manager | ||
| id: detect-pm | ||
| run: | | ||
|
Member
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. I'm wondering if there is a way to handle this with a command instead of having to detect this within Action files. If not, then this should be abstracted into a separate job and the output should be shared with every other job in the workflow instead of having to run it twice.
Member
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. Also, I know that the goal here was to ensure a smooth transition. But if there is a proposal published and a schedule announced after, everyone would be made aware of the change and the only impact should be that the GitHub Action workflows for each pull request would no longer pass. Wouldn't rebasing or updating the HEAD branch fix that? I'm leaning towards not including this at all if we can help it. It could help contributors with the transition. But on the other hand, it could temporarily be a blocker for some. |
||
| if [ -f "pnpm-lock.yaml" ]; then | ||
| echo "manager=pnpm" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "manager=npm" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Build | ||
| run: ${{ steps.detect-pm.outputs.manager }} run build -- --skip-types | ||
|
|
||
| - name: Install Playwright dependencies | ||
| run: | | ||
| npx playwright install chromium firefox webkit --with-deps | ||
|
|
||
| - name: Install WordPress and start the server | ||
| run: | | ||
| npm run wp-env-test start | ||
| ${{ steps.detect-pm.outputs.manager }} run wp-env-test start | ||
|
|
||
| - name: Run the tests | ||
| env: | ||
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | ||
| SHARD_PART: ${{ matrix.part }} | ||
| SHARD_TOTAL: ${{ matrix.totalParts }} | ||
| run: | | ||
| xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e -- --shard="${SHARD_PART}/${SHARD_TOTAL}" | ||
| xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- ${{ steps.detect-pm.outputs.manager }} run test:e2e --shard="${SHARD_PART}/${SHARD_TOTAL}" | ||
|
|
||
| - name: Archive debug artifacts (screenshots, traces) | ||
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
|
|
@@ -132,8 +141,17 @@ jobs: | |
| - name: Setup Node.js and install dependencies | ||
| uses: ./.github/setup-node | ||
|
|
||
| - name: Npm build | ||
| run: npm run build -- --skip-types | ||
| - name: Detect package manager | ||
| id: detect-pm | ||
| run: | | ||
| if [ -f "pnpm-lock.yaml" ]; then | ||
| echo "manager=pnpm" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "manager=npm" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Build | ||
| run: ${{ steps.detect-pm.outputs.manager }} run build -- --skip-types | ||
|
|
||
| - name: Report flaky tests | ||
| uses: ./packages/report-flaky-tests | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,10 +49,10 @@ jobs: | |
| with: | ||
|
Member
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. Both React Native workflows are currently disabled. I lean towards not making changes to these files because they currently cannot be tested. I have been meaning to open an issue that suggests we should remove the RN-specific dependencies and workflows until there is a coordinated effort to support this going forward. They can always be restored through version control in the future. |
||
| path: | | ||
| ~/.appium | ||
| key: ${{ runner.os }}-tests-setup-${{ hashFiles('package-lock.json') }} | ||
| key: ${{ runner.os }}-tests-setup-${{ hashFiles('pnpm-lock.yaml') }} | ||
|
|
||
| - name: Prepare tests setup | ||
| run: npm run native test:e2e:setup | ||
| run: pnpm run native test:e2e:setup | ||
|
|
||
| - name: Gradle cache | ||
| uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2 | ||
|
|
@@ -91,7 +91,7 @@ jobs: | |
| disable-animations: true | ||
| arch: x86_64 | ||
| profile: Nexus 6 | ||
| script: npm run native test:e2e:android:local "$NATIVE_TEST_NAME" | ||
| script: pnpm run native test:e2e:android:local "$NATIVE_TEST_NAME" | ||
|
|
||
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
| if: always() | ||
|
|
||
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.
Will changes to the
pnpm-lock.yamlfile ever need to be committed?