From a58252a7267b87a4935a5d6d50ed65fdd3422ea4 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Wed, 26 May 2021 14:13:57 -0400 Subject: [PATCH 1/7] Only calculate the compressed size when necessary. (#32161) This updates the compressed size workflow to run only when the files changes would have an impact on the package size. (cherry picked from commit 23d84b3ed7614196450e911da83a9a21e3f625bf) --- .github/workflows/bundle-size.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bundle-size.yml b/.github/workflows/bundle-size.yml index cd3f591a04910..afb094b928dcf 100644 --- a/.github/workflows/bundle-size.yml +++ b/.github/workflows/bundle-size.yml @@ -1,6 +1,28 @@ name: Compressed Size -on: [pull_request] +on: + pull_request: + paths: + # Any change to a CSS, Sass, or JavaScript file should run checks. + - '**.js' + - '**.css' + - '**.scss' + # Changes to any NPM related files could affect the outcome. + - '**package*.json' + # These files configures ESLint. Changes could affect the outcome. + - '**.eslint*' + # These files configures JSHint. Changes could affect the outcome. + - '**.jshint*' + # These files configures Prettier. Changes could affect the outcome. + - '**.prettier*' + # These files configures stylelint. Changes could affect the outcome. + - '**.stylelint*' + # These files configures TypeScript. Changes could affect the outcome. + - '**.tsconfig*' + # This file configures Webpack. Changes could affect the outcome. + - 'webpack.config.js' + # Changes to this workflow file should always verify the changes are successful. + - '.github/workflows/bundle-size.yml' # Cancels all previous workflow runs for pull requests that have not completed. concurrency: From 0c117bff2e58c466767e13f8b81bc694e25621d9 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Wed, 2 Jun 2021 06:49:29 -0400 Subject: [PATCH 2/7] Limit when workflows run on forks (#32114) (cherry picked from commit 435dde470f5541ba397a83126333223abe1eee41) --- .github/workflows/build-plugin-zip.yml | 3 +++ .github/workflows/create-block.yml | 1 + .github/workflows/end2end-test.yml | 3 +-- .github/workflows/performance.yml | 2 +- .github/workflows/pull-request-automation.yml | 1 + .github/workflows/rnmobile-ios-runner.yml | 1 + .github/workflows/stale-issue-add-needs-testing.yml | 1 + .github/workflows/stale-issue-mark-stale.yml | 1 + .github/workflows/stale-issue-needs-info.yml | 1 + .github/workflows/static-checks.yml | 2 +- .github/workflows/storybook-pages.yml | 1 + .github/workflows/unit-test.yml | 6 ++++-- 12 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 9d376e0ea6e2f..d3e1ee1bed00e 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -22,6 +22,7 @@ jobs: name: Bump version runs-on: ubuntu-latest if: | + github.repository == 'WordPress/gutenberg' && github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/trunk' && ( github.event.inputs.version == 'rc' || @@ -169,6 +170,8 @@ jobs: name: Create Release Draft and Attach Asset needs: [bump-version, build] runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' }} + steps: - name: Set Release Version id: get_release_version diff --git a/.github/workflows/create-block.yml b/.github/workflows/create-block.yml index 76a11ff6ad69b..5b89d6678ebbb 100644 --- a/.github/workflows/create-block.yml +++ b/.github/workflows/create-block.yml @@ -16,6 +16,7 @@ jobs: checks: name: Checks runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/end2end-test.yml b/.github/workflows/end2end-test.yml index a6ab7b73e85a0..9bb2d220cc79d 100644 --- a/.github/workflows/end2end-test.yml +++ b/.github/workflows/end2end-test.yml @@ -18,9 +18,8 @@ concurrency: jobs: admin: name: Admin - ${{ matrix.part }} - runs-on: ubuntu-latest - + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 649f9155ad5e8..031f19dc6b892 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -15,8 +15,8 @@ concurrency: jobs: performance: name: Run performance tests - runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' }} steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 diff --git a/.github/workflows/pull-request-automation.yml b/.github/workflows/pull-request-automation.yml index 6c84669f3e390..a9317cfe211ca 100644 --- a/.github/workflows/pull-request-automation.yml +++ b/.github/workflows/pull-request-automation.yml @@ -7,6 +7,7 @@ name: Pull request automation jobs: pull-request-automation: runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' }} steps: # Checkout defaults to using the branch which triggered the event, which # isn't necessarily `trunk` (e.g. in the case of a merge). diff --git a/.github/workflows/rnmobile-ios-runner.yml b/.github/workflows/rnmobile-ios-runner.yml index 971ef150e0126..aa8f3c9d78e20 100644 --- a/.github/workflows/rnmobile-ios-runner.yml +++ b/.github/workflows/rnmobile-ios-runner.yml @@ -15,6 +15,7 @@ concurrency: jobs: test: runs-on: macos-latest + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} strategy: matrix: xcode: [12.2] diff --git a/.github/workflows/stale-issue-add-needs-testing.yml b/.github/workflows/stale-issue-add-needs-testing.yml index e17bfa7b29567..a01f1bfcaf9ee 100644 --- a/.github/workflows/stale-issue-add-needs-testing.yml +++ b/.github/workflows/stale-issue-add-needs-testing.yml @@ -6,6 +6,7 @@ on: jobs: stale: runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' }} steps: - uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17 with: diff --git a/.github/workflows/stale-issue-mark-stale.yml b/.github/workflows/stale-issue-mark-stale.yml index 983b62c1e0700..746a123df56ac 100644 --- a/.github/workflows/stale-issue-mark-stale.yml +++ b/.github/workflows/stale-issue-mark-stale.yml @@ -6,6 +6,7 @@ on: jobs: stale: runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' }} steps: - uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17 with: diff --git a/.github/workflows/stale-issue-needs-info.yml b/.github/workflows/stale-issue-needs-info.yml index c0f3e4ed6bec6..3de5cb07f9d33 100644 --- a/.github/workflows/stale-issue-needs-info.yml +++ b/.github/workflows/stale-issue-needs-info.yml @@ -6,6 +6,7 @@ on: jobs: stale: runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' }} steps: - uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17 with: diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index 32508611082d6..e423dff99ac2e 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -18,8 +18,8 @@ concurrency: jobs: check: name: All - runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 diff --git a/.github/workflows/storybook-pages.yml b/.github/workflows/storybook-pages.yml index 7084b8d964230..ba28045f5e34a 100644 --- a/.github/workflows/storybook-pages.yml +++ b/.github/workflows/storybook-pages.yml @@ -8,6 +8,7 @@ on: jobs: deploy: runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' }} steps: - name: Checkout uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index d5d4b06c6bcfd..8c66c2983e08e 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -21,6 +21,8 @@ jobs: unit-js: name: JavaScript runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} + strategy: fail-fast: false matrix: @@ -59,8 +61,8 @@ jobs: unit-php: name: PHP - runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 @@ -101,8 +103,8 @@ jobs: mobile-unit-js: name: Mobile - runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 From cd105d1ce28b84926d58023521c6a0cf5c5f8141 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Mon, 7 Jun 2021 11:08:54 -0400 Subject: [PATCH 3/7] Improvements to NPM package caching across workflows (#32458) * Use a consistent cache key for NPM packages across all workflows. Also, include the NodeJS version in the cache key in case different package versions are required. * Update the `actions/cache` action to the latest version. * Remove the strategy matrix from jobs with a single NodeJS version. For some reason, GitHub Actions will attach matrix values to job names in parenthesis. Because required checks are configured by job name, these need to stay consistent. (cherry picked from commit 7e5416280ecb9d3197647e8eae20e0f62afc3570) --- .github/workflows/build-plugin-zip.yml | 13 ++++--- .github/workflows/bundle-size.yml | 15 ++++++-- .github/workflows/create-block.yml | 12 +++---- .github/workflows/end2end-test.yml | 13 ++++--- .github/workflows/performance.yml | 12 +++---- .github/workflows/pull-request-automation.yml | 15 ++++++-- .github/workflows/rnmobile-android-runner.yml | 14 ++++---- .github/workflows/rnmobile-ios-runner.yml | 16 +++++---- .github/workflows/static-checks.yml | 12 +++---- .github/workflows/storybook-pages.yml | 16 +++++---- .github/workflows/unit-test.yml | 36 ++++++++----------- 11 files changed, 93 insertions(+), 81 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index d3e1ee1bed00e..94e5743082eaa 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -112,25 +112,24 @@ jobs: runs-on: ubuntu-latest needs: bump-version if: always() + steps: - name: Checkout code uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 with: ref: ${{ needs.bump-version.outputs.release_branch || github.ref }} - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + node-version: 14 - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules + - 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 }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-14-npm-cache-${{ hashFiles('**/package-lock.json') }} - name: Build Gutenberg plugin ZIP file run: ./bin/build-plugin-zip.sh diff --git a/.github/workflows/bundle-size.yml b/.github/workflows/bundle-size.yml index afb094b928dcf..56b45f6a7e1aa 100644 --- a/.github/workflows/bundle-size.yml +++ b/.github/workflows/bundle-size.yml @@ -35,16 +35,25 @@ jobs: build: name: Check runs-on: ubuntu-latest - + strategy: + matrix: + node: ['14'] steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 with: fetch-depth: 1 - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + 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-cache-${{ hashFiles('**/package-lock.json') }} - uses: preactjs/compressed-size-action@7d87f60a6b0c7d193b8183ce859ed00b356ea92f # v2.1.0 with: diff --git a/.github/workflows/create-block.yml b/.github/workflows/create-block.yml index 5b89d6678ebbb..34f3fb65f53b7 100644 --- a/.github/workflows/create-block.yml +++ b/.github/workflows/create-block.yml @@ -20,24 +20,22 @@ jobs: strategy: fail-fast: false matrix: - node: [12, 14] + node: ['12', '14'] steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Use Node.js ${{ matrix.node }}.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: node-version: ${{ matrix.node }} - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules-${{ 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 }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-npm-cache-${{ hashFiles('**/package-lock.json') }} - name: npm install, build, format and lint run: | diff --git a/.github/workflows/end2end-test.yml b/.github/workflows/end2end-test.yml index 9bb2d220cc79d..398cd76ba2367 100644 --- a/.github/workflows/end2end-test.yml +++ b/.github/workflows/end2end-test.yml @@ -24,23 +24,22 @@ jobs: fail-fast: false matrix: part: [1, 2, 3, 4] + node: ['14'] steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + node-version: ${{ matrix.node }} - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules + - 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 }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-npm-cache-${{ hashFiles('**/package-lock.json') }} - name: Npm install and build run: | diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 031f19dc6b892..c3fde03d6cee7 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -21,19 +21,17 @@ jobs: steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + node-version: 14 - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules + - 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 }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-14-npm-cache-${{ hashFiles('**/package-lock.json') }} - name: Npm install run: | diff --git a/.github/workflows/pull-request-automation.yml b/.github/workflows/pull-request-automation.yml index a9317cfe211ca..83cdff759f74b 100644 --- a/.github/workflows/pull-request-automation.yml +++ b/.github/workflows/pull-request-automation.yml @@ -8,6 +8,10 @@ jobs: pull-request-automation: runs-on: ubuntu-latest if: ${{ github.repository == 'WordPress/gutenberg' }} + strategy: + matrix: + node: ['14'] + steps: # Checkout defaults to using the branch which triggered the event, which # isn't necessarily `trunk` (e.g. in the case of a merge). @@ -15,10 +19,17 @@ jobs: with: ref: trunk - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + 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-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`. diff --git a/.github/workflows/rnmobile-android-runner.yml b/.github/workflows/rnmobile-android-runner.yml index 9c2de4d3355ed..e028267fe0b78 100644 --- a/.github/workflows/rnmobile-android-runner.yml +++ b/.github/workflows/rnmobile-android-runner.yml @@ -21,26 +21,28 @@ jobs: strategy: matrix: native-test-name: [gutenberg-editor-initial-html] + node: ['14'] steps: - name: checkout uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + node-version: ${{ matrix.node }} - - name: Restore npm cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + - 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 }}-npm-${{ hashFiles('package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-npm-cache-${{ hashFiles('**/package-lock.json') }} - run: npm ci - name: Restore Gradle cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} diff --git a/.github/workflows/rnmobile-ios-runner.yml b/.github/workflows/rnmobile-ios-runner.yml index aa8f3c9d78e20..2a5a3d7c6bdc5 100644 --- a/.github/workflows/rnmobile-ios-runner.yml +++ b/.github/workflows/rnmobile-ios-runner.yml @@ -20,20 +20,22 @@ jobs: matrix: xcode: [12.2] native-test-name: [gutenberg-editor-initial-html] + node: ['14'] steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + node-version: ${{ matrix.node }} - - name: Restore npm cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + - 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 }}-npm-${{ hashFiles('package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-npm-cache-${{ hashFiles('**/package-lock.json') }} - run: npm ci @@ -41,7 +43,7 @@ jobs: 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 - name: Restore build cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: path: | packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app @@ -49,7 +51,7 @@ jobs: key: ${{ runner.os }}-ios-build-${{ matrix.xcode }}-${{ hashFiles('ios-checksums.txt') }} - name: Restore pods cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: path: | packages/react-native-editor/ios/Pods diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index e423dff99ac2e..de8a78796b662 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -24,19 +24,17 @@ jobs: steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + node-version: 14 - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules + - 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 }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-14-npm-cache-${{ hashFiles('**/package-lock.json') }} - name: Npm install and build # A "full" install is executed, since `npm ci` does not always exit diff --git a/.github/workflows/storybook-pages.yml b/.github/workflows/storybook-pages.yml index ba28045f5e34a..5cdcec4866f94 100644 --- a/.github/workflows/storybook-pages.yml +++ b/.github/workflows/storybook-pages.yml @@ -9,25 +9,27 @@ jobs: deploy: runs-on: ubuntu-latest if: ${{ github.repository == 'WordPress/gutenberg' }} + strategy: + matrix: + node: ['14'] + steps: - name: Checkout uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 with: ref: trunk - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + node-version: ${{ matrix.node }} - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules + - 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 }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-npm-cache-${{ hashFiles('**/package-lock.json') }} - name: Install Dependencies run: npm ci diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 8c66c2983e08e..73507e750a210 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -26,24 +26,22 @@ jobs: strategy: fail-fast: false matrix: - node: [12, 14] + node: ['12', '14'] steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Use Node.js ${{ matrix.node }}.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: node-version: ${{ matrix.node }} - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules-${{ 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 }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-npm-cache-${{ hashFiles('**/package-lock.json') }} - name: Npm install and build # It's not necessary to run the full build, since Jest can interpret @@ -67,19 +65,17 @@ jobs: steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + node-version: 14 - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules + - 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 }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-14-npm-cache-${{ hashFiles('**/package-lock.json') }} - name: Npm install and build run: | @@ -109,19 +105,17 @@ jobs: steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Use Node.js 14.x + - name: Use desired version of NodeJS uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: - node-version: 14.x + node-version: 14 - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules + - 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 }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-14-npm-cache-${{ hashFiles('**/package-lock.json') }} - name: Npm install and build # It's not necessary to run the full build, since Jest can interpret From 54733d87aeaec04342888096e220f96154da44a5 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Mon, 7 Jun 2021 15:56:51 -0400 Subject: [PATCH 4/7] Limit when release artifacts are built on forks: pt. 2 (#32494) * Limit when release artifacts are built on forks. Previously in #32114, adjustments were made to GHA workflow files to limit when workflows ran on forked repositories. But this missed the second job in the workflow that builds the release artifact. Because it was set to always run even though the previous job is required, it has continued to run on forks. * Ensure the artifact is built always, even when the preceding job does not run. (cherry picked from commit 8fbc4d617f6d85da7f5496e8d49e869c7ecca011) --- .github/workflows/build-plugin-zip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 94e5743082eaa..613d7c6c0479c 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -111,7 +111,7 @@ jobs: name: Build Release Artifact runs-on: ubuntu-latest needs: bump-version - if: always() + if: ${{ ( github.repository == 'WordPress/gutenberg' && always() ) || ( github.event_name == 'pull_request' && always() ) }} steps: - name: Checkout code From 87cd37883e0fbefc22aea0dee028d9b476a6fcd5 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Fri, 11 Jun 2021 07:00:33 -0400 Subject: [PATCH 5/7] Use a different cache key for the PR automation workflow (#32588) * Use a different cache key for the PR automation workflow. * Update the `chalk` dependency to the latest version. (cherry picked from commit 05ed04a83eba9aee6e68bb3cdd99bd3a788b6311) --- .github/workflows/pull-request-automation.yml | 6 ++++-- package-lock.json | 19 +++++++++---------- package.json | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pull-request-automation.yml b/.github/workflows/pull-request-automation.yml index 83cdff759f74b..f8df8babb5327 100644 --- a/.github/workflows/pull-request-automation.yml +++ b/.github/workflows/pull-request-automation.yml @@ -29,11 +29,13 @@ jobs: with: # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/.npm - key: ${{ runner.os }}-node-${{ matrix.node }}-npm-cache-${{ hashFiles('**/package-lock.json') }} + 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`. - - run: cd packages/project-management-automation && npm install + - name: Install NPM dependencies + run: npm install + working-directory: packages/project-management-automation - uses: ./packages/project-management-automation with: diff --git a/package-lock.json b/package-lock.json index 362747ddc9998..f369c8901aeca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25021,9 +25021,9 @@ "dev": true }, "chalk": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", - "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -25031,12 +25031,11 @@ }, "dependencies": { "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "requires": { - "@types/color-name": "^1.1.1", "color-convert": "^2.0.1" } }, @@ -25062,9 +25061,9 @@ "dev": true }, "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { "has-flag": "^4.0.0" diff --git a/package.json b/package.json index a3f1a9d769bbc..0d6fc3774c582 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "babel-plugin-transform-remove-console": "6.9.4", "benchmark": "2.1.4", "browserslist": "4.16.6", - "chalk": "4.0.0", + "chalk": "4.1.1", "commander": "4.1.0", "concurrently": "3.5.0", "copy-webpack-plugin": "5.1.2", From 5c2dbd26abe93c13e2c482bebdb3dcb8c559f4dc Mon Sep 17 00:00:00 2001 From: Adam Zielinski Date: Wed, 30 Jun 2021 16:25:57 +0200 Subject: [PATCH 6/7] Fix flaky widgets-related E2E tests (#33066) * Remove empty keys from the compared object * Revert dev artifacts * Disable the gutenberg-test-marquee-widget plugin * Wrap marquee tests in their own describe statement * Lint * Update snapshots * Replace hello with howdy * Move plugin activation to beforeEach * Move deleteAllWidgets to beforeEach * Update tests * use data-testid rather than name attribute selectors * Remove any existing marquees before running the tests, use the "save" form button * Remove dev artifact Co-authored-by: Kai Hao (cherry picked from commit 5cafe02e25f9a42d4abd7bf05857c006683ef023) --- .../plugins/marquee-function-widget.php | 20 +- .../specs/widgets/editing-widgets.test.js | 190 ++++++++++-------- 2 files changed, 115 insertions(+), 95 deletions(-) diff --git a/packages/e2e-tests/plugins/marquee-function-widget.php b/packages/e2e-tests/plugins/marquee-function-widget.php index 43b4f15661772..dda0c3f9a6e27 100644 --- a/packages/e2e-tests/plugins/marquee-function-widget.php +++ b/packages/e2e-tests/plugins/marquee-function-widget.php @@ -34,15 +34,17 @@ function() { $greeting = get_option( 'marquee_greeting' ); ?>

- - +

{ @@ -89,6 +89,12 @@ describe( 'Widgets screen', () => { ); expect( categoryHeaders.length > 0 ).toBe( true ); + const searchBox = await find( { + role: 'searchbox', + name: 'Search for blocks and patterns', + } ); + await searchBox.type( blockName ); + const addBlock = await find( { role: 'option', @@ -394,109 +400,123 @@ describe( 'Widgets screen', () => { ` ); } ); - async function addMarquee() { - // There will be 2 matches here. - // One is the in-between inserter, - // and the other one is the button block appender. - const [ inlineInserterButton ] = await findAll( { - role: 'combobox', - name: 'Add block', - } ); - await inlineInserterButton.click(); - - // TODO: Convert to find() API from puppeteer-testing-library. - const inserterSearchBox = await page.waitForSelector( - 'aria/Search for blocks and patterns[role="searchbox"]' - ); - await expect( inserterSearchBox ).toHaveFocus(); + describe( 'Function widgets', () => { + async function addMarquee( nbExpectedMarquees ) { + const marqueeBlock = await getBlockInGlobalInserter( + 'Marquee Greeting' + ); + await marqueeBlock.click(); + await page.waitForFunction( + ( expectedMarquees ) => { + return ( + document.querySelectorAll( + '[data-testid="marquee-greeting"]' + ).length === expectedMarquees + ); + }, + {}, + nbExpectedMarquees + ); + } - await page.keyboard.type( 'Marquee' ); + async function deleteExistingMarquees() { + const widgetAreasHoldingMarqueeWidgets = await page.$x( + '//input[@data-testid="marquee-greeting"]/ancestor::div[@aria-label="Block: Widget Area"]' + ); + for ( const widgetArea of widgetAreasHoldingMarqueeWidgets ) { + const closedPanelBody = await widgetArea.$( + '.components-panel__body:not(.is-opened)' + ); + if ( closedPanelBody ) { + await closedPanelBody.focus(); + await closedPanelBody.click(); + } - const inlineQuickInserter = await find( { - role: 'listbox', - name: 'Blocks', - } ); - const marqueeBlockOption = await find( - { - role: 'option', - }, - { - root: inlineQuickInserter, + const [ existingMarqueeWidgets ] = await widgetArea.$x( + '//input[@data-testid="marquee-greeting"]/ancestor::div[@data-block][contains(@class, "wp-block-legacy-widget")]' + ); + if ( existingMarqueeWidgets ) { + await existingMarqueeWidgets.focus(); + await pressKeyWithModifier( 'access', 'z' ); + } } - ); - await marqueeBlockOption.click(); - } - - it( 'Should add and save the marquee widget', async () => { - await activatePlugin( 'gutenberg-test-marquee-widget' ); - await visitAdminPage( 'widgets.php' ); + } - await addMarquee(); + beforeAll( async () => { + await activatePlugin( 'gutenberg-test-marquee-widget' ); + } ); - await find( { - selector: '[data-block][data-type="core/legacy-widget"]', + beforeEach( async () => { + await deleteExistingMarquees(); } ); - const greetingsInput = await find( { - selector: '#marquee-greeting', + afterAll( async () => { + await deactivatePlugin( 'gutenberg-test-marquee-widget' ); } ); - await greetingsInput.click(); - await page.keyboard.type( 'Howdy' ); - await saveWidgets(); + it( 'Should add and save the marquee widget', async () => { + await addMarquee( 1 ); - let editedSerializedWidgetAreas = await getSerializedWidgetAreas(); - await expect( editedSerializedWidgetAreas ).toMatchInlineSnapshot( ` - Object { - "sidebar-1": "Hello!", - } - ` ); + const [ marqueeInput ] = await page.$x( + '//input[@data-testid="marquee-greeting"]' + ); + await marqueeInput.focus(); + await marqueeInput.type( 'Howdy' ); - await page.reload(); + // The first marquee is saved after clicking the form save button. + const [ marqueeSaveButton ] = await marqueeInput.$x( + '//input/ancestor::div[@data-block][contains(@class, "wp-block-legacy-widget")]//button[@type="submit"]' + ); + await marqueeSaveButton.click(); - editedSerializedWidgetAreas = await getSerializedWidgetAreas(); - await expect( editedSerializedWidgetAreas ).toMatchInlineSnapshot( ` - Object { - "sidebar-1": "Hello!", - } - ` ); + await saveWidgets(); - // Add another marquee, it shouldn't be saved - await addMarquee(); + let editedSerializedWidgetAreas = await getSerializedWidgetAreas(); + await expect( editedSerializedWidgetAreas ).toMatchInlineSnapshot( ` + Object { + "sidebar-1": "Howdy", + } + ` ); - // It takes a moment to load the form, let's wait for it. - await waitFor( async () => { - const marquees = await findAll( { - selector: '[id=marquee-greeting]', - } ); - if ( marquees.length === 1 ) { - throw new Error(); + await page.reload(); + + editedSerializedWidgetAreas = await getSerializedWidgetAreas(); + await expect( editedSerializedWidgetAreas ).toMatchInlineSnapshot( ` + Object { + "sidebar-1": "Howdy", } - } ); + ` ); - const marquees = await findAll( { - selector: '[id=marquee-greeting]', - } ); + await addMarquee( 2 ); - expect( marquees ).toHaveLength( 2 ); - await marquees[ 1 ].click(); - await page.keyboard.type( 'Second howdy' ); + const marqueeInputs = await page.$$( + '[data-testid="marquee-greeting"]' + ); - await saveWidgets(); - editedSerializedWidgetAreas = await getSerializedWidgetAreas(); - await expect( editedSerializedWidgetAreas ).toMatchInlineSnapshot( ` - Object { - "sidebar-1": "Hello!", - } - ` ); + expect( marqueeInputs ).toHaveLength( 2 ); + await marqueeInputs[ 0 ].focus(); + await marqueeInputs[ 0 ].type( 'first howdy' ); + + await marqueeInputs[ 1 ].focus(); + await marqueeInputs[ 1 ].type( 'Second howdy' ); + + // No marquee should be changed without clicking on their "save" button. + // The second marquee shouldn't be stored as a widget. + // See #32978 for more info. + await saveWidgets(); + editedSerializedWidgetAreas = await getSerializedWidgetAreas(); + await expect( editedSerializedWidgetAreas ).toMatchInlineSnapshot( ` + Object { + "sidebar-1": "Howdy", + } + ` ); - await page.reload(); - const marqueesAfter = await findAll( { - selector: '[id=marquee-greeting]', + await page.reload(); + const marqueesAfter = await findAll( { + selector: '[data-testid="marquee-greeting"]', + } ); + expect( marqueesAfter ).toHaveLength( 1 ); } ); - expect( marqueesAfter ).toHaveLength( 1 ); - - await deactivatePlugin( 'gutenberg-test-marquee-widget' ); } ); // Disable reason: We temporary skip this test until we can figure out why it fails sometimes. @@ -528,7 +548,6 @@ describe( 'Widgets screen', () => { "sidebar-1": "

First Paragraph

", - "wp_inactive_widgets": "", } ` ); const initialWidgets = await getWidgetAreaWidgets(); @@ -599,7 +618,6 @@ describe( 'Widgets screen', () => {

First Paragraph

", - "wp_inactive_widgets": "", } ` ); const editedWidgets = await getWidgetAreaWidgets(); From 5e9e6bfdba72f7f213af5d0a67ffd591e3a38d02 Mon Sep 17 00:00:00 2001 From: Kerry Liu Date: Tue, 29 Jun 2021 12:44:37 -0700 Subject: [PATCH 7/7] Navigation: skip flakey tests (#33074) (cherry picked from commit 4d0959e2dc956a9e40a4e04db3029f26832c4d70) --- .../e2e-tests/specs/experiments/blocks/navigation.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/e2e-tests/specs/experiments/blocks/navigation.test.js b/packages/e2e-tests/specs/experiments/blocks/navigation.test.js index cc970c75eee15..6bdc30e4a107b 100644 --- a/packages/e2e-tests/specs/experiments/blocks/navigation.test.js +++ b/packages/e2e-tests/specs/experiments/blocks/navigation.test.js @@ -532,7 +532,9 @@ describe( 'Navigation', () => { expect( await getEditedPostContent() ).toMatchSnapshot(); } ); - it( 'loads frontend code only if the block is present', async () => { + // The following tests are unstable, roughly around when https://github.com/WordPress/wordpress-develop/pull/1412 + // landed. The block manually tests well, so let's skip to unblock other PRs and immediately follow up. cc @vcanales + it.skip( 'loads frontend code only if the block is present', async () => { // Mock the response from the Pages endpoint. This is done so that the pages returned are always // consistent and to test the feature more rigorously than the single default sample page. await mockPagesResponse( [ @@ -588,7 +590,7 @@ describe( 'Navigation', () => { expect( tagCount ).toBe( 1 ); } ); - it( 'loads frontend code only if responsiveness is turned on', async () => { + it.skip( 'loads frontend code only if responsiveness is turned on', async () => { await mockPagesResponse( [ { title: 'Home',