@samitouri / QOS-React / commits / 4eba294c69

[ci] Cache runtime and compiler only for test runs (#32608)

We only need the compiler built for `yarn test` in the root directory. Rather than always cache both for every step, let's just do it where it's needed explicitly. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32608). * #32609 * __->__ #32608

lauren committed Mar 13, 2025 at 22:21 UTC 4eba294c69422ade02f2bb4d6a0255755b406b32
4 files changed +36 -21
.github/workflows/runtime_build_and_test.yml
+29 -17
@@ -56,7 +56,7 @@ jobs:
56 id: node_modules
57 with:
58 path: "**/node_modules"
59 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
59 + key: runtime-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
60 - name: Ensure clean build directory
61 run: rm -rf build
62 - run: yarn install --frozen-lockfile
@@ -80,7 +80,7 @@ jobs:
80 id: node_modules
81 with:
82 path: "**/node_modules"
83 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
83 + key: runtime-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
84 - name: Ensure clean build directory
85 run: rm -rf build
86 - run: yarn install --frozen-lockfile
@@ -106,7 +106,7 @@ jobs:
106 id: node_modules
107 with:
108 path: "**/node_modules"
109 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
109 + key: runtime-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
110 - name: Ensure clean build directory
111 run: rm -rf build
112 - run: yarn install --frozen-lockfile
@@ -153,16 +153,20 @@ jobs:
153 with:
154 node-version-file: '.nvmrc'
155 cache: yarn
156 - cache-dependency-path: yarn.lock
156 + cache-dependency-path: |
157 + yarn.lock
158 + compiler/yarn.lock
159 - name: Restore cached node_modules
160 uses: actions/cache@v4
161 id: node_modules
162 with:
163 path: "**/node_modules"
162 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
164 + key: runtime-and-compiler-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'compiler/yarn.lock') }}
165 - name: Ensure clean build directory
166 run: rm -rf build
167 - run: yarn install --frozen-lockfile
168 + - run: yarn install --frozen-lockfile
169 + working-directory: compiler
170 - run: yarn test ${{ matrix.params }} --ci --shard=${{ matrix.shard }}
171
172 # ----- BUILD -----
@@ -183,7 +187,9 @@ jobs:
187 with:
188 node-version-file: '.nvmrc'
189 cache: yarn
186 - cache-dependency-path: yarn.lock
190 + cache-dependency-path: |
191 + yarn.lock
192 + compiler/yarn.lock
193 - uses: actions/setup-java@v4
194 with:
195 distribution: temurin
@@ -193,10 +199,12 @@ jobs:
199 id: node_modules
200 with:
201 path: "**/node_modules"
196 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
202 + key: runtime-and-compiler-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'compiler/yarn.lock') }}
203 - name: Ensure clean build directory
204 run: rm -rf build
205 - run: yarn install --frozen-lockfile
206 + - run: yarn install --frozen-lockfile
207 + working-directory: compiler
208 - run: yarn build --index=${{ matrix.worker_id }} --total=20 --r=${{ matrix.release_channel }} --ci
209 env:
210 CI: github
@@ -261,16 +269,20 @@ jobs:
269 with:
270 node-version-file: '.nvmrc'
271 cache: yarn
264 - cache-dependency-path: yarn.lock
272 + cache-dependency-path: |
273 + yarn.lock
274 + compiler/yarn.lock
275 - name: Restore cached node_modules
276 uses: actions/cache@v4
277 id: node_modules
278 with:
279 path: "**/node_modules"
270 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
280 + key: runtime-and-compiler-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'compiler/yarn.lock') }}
281 - name: Ensure clean build directory
282 run: rm -rf build
283 - run: yarn install --frozen-lockfile
284 + - run: yarn install --frozen-lockfile
285 + working-directory: compiler
286 - name: Restore archived build
287 uses: actions/download-artifact@v4
288 with:
@@ -299,7 +311,7 @@ jobs:
311 id: node_modules
312 with:
313 path: "**/node_modules"
302 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
314 + key: runtime-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
315 - name: Ensure clean build directory
316 run: rm -rf build
317 - run: yarn install --frozen-lockfile
@@ -346,7 +358,7 @@ jobs:
358 id: node_modules
359 with:
360 path: "**/node_modules"
349 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
361 + key: runtime-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
362 - name: Ensure clean build directory
363 run: rm -rf build
364 - run: yarn install --frozen-lockfile
@@ -381,7 +393,7 @@ jobs:
393 id: node_modules
394 with:
395 path: "**/node_modules"
384 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
396 + key: runtime-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
397 - name: Ensure clean build directory
398 run: rm -rf build
399 - run: yarn install --frozen-lockfile
@@ -413,7 +425,7 @@ jobs:
425 id: node_modules
426 with:
427 path: "**/node_modules"
416 - key: fixtures_dom-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
428 + key: fixtures_dom-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
429 - name: Ensure clean build directory
430 run: rm -rf build
431 - run: yarn install --frozen-lockfile
@@ -456,7 +468,7 @@ jobs:
468 id: node_modules
469 with:
470 path: "**/node_modules"
459 - key: fixtures_flight-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
471 + key: fixtures_flight-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
472 - name: Ensure clean build directory
473 run: rm -rf build
474 - run: yarn install --frozen-lockfile
@@ -518,7 +530,7 @@ jobs:
530 id: node_modules
531 with:
532 path: "**/node_modules"
521 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
533 + key: runtime-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
534 - name: Ensure clean build directory
535 run: rm -rf build
536 - run: yarn install --frozen-lockfile
@@ -569,7 +581,7 @@ jobs:
581 id: node_modules
582 with:
583 path: "**/node_modules"
572 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
584 + key: runtime-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
585 - name: Ensure clean build directory
586 run: rm -rf build
587 - run: yarn install --frozen-lockfile
@@ -606,7 +618,7 @@ jobs:
618 id: node_modules
619 with:
620 path: "**/node_modules"
609 - key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
621 + key: runtime-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
622 - name: Ensure clean build directory
623 run: rm -rf build
624 - run: yarn install --frozen-lockfile
.github/workflows/runtime_eslint_plugin_e2e.yml
+6 -2
@@ -35,16 +35,20 @@ jobs:
35 with:
36 node-version-file: '.nvmrc'
37 cache: yarn
38 - cache-dependency-path: yarn.lock
38 + cache-dependency-path: |
39 + yarn.lock
40 + compiler/yarn.lock
41 - name: Restore cached node_modules
42 uses: actions/cache@v4
43 id: node_modules
44 with:
45 path: "node_modules"
44 - key: runtime-eslint_e2e-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
46 + key: runtime-and-compiler-eslint_e2e-node_modules-v3-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'compiler/yarn.lock') }}
47 - name: Ensure clean build directory
48 run: rm -rf build
49 - run: yarn install --frozen-lockfile
50 + - run: yarn install --frozen-lockfile
51 + working-directory: compiler
52 - name: Build plugin
53 working-directory: fixtures/eslint-v${{ matrix.eslint_major }}
54 run: node build.mjs
package.json
+1 -1
@@ -118,7 +118,7 @@
118 "testRegex": "/scripts/jest/dont-run-jest-directly\\.js$"
119 },
120 "scripts": {
121 - "prebuild": "yarn --cwd compiler install --frozen-lockfile && ./scripts/react-compiler/link-compiler.sh",
121 + "prebuild": "./scripts/react-compiler/link-compiler.sh",
122 "build": "node ./scripts/rollup/build-all-release-channels.js",
123 "build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react/jsx,react/compiler-runtime,react-dom/index,react-dom/client,react-dom/unstable_testing,react-dom/test-utils,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh,react-art --type=NODE",
124 "build-for-devtools-dev": "yarn build-for-devtools --type=NODE_DEV",
scripts/react-compiler/build-compiler.sh
-1
@@ -11,5 +11,4 @@ if [[ "$REACT_CLASS_EQUIVALENCE_TEST" == "true" ]]; then
11 fi
12
13 echo "Building babel-plugin-react-compiler..."
14 -yarn --cwd compiler install --frozen-lockfile
14 yarn --cwd compiler workspace babel-plugin-react-compiler build --dts