Skip to content

Commit

Permalink
Backport several GitHub Action workflow improvements to wp/trunk (#…
Browse files Browse the repository at this point in the history
…33174)

* 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 23d84b3)

* Limit when workflows run on forks (#32114)

(cherry picked from commit 435dde4)

* 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 7e54162)

* 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 8fbc4d6)

* 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 05ed04a)

* 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 <kevin830726@gmail.com>
(cherry picked from commit 5cafe02)

* Navigation: skip flakey tests (#33074)

(cherry picked from commit 4d0959e)

Co-authored-by: Adam Zielinski <adam@adamziel.com>
Co-authored-by: Kerry Liu <gwwar@users.noreply.github.com>
  • Loading branch information
3 people authored and youknowriad committed Jul 5, 2021
1 parent f7e8546 commit 8ca431f
Show file tree
Hide file tree
Showing 19 changed files with 266 additions and 198 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/build-plugin-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' ||
Expand Down Expand Up @@ -110,26 +111,25 @@ 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
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
Expand Down Expand Up @@ -169,6 +169,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
Expand Down
39 changes: 35 additions & 4 deletions .github/workflows/bundle-size.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -13,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:
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/create-block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,26 @@ jobs:
checks:
name: Checks
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
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: |
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,28 @@ 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:
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: |
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,23 @@ concurrency:
jobs:
performance:
name: Run performance tests

runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' }}

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: |
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/pull-request-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,35 @@ name: Pull request automation
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).
- 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 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`.
- 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:
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,43 @@ concurrency:
jobs:
test:
runs-on: macos-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
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

- 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

- 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
packages/react-native-editor/ios/build/WDA
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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stale-issue-add-needs-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stale-issue-mark-stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stale-issue-needs-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,23 @@ 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

- 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
Expand Down
Loading

0 comments on commit 8ca431f

Please sign in to comment.