WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/06/2021 01:12:13 PM (7 months ago)
Author:
desrosj
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/test-npm.yml

    r50930 r51341  
    4343  # - Logs debug information about the runner container.
    4444  # - Installs NodeJS 14.
    45   # - Sets up caching for NPM.
    4645  # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
    4746  # - Builds WordPress to run from the `build` directory.
     
    7170
    7271      - name: Install NodeJS
    73         uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
     72        uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
    7473        with:
    7574          node-version: 14
    76 
    77       - name: Cache NodeJS modules (Ubuntu & MacOS)
    78         uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    79         if: ${{ matrix.os != 'windows-latest' }}
    80         with:
    81           path: ~/.npm
    82           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    83 
    84       - name: Get NPM cache directory (Windows only)
    85         if: ${{ matrix.os == 'windows-latest' }}
    86         id: npm-cache
    87         run: echo "::set-output name=dir::$(npm config get cache)"
    88 
    89       - name: Cache NodeJS modules (Windows only)
    90         uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    91         if: ${{ matrix.os == 'windows-latest' }}
    92         with:
    93           path: ${{ steps.npm-cache.outputs.dir }}
    94           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
     75          cache: npm
    9576
    9677      - name: Install Dependencies
     
    11798  # - Logs debug information about the runner container.
    11899  # - Installs NodeJS 14.
    119   # - Sets up caching for NPM.
    120100  # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
    121101  # - Builds WordPress to run from the `build` directory.
     
    140120
    141121      - name: Install NodeJS
    142         uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
     122        uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
    143123        with:
    144124          node-version: 14
    145 
    146       - name: Cache NodeJS modules
    147         uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    148         if: ${{ matrix.os != 'windows-latest' }}
    149         with:
    150           path: ~/.npm
    151           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
     125          cache: npm
    152126
    153127      - name: Install Dependencies
Note: See TracChangeset for help on using the changeset viewer.