Skip to content

Commit 51ba7bc

Browse files
authored
ci(github-actions): ⚡ add caching of dependencies to improve test build times (#343)
* ci(github-actions): ⚡ add cache action to improve test build times Add caching of project root node_modules * ci: use caching config within actions/setup-node * test: add netlify build package to try and address failures in macOS test runner * ci: use netlify-cli as dep, not netlify/build * ci: add package-locks to test fixtures Update path in cache-dependency-path, didn't look to be correct * revert: "ci: add package-locks to test fixtures" This reverts commit ab8d9d1. * ci: revert back to 'npm ci' instead of 'npm install' * chore(deps): install netlify-cli globally within test runner * fix(deps): pin netlify/build package to previous version Unknown change has led to issues with the 'netlify build' command used in tests * ci: remove setting of cache 'npm ci' should be referencing it already * ci: add --prefer-offline flag to npm installs of test * ci: try to cache node_modules for the test fixtures Remove --prefer-offline flag as it didn't lead to an improvement * style: lint * ci: accidentally removed an install command * ci: 'run' accidentally snuck into the command * ci: run the macOS test runner on the main branch rather than on every branch * ci: modify conditional logic for syntax reasons * ci: use include rather than exclude mechanism also use ref_name from github context as it's a bit cleaner to read * style: lint * ci: move expression out of matrix * ci: last attempt at matrix config before breaking them into jobs * ci: transition from use of a matrix to jobs * style: lint * style: more lint * ci: remove node_version * ci: mac test job doesn't need to wait for ubuntu to complete
1 parent 302144c commit 51ba7bc

File tree

3 files changed

+12370
-11180
lines changed

3 files changed

+12370
-11180
lines changed

.github/workflows/test.yml

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,54 @@ on:
66
pull_request:
77

88
jobs:
9-
build:
10-
runs-on: ${{ matrix.os }}
11-
12-
strategy:
13-
matrix:
14-
os: [ubuntu-latest, macOS-latest] #, windows-latest] # TODO add an e2etest.bat file
15-
node-version: ['*']
16-
exclude:
17-
- os: macOS-latest
18-
node-version: 14.15.0
19-
# - os: windows-latest
20-
# node-version: 14.15.0
21-
fail-fast: false
9+
build-ubuntu:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: '*'
16+
- name: Global Node packages cache
17+
uses: actions/cache@v3
18+
with:
19+
path: ~/.npm
20+
key:
21+
ubuntu--build-${{ env.cache-name }}-${{
22+
hashFiles('**/package-lock.json') }}
23+
- name: Test fixture dependency cache
24+
uses: actions/cache@v3
25+
with:
26+
path: plugin/test/fixtures/**/node_modules
27+
key:
28+
ubuntu-build-${{ env.cache-name }}-${{
29+
hashFiles('plugin/test/fixtures/**/package.json') }}-node-modules
30+
- run: npm install -g netlify-cli
31+
- run: npm ci
32+
- run: cd plugin && npm ci && npm run build
33+
- run: npm test
2234

35+
build-mac:
36+
runs-on: macOS-latest
37+
if: github.ref_name == 'main'
2338
steps:
2439
- uses: actions/checkout@v3
25-
- name: Use Node.js ${{ matrix.node-version }}
26-
uses: actions/setup-node@v3
40+
- uses: actions/setup-node@v3
41+
with:
42+
node-version: '*'
43+
- name: Global Node packages cache
44+
uses: actions/cache@v3
45+
with:
46+
path: ~/.npm
47+
key:
48+
macOS-build-${{ env.cache-name }}-${{
49+
hashFiles('**/package-lock.json') }}
50+
- name: Test fixture dependency cache
51+
uses: actions/cache@v3
2752
with:
28-
node-version: ${{ matrix.node-version }}
29-
check-latest: '*'
53+
path: plugin/test/fixtures/**/node_modules
54+
key:
55+
macOS-build-${{ env.cache-name }}-${{
56+
hashFiles('plugin/test/fixtures/**/package.json') }}-node-modules
3057
- run: npm install -g netlify-cli
3158
- run: npm ci
3259
- run: cd plugin && npm ci && npm run build

0 commit comments

Comments
 (0)