From 889aead31afcd993a4b4bafb22079cd4bbc5c657 Mon Sep 17 00:00:00 2001 From: Tobey Blaber Date: Mon, 24 Oct 2022 13:09:58 +0100 Subject: [PATCH] Speedy node_modules cache --- .github/workflows/npm-test.yml | 24 +++++---------------- .github/workflows/publish-code-coverage.yml | 22 ++++--------------- .github/workflows/publish-docs.yml | 22 ++++--------------- .github/workflows/publish-package.yml | 22 ++++--------------- 4 files changed, 17 insertions(+), 73 deletions(-) diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index 9110419..dabf543 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -21,7 +21,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - version: [lts/*] + version: [lts/*, latest] steps: - name: Checkout repository @@ -32,29 +32,15 @@ jobs: with: node-version: ${{ matrix.version }} - - name: Get npm cache directory - id: npm-cache - run: echo "::set-output name=dir::$(npm config get cache)" - - name: Cache node_modules - id: cache-npm + id: cache uses: actions/cache@v3 - env: - cache-name: cache-node-modules with: - path: ${{ steps.npm-cache.outputs.dir }} - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - name: List the state of node modules - continue-on-error: true - run: npm list + path: ./node_modules + key: ${{ runner.os }}-${{ matrix.version }}-build-node-modules-${{ hashFiles('**/package-lock.json') }} - name: Install dependencies + if: ${{ steps.cache.outputs.cache-hit != 'true' }} run: npm ci - name: Run tests diff --git a/.github/workflows/publish-code-coverage.yml b/.github/workflows/publish-code-coverage.yml index 0e5d1f7..d961138 100644 --- a/.github/workflows/publish-code-coverage.yml +++ b/.github/workflows/publish-code-coverage.yml @@ -23,29 +23,15 @@ jobs: with: node-version: lts/* - - name: Get npm cache directory - id: npm-cache - run: echo "::set-output name=dir::$(npm config get cache)" - - name: Cache node_modules - id: cache-npm + id: cache uses: actions/cache@v3 - env: - cache-name: cache-node-modules with: - path: ${{ steps.npm-cache.outputs.dir }} - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - name: List the state of node modules - continue-on-error: true - run: npm list + path: ./node_modules + key: ${{ runner.os }}-lts/*-build-node-modules-${{ hashFiles('**/package-lock.json') }} - name: Install dependencies + if: ${{ steps.cache.outputs.cache-hit != 'true' }} run: npm ci - name: Generate code coverage reports diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 2a6a91d..a595921 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -30,29 +30,15 @@ jobs: with: node-version: lts/* - - name: Get npm cache directory - id: npm-cache - run: echo "::set-output name=dir::$(npm config get cache)" - - name: Cache node_modules - id: cache-npm + id: cache uses: actions/cache@v3 - env: - cache-name: cache-node-modules with: - path: ${{ steps.npm-cache.outputs.dir }} - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - name: List the state of node modules - continue-on-error: true - run: npm list + path: ./node_modules + key: ${{ runner.os }}-lts/*-build-node-modules-${{ hashFiles('**/package-lock.json') }} - name: Install dependencies + if: ${{ steps.cache.outputs.cache-hit != 'true' }} run: npm ci - name: Generate API reference diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 108f583..1d50420 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -17,29 +17,15 @@ jobs: with: node-version: lts/* - - name: Get npm cache directory - id: npm-cache - run: echo "::set-output name=dir::$(npm config get cache)" - - name: Cache node_modules - id: cache-npm + id: cache uses: actions/cache@v3 - env: - cache-name: cache-node-modules with: - path: ${{ steps.npm-cache.outputs.dir }} - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - name: List the state of node modules - continue-on-error: true - run: npm list + path: ./node_modules + key: ${{ runner.os }}-lts/*-build-node-modules-${{ hashFiles('**/package-lock.json') }} - name: Install dependencies + if: ${{ steps.cache.outputs.cache-hit != 'true' }} run: npm ci - name: Run tests