Skip to content

Commit

Permalink
chore: simplify unit test cache
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Aug 27, 2021
1 parent 4ff1c6c commit edceb8d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 60 deletions.
28 changes: 7 additions & 21 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,17 @@ jobs:
with:
args: "./**/*.md -i ./CHANGELOG.md"

- name: restore lock files
uses: actions/cache@master # must use unreleased master to cache multiple paths
- name: restore lerna
id: cache
uses: actions/cache@v2
with:
# must be done before bootstrap to not include node_modules files in the cache paths
path: |
package-lock.json
packages/*/package-lock.json
benchmark/*/package-lock.json
backwards-compatability/*/package-lock.json
metapackages/*/package-lock.json
packages/*/package-lock.json
integration-tests/*/package-lock.json
# increment the trailing number to break the cache manually
key: ${{ runner.os }}-lint-${{ hashFiles('**/package.json') }}-0
node_modules
*/*/node_modules
key: lint-${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('**/package.json') }}

# On a cache hit, use ci to speed up the install process
- name: Bootstrap (cache hit)
if: steps.cache.outputs.cache-hit == 'true'
run: |
npm ci --ignore-scripts
npx lerna bootstrap --ignore-scripts --hoist --nohoist='zone.js'
# On a cache miss, fall back to a regular install
- name: Bootstrap (cache miss)
# On a cache miss, install dependencies
- name: Bootstrap
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install --ignore-scripts
Expand Down
57 changes: 18 additions & 39 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,23 @@ jobs:
with:
node-version: ${{ matrix.node_version }}

- name: restore lock files
uses: actions/cache@master # must use unreleased master to cache multiple paths
- name: restore lerna
id: cache
uses: actions/cache@v2
with:
# must be done before bootstrap to not include node_modules files in the cache paths
path: |
package-lock.json
packages/*/package-lock.json
benchmark/*/package-lock.json
backwards-compatability/*/package-lock.json
metapackages/*/package-lock.json
packages/*/package-lock.json
integration-tests/*/package-lock.json
key: ${{ runner.os }}-unit_test-${{ matrix.node_version }}-${{ hashFiles('**/package.json') }}
- name: Install and Build (cache miss) 🔧
node_modules
*/*/node_modules
key: unittest-${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('**/package.json') }}

- name: Bootstrap
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install --ignore-scripts
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js'
npm run compile
- name: Install and Build (cache hit) 🔧
if: steps.cache.outputs.cache-hit == 'true'
run: |
npm ci --ignore-scripts
npx lerna bootstrap --hoist --nohoist='zone.js'
npm run compile
- name: Build 🔧
run: npm run compile

- name: Unit tests
run: npm run test
Expand All @@ -66,35 +56,24 @@ jobs:
uses: actions/checkout@v1
- name: Permission Setup
run: sudo chmod -R 777 /github /__w
- name: restore lock files
uses: actions/cache@master # must use unreleased master to cache multiple paths

- name: restore lerna
uses: actions/cache@v2
id: cache
with:
# must be done before bootstrap to not include node_modules files in the cache paths
path: |
package-lock.json
packages/*/package-lock.json
benchmark/*/package-lock.json
backwards-compatability/*/package-lock.json
metapackages/*/package-lock.json
packages/*/package-lock.json
integration-tests/*/package-lock.json
key: ${{ runner.os }}-unit_test-${{ matrix.container }}-${{ hashFiles('**/package.json') }}
node_modules
*/*/node_modules
key: unittest-${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('**/package.json') }}

- name: Install and Build (cache miss) 🔧
- name: Bootstrap
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install --ignore-scripts
npx lerna bootstrap --no-ci --hoist --nohoist='zone.js'
npm run compile
- name: Install and Build (cache hit) 🔧
if: steps.cache.outputs.cache-hit == 'true'
run: |
npm ci --ignore-scripts
npx lerna bootstrap --hoist --nohoist='zone.js'
npm run compile
- name: Build 🔧
run: npm run compile
- name: Unit tests
run: npm run test:browser
- name: Report Coverage
Expand Down

0 comments on commit edceb8d

Please sign in to comment.