Skip to content

Commit 8a35558

Browse files
author
Luca Forstner
authored
ci: Use Nx cache (#262)
1 parent 7bdc9af commit 8a35558

File tree

7 files changed

+87
-28
lines changed

7 files changed

+87
-28
lines changed

.github/workflows/checks.yml

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ jobs:
1818
node-version-file: "package.json"
1919
- name: Use dependency cache
2020
uses: actions/cache@v3
21-
id: cache
21+
id: dependency-cache
2222
with:
2323
path: "**/node_modules"
2424
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
25+
- name: Use build cache
26+
uses: actions/cache@v3
27+
with:
28+
path: .nxcache
29+
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
30+
restore-keys: |
31+
build-cache-key-${{ runner.os }}-
2532
- name: Install dependencies
2633
run: yarn --frozen-lockfile --ignore-engines
27-
if: steps.cache.outputs.cache-hit != 'true'
34+
if: steps.dependency-cache.outputs.cache-hit != 'true'
2835
- run: yarn build
2936

3037
type-check:
@@ -38,13 +45,20 @@ jobs:
3845
node-version-file: "package.json"
3946
- name: Use dependency cache
4047
uses: actions/cache@v3
41-
id: cache
48+
id: dependency-cache
4249
with:
4350
path: "**/node_modules"
4451
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
52+
- name: Use build cache
53+
uses: actions/cache@v3
54+
with:
55+
path: .nxcache
56+
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
57+
restore-keys: |
58+
build-cache-key-${{ runner.os }}-
4559
- name: Install dependencies
4660
run: yarn --frozen-lockfile --ignore-engines
47-
if: steps.cache.outputs.cache-hit != 'true'
61+
if: steps.dependency-cache.outputs.cache-hit != 'true'
4862
- run: yarn check:types
4963

5064
formatting-check:
@@ -57,13 +71,20 @@ jobs:
5771
node-version-file: "package.json"
5872
- name: Use dependency cache
5973
uses: actions/cache@v3
60-
id: cache
74+
id: dependency-cache
6175
with:
6276
path: "**/node_modules"
6377
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
78+
- name: Use build cache
79+
uses: actions/cache@v3
80+
with:
81+
path: .nxcache
82+
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
83+
restore-keys: |
84+
build-cache-key-${{ runner.os }}-
6485
- name: Install dependencies
6586
run: yarn --frozen-lockfile --ignore-engines
66-
if: steps.cache.outputs.cache-hit != 'true'
87+
if: steps.dependency-cache.outputs.cache-hit != 'true'
6788
- run: yarn check:formatting
6889

6990
test-unit:
@@ -77,13 +98,20 @@ jobs:
7798
node-version-file: "package.json"
7899
- name: Use dependency cache
79100
uses: actions/cache@v3
80-
id: cache
101+
id: dependency-cache
81102
with:
82103
path: "**/node_modules"
83104
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
105+
- name: Use build cache
106+
uses: actions/cache@v3
107+
with:
108+
path: .nxcache
109+
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
110+
restore-keys: |
111+
build-cache-key-${{ runner.os }}-
84112
- name: Install dependencies
85113
run: yarn --frozen-lockfile --ignore-engines
86-
if: steps.cache.outputs.cache-hit != 'true'
114+
if: steps.dependency-cache.outputs.cache-hit != 'true'
87115
- run: yarn test:unit
88116

89117
test-integration:
@@ -110,13 +138,20 @@ jobs:
110138
node-version: ${{ matrix.node-version }}
111139
- name: Use dependency cache
112140
uses: actions/cache@v3
113-
id: cache
141+
id: dependency-cache
114142
with:
115143
path: "**/node_modules"
116144
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
145+
- name: Use build cache
146+
uses: actions/cache@v3
147+
with:
148+
path: .nxcache
149+
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
150+
restore-keys: |
151+
build-cache-key-${{ runner.os }}-
117152
- name: Install dependencies
118153
run: yarn --frozen-lockfile --ignore-engines
119-
if: steps.cache.outputs.cache-hit != 'true'
154+
if: steps.dependency-cache.outputs.cache-hit != 'true'
120155
- run: yarn test:integration
121156

122157
test-e2e:
@@ -136,13 +171,20 @@ jobs:
136171
- uses: volta-cli/action@v3
137172
- name: Use dependency cache
138173
uses: actions/cache@v3
139-
id: cache
174+
id: dependency-cache
140175
with:
141176
path: "**/node_modules"
142177
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
178+
- name: Use build cache
179+
uses: actions/cache@v3
180+
with:
181+
path: .nxcache
182+
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
183+
restore-keys: |
184+
build-cache-key-${{ runner.os }}-
143185
- name: Install dependencies
144186
run: yarn --frozen-lockfile --ignore-engines
145-
if: steps.cache.outputs.cache-hit != 'true'
187+
if: steps.dependency-cache.outputs.cache-hit != 'true'
146188
- run: yarn test:e2e
147189

148190
lint:
@@ -156,13 +198,20 @@ jobs:
156198
node-version-file: "package.json"
157199
- name: Use dependency cache
158200
uses: actions/cache@v3
159-
id: cache
201+
id: dependency-cache
160202
with:
161203
path: "**/node_modules"
162204
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
205+
- name: Use build cache
206+
uses: actions/cache@v3
207+
with:
208+
path: .nxcache
209+
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
210+
restore-keys: |
211+
build-cache-key-${{ runner.os }}-
163212
- name: Install dependencies
164213
run: yarn --frozen-lockfile --ignore-engines
165-
if: steps.cache.outputs.cache-hit != 'true'
214+
if: steps.dependency-cache.outputs.cache-hit != 'true'
166215
- run: yarn lint
167216

168217
artifacts:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ yarn-error.log
33

44
.vscode/settings.json
55

6-
*.tgz
6+
*.tgz
7+
8+
.nxcache

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
packages/e2e-tests/scenarios/*/ref/**/*
2-
packages/bundler-plugin-core/test/fixtures
2+
packages/bundler-plugin-core/test/fixtures
3+
.nxcache

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
23
"version": "2.0.0",
3-
"packages": "packages/*",
44
"npmClient": "yarn",
55
"useWorkspaces": true
66
}

nx.json

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
{
2-
"extends": "nx/presets/npm.json",
32
"$schema": "./node_modules/nx/schemas/nx-schema.json",
4-
"affected": {
5-
"defaultBase": "main"
6-
},
73
"tasksRunnerOptions": {
84
"default": {
95
"runner": "nx/tasks-runners/default",
106
"options": {
117
"cacheableOperations": ["build", "lint", "test"],
12-
"parallel": 10
8+
"cacheDirectory": ".nxcache"
139
}
1410
}
1511
},
12+
"namedInputs": {
13+
"sharedGlobals": ["{workspaceRoot}/*.js", "{workspaceRoot}/*.json", "{workspaceRoot}/yarn.lock"]
14+
},
1615
"targetDefaults": {
1716
"build": {
18-
"dependsOn": ["^build"]
17+
"inputs": ["sharedGlobals"],
18+
"dependsOn": ["^build"],
19+
"outputs": ["{projectRoot}/dist"]
1920
},
2021
"lint": {
21-
"dependsOn": ["^build", "build"]
22+
"inputs": ["sharedGlobals"],
23+
"dependsOn": ["^build", "build"],
24+
"outputs": []
2225
},
2326
"test": {
24-
"dependsOn": ["^build"]
27+
"inputs": ["sharedGlobals"],
28+
"dependsOn": ["^build"],
29+
"outputs": []
2530
},
2631
"check:types": {
27-
"dependsOn": ["^build"]
32+
"inputs": ["sharedGlobals"],
33+
"dependsOn": ["^build"],
34+
"outputs": []
2835
},
2936
"build:npm": {
3037
"dependsOn": ["build", "^build"]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@nrwl/cli": "14.5.10",
3131
"@nrwl/workspace": "14.5.10",
3232
"husky": "^8.0.0",
33-
"lerna": "^6.0.1",
33+
"lerna": "^6.6.2",
3434
"nx": "14.5.10",
3535
"prettier": "^2.7.1",
3636
"pretty-quick": "^3.1.3",

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8080,7 +8080,7 @@ kleur@^3.0.3:
80808080
resolved "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
80818081
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==
80828082

8083-
lerna@^6.0.1:
8083+
lerna@^6.6.2:
80848084
version "6.6.2"
80858085
resolved "https://registry.npmjs.org/lerna/-/lerna-6.6.2.tgz#ad921f913aca4e7307123a598768b6f15ca5804f"
80868086
integrity sha512-W4qrGhcdutkRdHEaDf9eqp7u4JvI+1TwFy5woX6OI8WPe4PYBdxuILAsvhp614fUG41rKSGDKlOh+AWzdSidTg==

0 commit comments

Comments
 (0)