Skip to content

Commit 8c9ec9a

Browse files
committed
chore: add compile cache to unit tests
1 parent 8fc8034 commit 8c9ec9a

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

.github/workflows/unit-test.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,26 @@ on:
55
pull_request:
66

77
jobs:
8+
build-with-cache:
9+
strategy:
10+
fail-fast: false
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 16
20+
- name: Install
21+
run: npm ci
22+
- name: Build with Cache
23+
run: |
24+
echo "setting cache dir to $(npm get cache)/$GITHUB_REF_NAME"
25+
NX_CACHE_DIRECTORY=$(npm get cache)/$GITHUB_REF_NAME npm run compile
826
unit-test:
27+
needs: build-with-cache
928
strategy:
1029
fail-fast: false
1130
matrix:
@@ -129,7 +148,7 @@ jobs:
129148
- name: Install
130149
run: npm ci
131150
- name: Build
132-
run: npm run compile
151+
run: npm run compile:ci
133152
- name: Unit tests (Full)
134153
if: matrix.code-coverage
135154
run: npm run test
@@ -145,6 +164,7 @@ jobs:
145164
verbose: true
146165

147166
browser-test:
167+
needs: build-with-cache
148168
strategy:
149169
fail-fast: false
150170
matrix:
@@ -167,7 +187,7 @@ jobs:
167187
- name: Install
168188
run: npm ci
169189
- name: Build
170-
run: npm run compile
190+
run: npm run compile:ci
171191
- name: Unit tests
172192
run: npm run test:browser
173193
- name: Report Coverage
@@ -176,3 +196,13 @@ jobs:
176196
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
177197
with:
178198
verbose: true
199+
empty-cache:
200+
needs: [unit-test, browser-test]
201+
strategy:
202+
fail-fast: false
203+
runs-on: ubuntu-latest
204+
steps:
205+
- name: Clear Build Cache
206+
run: |
207+
echo "deleting cache dir $(npm get cache)/$GITHUB_REF_NAME"
208+
rm -rf $(npm get cache)/$GITHUB_REF_NAME

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)