Skip to content

Commit

Permalink
chore: setup the workflows to cache (#977)
Browse files Browse the repository at this point in the history
* chore: setup the workflows to cache
Added caching of `node_modules` when nothing has changed in any `package.json`
also using the `setup-node` built-in cache of `~/.npm` which will speed up `npm ci` when it has to run

* Added `restore-keys` for direct reference to cached resources per runner
  • Loading branch information
JacobMGEvans authored May 15, 2022
1 parent 9906e1c commit 02a2cae
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/create-pullrequest-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.7
cache: "npm"
cache: "npm" # cache ~/.npm in case 'npm ci' needs to run

- uses: actions/cache@v3
id: node-modules-cache
Expand All @@ -29,7 +29,8 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: Install NPM Dependencies
run: npm install
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Modify package.json version
run: node .github/version-script.js
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/experimental-wasm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.7
cache: "npm"
cache: "npm" # cache ~/.npm in case 'npm ci' needs to run

- uses: actions/cache@v3
id: node-modules-cache
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install NPM Dependencies
run: npm ci
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/prereleases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.7
cache: "npm"
cache: "npm" # cache ~/.npm in case 'npm ci' needs to run

- uses: actions/cache@v3
id: node-modules-cache
Expand All @@ -31,7 +31,8 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: Install NPM Dependencies
run: npm install
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Modify package.json version
run: node .github/version-script.js
Expand Down Expand Up @@ -65,7 +66,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.7
cache: "npm"
cache: "npm" # cache ~/.npm in case 'npm ci' needs to run

- uses: actions/cache@v3
id: node-modules-cache
Expand All @@ -76,7 +77,8 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: Install NPM Dependencies
run: npm install
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Build wrangler
run: npm run build
Expand Down
26 changes: 24 additions & 2 deletions .github/workflows/pullrequests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.7
cache: "npm"
cache: "npm" # cache ~/.npm in case 'npm ci' needs to run

- uses: actions/cache@v3
id: eslint-cache
Expand All @@ -29,7 +29,18 @@ jobs:
tsconfig.tsbuildinfo
key: ${{ matrix.os }}-eslint-tsbuildinfo-${{ hashFiles('**/*.ts','**/*.js', 'package.json', 'tsconfig.json') }}

- uses: actions/cache@v3
id: node-modules-cache
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install NPM Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Check for errors
Expand All @@ -51,7 +62,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.7
cache: "npm"
cache: "npm" # cache ~/.npm in case 'npm ci' needs to run

- name: Restore Wrangler 1 from Cache
uses: actions/cache@v3
Expand All @@ -60,7 +71,18 @@ jobs:
path: packages/wranglerjs-compat-webpack-plugin/src/__tests__/helpers/.wrangler-1-cache
key: ${{ matrix.os }}-wrangler-1-cache

- uses: actions/cache@v3
id: node-modules-cache
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install NPM Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Run builds
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.7
cache: "npm"
cache: "npm" # cache ~/.npm in case 'npm ci' needs to run

- uses: actions/cache@v3
id: node-modules-cache
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install NPM Dependencies
run: npm install
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Check for errors
run: npm run check
Expand Down

0 comments on commit 02a2cae

Please sign in to comment.