Skip to content

Commit

Permalink
Speedy ci cache
Browse files Browse the repository at this point in the history
  • Loading branch information
toebeann committed Oct 24, 2022
1 parent bc77445 commit 0766d77
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 76 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/npm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
branches: ["main"]
paths:
[
"*.ts",
"jest.config.js?(on)",
"**.ts",
"jest.config.js*",
"package-lock.json",
".github/workflows/npm-test.yml",
]
Expand All @@ -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
Expand Down
26 changes: 6 additions & 20 deletions .github/workflows/publish-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
branches: ["main"]
paths:
[
"*.ts",
"jest.config.js?(on)",
"**.ts",
"jest.config.js*",
".github/workflows/publish-code-coverage.yml",
]
workflow_dispatch:
Expand All @@ -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
Expand Down
22 changes: 4 additions & 18 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 4 additions & 18 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0766d77

Please sign in to comment.