Skip to content
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

Try pnpm (take two) #38624

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e8eefdf
Run pnpm import and squash other changes to ease rebasing
sarayourfriend Feb 8, 2022
1683f5b
Remove package-lock.json linting
sarayourfriend Feb 8, 2022
d1cc228
Declare dependency on csstype
sarayourfriend Feb 8, 2022
5fdf1e2
Fix wonky @types/react resolution due to react-native having differen…
sarayourfriend Feb 8, 2022
482c2a7
Try fixing react type resolution with hoisting
sarayourfriend Feb 8, 2022
815175f
Try a combination of hositing and tsconfig paths
sarayourfriend Feb 8, 2022
aef8dc2
Add explicit dev dependency on @types/node
sarayourfriend Feb 8, 2022
f41a70a
Add explicit jest-circus dependency
sarayourfriend Feb 8, 2022
9d69f1b
Remove lockfile linting step
sarayourfriend Feb 8, 2022
07d7411
Modify performance test script for pnpm
sarayourfriend Feb 8, 2022
d00f798
Use `pnpm list` to list installed packages
sarayourfriend Feb 8, 2022
199de59
Use `pnpm` to install and build plugin zip
sarayourfriend Feb 8, 2022
6039e83
Fix running native package scripts
sarayourfriend Feb 8, 2022
4951764
Fix build script
sarayourfriend Feb 8, 2022
202965e
Try hoisting within a package
sarayourfriend Feb 8, 2022
bd1d499
Improve setup node action and use better defaults
sarayourfriend Feb 12, 2022
618ae4f
Correct documentation/output
sarayourfriend Feb 12, 2022
f53d8d1
Try hositing inside the package that actually uses it
sarayourfriend Feb 12, 2022
57b64dd
Try shamefully-hoist
sarayourfriend Feb 12, 2022
7a351dc
Fix workspace package references
sarayourfriend Feb 12, 2022
cccb4df
Try using link: for workspace root dependencies
sarayourfriend Feb 12, 2022
b742db6
Patch eslint module resolution
sarayourfriend Feb 12, 2022
097bc58
Hoist stylelint dependencies
sarayourfriend Feb 12, 2022
97bbb1a
Break down and just hoist stuff
sarayourfriend Feb 12, 2022
359fb8d
Hoist namespaced plugins
sarayourfriend Feb 12, 2022
fd010de
Try workaround for npm-run-all not supporting pnpm
sarayourfriend Feb 13, 2022
e5066de
Add missing top-level dev dependency
sarayourfriend Feb 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

## Checklist:
- [ ] My code is tested.
- [ ] My code follows the WordPress code style. <!-- Check code: `npm run lint`, Guidelines: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/ -->
- [ ] My code follows the WordPress code style. <!-- Check code: `pnpm run lint`, Guidelines: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/ -->
- [ ] My code follows the accessibility standards. <!-- Guidelines: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/accessibility/ -->
- [ ] I've tested my changes with keyboard and screen readers. <!-- Instructions: https://github.com/WordPress/gutenberg/blob/HEAD/docs/contributors/accessibility-testing.md -->
- [ ] My code has proper inline documentation. <!-- Guidelines: https://developer.wordpress.org/coding-standards/inline-documentation-standards/javascript/ -->
Expand Down
52 changes: 52 additions & 0 deletions .github/action/setup-node-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# this is a reusable workflow that will be called by the
# push_staging and push_production workflows
# more info: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows

name: gutenberg/setup-node-env
description: Setup the Node.js environment including `pnpm` and dependencies

inputs:
install:
default: true
description: Whether to install dependencies.
install-working-directory:
required: false
description: Optional working directory to run installation in.
node-version:
required: false
description: The node version to use. If not provided, the version in `.nvmrc` will be used.
pnpm-version:
default: 6.29.1
description: The pnpm version to use.

runs:
using: 'composite'
steps:
- uses: pnpm/[email protected]
with:
version: ${{ inputs.pnpm-version }}

- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-

- uses: actions/[email protected]
with:
node-version: ${{ inputs.node-version }}
node-version-file: ${{ !inputs.node-version && '.nvmrc' || null }}
cache: pnpm
cache-dependency-path: |
pnpm-workspace.yaml
pnpm-lock.yaml
.npmrc
.nvmrc

- name: Install
if: inputs.install
shell: bash
run: "pnpm install"
working-directory: ${{ inputs.install-working-directory }}
8 changes: 2 additions & 6 deletions .github/workflows/build-plugin-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,7 @@ jobs:
with:
ref: ${{ needs.bump-version.outputs.release_branch || github.ref }}

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
with:
node-version: 14
cache: npm
- uses: ./.github/action/setup-node-env

- name: Build Gutenberg plugin ZIP file
run: ./bin/build-plugin-zip.sh
Expand All @@ -192,7 +188,7 @@ jobs:
run: |
IFS='.' read -r -a VERSION_ARRAY <<< "${VERSION}"
MILESTONE="Gutenberg ${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}"
npm run changelog -- --milestone="$MILESTONE" --unreleased > release-notes.txt
pnpm run changelog -- --milestone="$MILESTONE" --unreleased > release-notes.txt
sed -ie '1,6d' release-notes.txt
if [[ ${{ needs.bump-version.outputs.new_version }} != *"rc"* ]]; then
# Include previous RCs' release notes, if any
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/bundle-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ jobs:
with:
fetch-depth: 1

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
with:
node-version: ${{ matrix.node }}
cache: npm
- uses: ./.github/action/setup-node-env

- uses: preactjs/compressed-size-action@df6e03e187079aef959a2878311639c77b95ee2e # v2.2.0
with:
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/create-block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ jobs:
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
- uses: ./.github/action/setup-node-env
with:
node-version: ${{ matrix.node }}
cache: npm
node-version: ${{ matrix-node }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should still be matrix.node?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, yes it should be!


- name: npm install, build, format and lint
- name: build, format and lint
shell: bash
run: |
npm ci
bash ./bin/test-create-block.sh
run: bash ./bin/test-create-block.sh
12 changes: 4 additions & 8 deletions .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,16 @@ jobs:
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
- uses: ./.github/action/setup-node-env
with:
node-version: ${{ matrix.node }}
cache: npm

- name: Npm install and build
run: |
npm ci
npm run build
- name: Build
run: pnpm run build

- name: Install WordPress
run: |
npm run wp-env start
pnpm run wp-env start

- name: Running the tests
run: |
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/flaky-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@ jobs:
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
- uses: ./.github/action/setup-node-env
with:
node-version: 14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to keep this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is set to 14. I only kept passing it to the action in places that were still using the matrix strategy for it.

cache: npm

- name: Npm install
run: |
npm ci

- name: Report flaky tests
uses: ./.github/report-flaky-tests
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@ jobs:
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
with:
node-version: 14
cache: npm

- name: Npm install
run: |
npm ci
- uses: ./.github/action/setup-node-env

- name: Compare performance with trunk
if: github.event_name == 'pull_request'
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/pull-request-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,10 @@ jobs:
with:
ref: trunk

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
- uses: ./.github/action/setup-node-env
with:
node-version: ${{ matrix.node }}

- name: Cache NPM packages
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-npm-pr-automation-cache-${{ hashFiles('**/package-lock.json') }}

# Changing into the action's directory and running `npm install` is much
# faster than a full project-wide `npm ci`.
- name: Install NPM dependencies
run: npm install
working-directory: packages/project-management-automation
install-working-directory: packages/project-management-automation

- uses: ./packages/project-management-automation
with:
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ jobs:
- name: checkout
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
- uses: ./.github/action/setup-node-env
with:
node-version: ${{ matrix.node }}
cache: npm

- run: npm ci

- name: Restore Gradle cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
Expand All @@ -44,7 +40,7 @@ jobs:
api-level: 28
emulator-build: 7425822 # https://git.io/JE3jX
profile: pixel_xl
script: npm run native test:e2e:android:local ${{ matrix.native-test-name }}
script: pnpm run native test:e2e:android:local ${{ matrix.native-test-name }}

- uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2
if: always()
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ jobs:
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
- uses: ./.github/action/setup-node-env
with:
node-version: ${{ matrix.node }}
cache: npm

- run: npm ci

- name: Prepare build cache key
run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt
run: find pnpm-lock.yaml packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt

- name: Restore build cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
Expand All @@ -53,25 +49,25 @@ jobs:
~/Library/Caches/CocoaPods
~/.cocoapods/repos/trunk
packages/react-native-editor/ios/vendor
key: ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}-${{ hashFiles('packages/react-native-editor/ios/Podfile.lock') }}-${{ hashFiles('package-lock.json') }}
key: ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}-${{ hashFiles('packages/react-native-editor/ios/Podfile.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}

- name: Bundle iOS
run: npm run native test:e2e:bundle:ios
run: pnpm run native test:e2e:bundle:ios

- name: Switch Xcode version to ${{ matrix.xcode }}
run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode }}.app

- name: Build (if needed)
run: test -e packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/GutenbergDemo || npm run native test:e2e:build-app:ios
run: test -e packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/GutenbergDemo || pnpm run native test:e2e:build-app:ios

- name: Build Web Driver Agent (if needed)
run: test -d packages/react-native-editor/ios/build/WDA || npm run native test:e2e:build-wda
run: test -d packages/react-native-editor/ios/build/WDA || pnpm run native test:e2e:build-wda

- name: Force update Launch Database to prevent issues when opening the Simulator app
run: /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer/Applications/Simulator.app

- name: Run iOS Device Tests
run: TEST_RN_PLATFORM=ios npm run native device-tests:local ${{ matrix.native-test-name }}
run: TEST_RN_PLATFORM=ios pnpm run native device-tests:local ${{ matrix.native-test-name }}

- name: Prepare build cache
run: |
Expand Down
21 changes: 5 additions & 16 deletions .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,16 @@ jobs:
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
with:
node-version: 14
cache: npm

- name: Npm install
# A "full" install is executed, since `npm ci` does not always exit
# with an error status code if the lock file is inaccurate.
#
# See: https://github.com/WordPress/gutenberg/issues/16157
run: npm install
- uses: ./.github/action/setup-node-env

- name: Lint JavaScript and Styles
run: npm run lint
run: pnpm run lint

- name: Type checking
run: npm run build:package-types
run: pnpm run build:package-types

- name: Check local changes
run: npm run check-local-changes
run: pnpm run check-local-changes

- name: License compatibility
run: npm run check-licenses
run: pnpm run check-licenses
9 changes: 2 additions & 7 deletions .github/workflows/storybook-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@ jobs:
with:
ref: trunk

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
- uses: ./.github/action/setup-node-env
with:
node-version: ${{ matrix.node }}
cache: npm

- name: Install Dependencies
run: npm ci

- name: Build Storybook
run: npm run storybook:build
run: pnpm run storybook:build

- name: Deploy
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
Expand Down
Loading