Skip to content

Commit 3575a52

Browse files
committed
ci: cache only 'node_modules' without 'out'
Source code files ('.ts') depends on multiple files (not only .ts files, but package.json, tsconfig.json, etc...), so in order not to complicate things a lot we just build src files again.
1 parent 8d3552b commit 3575a52

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

.github/workflows/testing.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,25 @@ jobs:
1515
with:
1616
node-version: '20.x'
1717
cache: 'npm'
18-
- name: Build extension
18+
- name: Restore node_modules from cache
19+
id: restore-node-modules
20+
uses: actions/cache/restore@v4
21+
with:
22+
path: node_modules
23+
key: node_modules-${{ hashFiles('package-lock.json') }}
24+
- name: Install node_modules
25+
if: steps.restore-node-modules.outputs.cache-hit != 'true'
1926
run: |
2027
npm i
2128
npm i -D
22-
npm run compile
29+
- name: Store node_modules to cache
30+
uses: actions/cache/save@v4
31+
if: steps.restore-node-modules.outputs.cache-hit != 'true'
32+
with:
33+
path: node_modules
34+
key: ${{ steps.restore-node-modules.outputs.cache-primary-key }}
35+
- name: Build extension
36+
run: npm run compile
2337
- name: Run linter
2438
run: npm run lint
2539

@@ -33,14 +47,14 @@ jobs:
3347
steps:
3448
- name: Setup repository
3549
uses: actions/checkout@v4
36-
- name: Restore cache
50+
- name: Restore node_modules
3751
uses: actions/cache/restore@v4
3852
with:
39-
path: |
40-
node_modules
41-
out
42-
key: cache-${{ runner.os }}-${{ hashFiles('src/**/*.ts') }}
53+
path: node_modules
54+
key: node_modules-${{ hashFiles('package-lock.json') }}
4355
fail-on-cache-miss: true
56+
- name: Build extension
57+
run: npm run compile
4458
- name: Setup NodeJS
4559
uses: actions/setup-node@v4
4660
with:

0 commit comments

Comments
 (0)