From 0c25dca719475585359db967f7605d247e81481a Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 6 Jul 2021 13:12:13 +0000 Subject: [PATCH] Build/Test Tools: Use caching built into `actions/setup-node`. This updates the `actions/setup-node` action to version 2.2.2 and takes advantage of the cache feature now built in. This removes the need for an additional step using `actions/cache` to cache NPM dependencies. The cache key used will be `${{ runner.os }}-npm-${{ hashFiles('') }}`, which matches the recommendation in the `actions/cache` documentation and the key currently in use in the WordPress workflows. Props gziolo. Fixes #53584. git-svn-id: https://develop.svn.wordpress.org/trunk@51341 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/coding-standards.yml | 13 ++-------- .github/workflows/end-to-end-tests.yml | 13 ++-------- .github/workflows/javascript-tests.yml | 13 ++-------- .github/workflows/phpunit-tests.yml | 13 ++-------- .github/workflows/test-coverage.yml | 13 ++-------- .github/workflows/test-npm.yml | 34 +++----------------------- 6 files changed, 14 insertions(+), 85 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 7f04b14183..bd260800ca 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -102,7 +102,6 @@ jobs: # - Checks out the repository. # - Logs debug information about the runner container. # - Installs NodeJS 14. - # - Sets up caching for NPM. # - Logs updated debug information. # _ Installs NPM dependencies using install-changed to hash the `package.json` file. # - Run the WordPress JSHint checks. @@ -126,18 +125,10 @@ jobs: svn --version - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - name: Cache NodeJS modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Log debug information run: | diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index 2be14d9a2c..c3f1f09ecf 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -37,7 +37,6 @@ jobs: # - Checks out the repository. # - Logs debug information about the runner container. # - Installs NodeJS 14. - # - Sets up caching for NPM. # _ Installs NPM dependencies using install-changed to hash the `package.json` file. # - Builds WordPress to run from the `build` directory. # - Starts the WordPress Docker container. @@ -73,18 +72,10 @@ jobs: locale -a - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - name: Cache NodeJS modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Install Dependencies run: npm ci diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index 335812b61f..d5ad21c0e7 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -46,7 +46,6 @@ jobs: # - Checks out the repository. # - Logs debug information about the runner container. # - Installs NodeJS 14. - # - Sets up caching for NPM. # - Logs updated debug information. # _ Installs NPM dependencies using install-changed to hash the `package.json` file. # - Run the WordPress QUnit tests. @@ -68,18 +67,10 @@ jobs: svn --version - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - name: Cache NodeJS modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Log debug information run: | diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 1fd865823f..f57316fcb9 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -43,7 +43,6 @@ jobs: # - Set environment variables. # - Sets up the environment variables needed for testing with memcached (if desired). # - Installs NodeJS 14. - # - Sets up caching for NPM. # - Installs NPM dependencies # - Configures caching for Composer. # - Installs Composer dependencies (if desired). @@ -114,18 +113,10 @@ jobs: uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - name: Use cached Node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Install Dependencies run: npm ci diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index abdc989681..67a53c4a0b 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -34,7 +34,6 @@ jobs: # - Checks out the WordPress Importer plugin (needed for the Core PHPUnit tests). # - Logs debug information about the runner container. # - Installs NodeJS 14. - # - Sets up caching for NPM. # _ Installs NPM dependencies using install-changed to hash the `package.json` file. # - Logs Docker debug information (about the Docker installation within the runner). # - Starts the WordPress Docker container. @@ -79,18 +78,10 @@ jobs: locale -a - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - name: Cache NodeJS modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Install Dependencies run: npm ci diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index ce16cb2815..c806e13c55 100644 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -42,7 +42,6 @@ jobs: # - Checks out the repository. # - Logs debug information about the runner container. # - Installs NodeJS 14. - # - Sets up caching for NPM. # _ Installs NPM dependencies using install-changed to hash the `package.json` file. # - Builds WordPress to run from the `build` directory. # - Cleans up after building WordPress to the `build` directory. @@ -70,28 +69,10 @@ jobs: svn --version - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - name: Cache NodeJS modules (Ubuntu & MacOS) - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - if: ${{ matrix.os != 'windows-latest' }} - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - - - name: Get NPM cache directory (Windows only) - if: ${{ matrix.os == 'windows-latest' }} - id: npm-cache - run: echo "::set-output name=dir::$(npm config get cache)" - - - name: Cache NodeJS modules (Windows only) - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - if: ${{ matrix.os == 'windows-latest' }} - with: - path: ${{ steps.npm-cache.outputs.dir }} - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Install Dependencies run: npm ci @@ -116,7 +97,6 @@ jobs: # - Checks out the repository. # - Logs debug information about the runner container. # - Installs NodeJS 14. - # - Sets up caching for NPM. # _ Installs NPM dependencies using install-changed to hash the `package.json` file. # - Builds WordPress to run from the `build` directory. # - Cleans up after building WordPress to the `build` directory. @@ -139,16 +119,10 @@ jobs: svn --version - name: Install NodeJS - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2 with: node-version: 14 - - - name: Cache NodeJS modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - if: ${{ matrix.os != 'windows-latest' }} - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + cache: npm - name: Install Dependencies run: npm ci