From 30a43cfbc6a9284d2df9203d2cd7743771439f7d Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Tue, 6 Jul 2021 09:02:40 -0400 Subject: [PATCH] Use NPM caching built into action/setup-node (#33190) As of version 2.2.2, caching for NPM dependencies is now built into the `action/setup-action` action. See https://github.blog/changelog/2021-07-02-github-actions-setup-node-now-supports-dependency-caching/ for more information. * Consistently include an empty line before `steps`. * Continue using the old caching method for the pull request workflow. The `npm install` runs for a separate directory, which could cause a very small subset of packages to be cached. (cherry picked from commit 138d5f1) --- .github/workflows/build-plugin-zip.yml | 10 ++---- .github/workflows/bundle-size.yml | 11 ++----- .github/workflows/create-block.yml | 12 ++----- .github/workflows/end2end-test.yml | 10 ++---- .github/workflows/performance.yml | 10 ++---- .github/workflows/pull-request-automation.yml | 2 +- .github/workflows/rnmobile-android-runner.yml | 10 ++---- .github/workflows/rnmobile-ios-runner.yml | 10 ++---- .github/workflows/stale-issue-needs-info.yml | 1 + .github/workflows/static-checks.yml | 10 ++---- .github/workflows/storybook-pages.yml | 10 ++---- .github/workflows/unit-test.yml | 32 ++++--------------- .../upload-release-to-plugin-repo.yml | 1 + 13 files changed, 30 insertions(+), 99 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index dc70de859ca3a..fe5b8839f6548 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -29,16 +29,10 @@ jobs: uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - 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-14-npm-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - 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 56b45f6a7e1aa..cfec55e9b48c0 100644 --- a/.github/workflows/bundle-size.yml +++ b/.github/workflows/bundle-size.yml @@ -38,22 +38,17 @@ jobs: strategy: matrix: node: ['14'] + steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 with: fetch-depth: 1 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 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-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - 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 940d278f9149b..180c91177362e 100644 --- a/.github/workflows/create-block.yml +++ b/.github/workflows/create-block.yml @@ -34,16 +34,10 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 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-cache-${{ hashFiles('**/package-lock.json') }} + node-version: ${{ matrix.node }} + cache: npm - name: npm install, build, format and lint run: | diff --git a/.github/workflows/end2end-test.yml b/.github/workflows/end2end-test.yml index 2970a66bfb8cf..0fac10c4be061 100644 --- a/.github/workflows/end2end-test.yml +++ b/.github/workflows/end2end-test.yml @@ -34,16 +34,10 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 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-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Npm install and build run: | diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 749e44c10c384..77090d2d65335 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -24,16 +24,10 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - 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-14-npm-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Npm install run: | diff --git a/.github/workflows/pull-request-automation.yml b/.github/workflows/pull-request-automation.yml index f8df8babb5327..064a4380707db 100644 --- a/.github/workflows/pull-request-automation.yml +++ b/.github/workflows/pull-request-automation.yml @@ -20,7 +20,7 @@ jobs: ref: trunk - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: ${{ matrix.node }} diff --git a/.github/workflows/rnmobile-android-runner.yml b/.github/workflows/rnmobile-android-runner.yml index 102b9ade416bc..91a7f94c22a71 100644 --- a/.github/workflows/rnmobile-android-runner.yml +++ b/.github/workflows/rnmobile-android-runner.yml @@ -30,16 +30,10 @@ jobs: uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 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-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - run: npm ci diff --git a/.github/workflows/rnmobile-ios-runner.yml b/.github/workflows/rnmobile-ios-runner.yml index 38585f7ca0ca9..5c8f4a77c43f4 100644 --- a/.github/workflows/rnmobile-ios-runner.yml +++ b/.github/workflows/rnmobile-ios-runner.yml @@ -30,16 +30,10 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 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-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - run: npm ci diff --git a/.github/workflows/stale-issue-needs-info.yml b/.github/workflows/stale-issue-needs-info.yml index 4651dd7c69347..397fcdcbbef58 100644 --- a/.github/workflows/stale-issue-needs-info.yml +++ b/.github/workflows/stale-issue-needs-info.yml @@ -7,6 +7,7 @@ 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 4f351ea1e455e..c800e6be62039 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -25,16 +25,10 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - 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-14-npm-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - 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 6a6803cc2c258..76762b853ca0b 100644 --- a/.github/workflows/storybook-pages.yml +++ b/.github/workflows/storybook-pages.yml @@ -20,16 +20,10 @@ jobs: ref: trunk - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 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-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Install Dependencies run: npm ci diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 265e53ef8408a..6acf7c3d92809 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -32,16 +32,10 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 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-cache-${{ hashFiles('**/package-lock.json') }} + node-version: ${{ matrix.node }} + cache: npm - name: Npm install and build # It's not necessary to run the full build, since Jest can interpret @@ -66,16 +60,10 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - 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-14-npm-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Npm install and build run: | @@ -107,16 +95,10 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Use desired version of NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - 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-14-npm-cache-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Npm install and build # It's not necessary to run the full build, since Jest can interpret diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 4ab536735f2cd..dc56015daa66a 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -16,6 +16,7 @@ jobs: SVN_USERNAME: ${{ secrets.svn_username }} SVN_PASSWORD: ${{ secrets.svn_password }} VERSION: ${{ github.event.release.name }} + steps: - name: Check out Gutenberg trunk from WP.org plugin repo run: svn checkout "$PLUGIN_REPO_URL/trunk"