@samitouri / QOS-React / commits / 5f232d72d4

[ci] Skip yarn install on cache hit (#32757)

We currently already do this in runtime_build_and_test, we can reuse the same technique in other workflows to speed them up.

lauren committed Mar 26, 2025 at 13:13 UTC 5f232d72d4cb15470c77e91c30e9cf61e090508c
8 files changed +51 -13
.github/workflows/compiler_playground.yml
+5 -1
@@ -40,8 +40,12 @@ jobs:
40 with:
41 path: |
42 **/node_modules
43 - key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/**/yarn.lock') }}
43 + key: compiler-and-playground-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/**/yarn.lock') }}
44 - run: yarn install --frozen-lockfile
45 + if: steps.node_modules.outputs.cache-hit != 'true'
46 + working-directory: compiler
47 + - run: yarn install --frozen-lockfile
48 + if: steps.node_modules.outputs.cache-hit != 'true'
49 - name: Check Playwright version
50 id: playwright_version
51 run: echo "playwright_version=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//' | head -1)" >> "$GITHUB_OUTPUT"
.github/workflows/compiler_prereleases.yml
+2 -1
@@ -49,8 +49,9 @@ jobs:
49 with:
50 path: |
51 **/node_modules
52 - key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/**/yarn.lock') }}
52 + key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/yarn.lock') }}
53 - run: yarn install --frozen-lockfile
54 + if: steps.node_modules.outputs.cache-hit != 'true'
55 - name: Publish packages to npm
56 run: |
57 cp ./scripts/release/ci-npmrc ~/.npmrc
.github/workflows/compiler_typescript.yml
+7 -3
@@ -47,11 +47,13 @@ jobs:
47 cache-dependency-path: compiler/yarn.lock
48 - name: Restore cached node_modules
49 uses: actions/cache@v4
50 + id: node_modules
51 with:
52 path: |
53 **/node_modules
53 - key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/**/yarn.lock') }}
54 + key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/yarn.lock') }}
55 - run: yarn install --frozen-lockfile
56 + if: steps.node_modules.outputs.cache-hit != 'true'
57 - run: yarn workspace babel-plugin-react-compiler lint
58
59 # Hardcoded to improve parallelism
@@ -71,8 +73,9 @@ jobs:
73 with:
74 path: |
75 **/node_modules
74 - key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/**/yarn.lock') }}
76 + key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/yarn.lock') }}
77 - run: yarn install --frozen-lockfile
78 + if: steps.node_modules.outputs.cache-hit != 'true'
79 - run: yarn workspace babel-plugin-react-compiler jest
80
81 test:
@@ -96,8 +99,9 @@ jobs:
99 with:
100 path: |
101 **/node_modules
99 - key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/**/yarn.lock') }}
102 + key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/yarn.lock') }}
103 - run: yarn install --frozen-lockfile
104 + if: steps.node_modules.outputs.cache-hit != 'true'
105 - run: xvfb-run -a yarn workspace ${{ matrix.workspace_name }} test
106 if: runner.os == 'Linux' && matrix.workspace_name == 'react-forgive'
107 - run: yarn workspace ${{ matrix.workspace_name }} test
.github/workflows/devtools_regression_tests.yml
+18 -4
@@ -40,7 +40,9 @@ jobs:
40 - name: Ensure clean build directory
41 run: rm -rf build
42 - run: yarn install --frozen-lockfile
43 + if: steps.node_modules.outputs.cache-hit != 'true'
44 - run: yarn --cwd scripts/release install --frozen-lockfile
45 + if: steps.node_modules.outputs.cache-hit != 'true'
46 - name: Download react-devtools artifacts for base revision
47 run: |
48 git fetch origin main
@@ -75,6 +77,7 @@ jobs:
77 - name: Ensure clean build directory
78 run: rm -rf build
79 - run: yarn install --frozen-lockfile
80 + if: steps.node_modules.outputs.cache-hit != 'true'
81 - name: Restore archived build
82 uses: actions/download-artifact@v4
83 with:
@@ -134,6 +137,7 @@ jobs:
137 **/node_modules
138 key: runtime-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
139 - run: yarn install --frozen-lockfile
140 + if: steps.node_modules.outputs.cache-hit != 'true'
141 - name: Restore all archived build artifacts
142 uses: actions/download-artifact@v4
143 - name: Display structure of build
@@ -169,14 +173,24 @@ jobs:
173 **/node_modules
174 key: runtime-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
175 - run: yarn install --frozen-lockfile
176 + if: steps.node_modules.outputs.cache-hit != 'true'
177 - name: Restore all archived build artifacts
178 uses: actions/download-artifact@v4
179 - name: Display structure of build
180 run: ls -R build
176 - - name: Playwright install deps
177 - run: |
178 - npx playwright install
179 - sudo npx playwright install-deps
181 + - name: Check Playwright version
182 + id: playwright_version
183 + run: echo "playwright_version=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//' | head -1)" >> "$GITHUB_OUTPUT"
184 + - name: Cache Playwright Browsers for version ${{ steps.playwright_version.outputs.playwright_version }}
185 + id: cache_playwright_browsers
186 + uses: actions/cache@v4
187 + with:
188 + path: ~/.cache/ms-playwright
189 + key: playwright-browsers-v6-${{ runner.arch }}-${{ runner.os }}-${{ steps.playwright_version.outputs.playwright_version }}
190 + - run: npx playwright install --with-deps
191 + if: steps.cache_playwright_browsers.outputs.cache-hit != 'true'
192 + - run: npx playwright install-deps
193 + if: steps.cache_playwright_browsers.outputs.cache-hit == 'true'
194 - run: ./scripts/ci/download_devtools_regression_build.js ${{ matrix.version }}
195 - run: ls -R build-regression
196 - run: ./scripts/ci/run_devtools_e2e_tests.js ${{ matrix.version }}
.github/workflows/runtime_eslint_plugin_e2e.yml
+7 -4
@@ -46,17 +46,20 @@ jobs:
46 with:
47 path: |
48 **/node_modules
49 - key: runtime-and-compiler-eslint_e2e-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'compiler/yarn.lock') }}
49 + key: runtime-and-compiler-eslint_e2e-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'compiler/yarn.lock', 'fixtures/eslint-v*/yarn.lock') }}
50 - name: Ensure clean build directory
51 run: rm -rf build
52 - run: yarn install --frozen-lockfile
53 + if: steps.node_modules.outputs.cache-hit != 'true'
54 - run: yarn --cwd compiler install --frozen-lockfile
54 - - name: Build plugin
55 - working-directory: fixtures/eslint-v${{ matrix.eslint_major }}
56 - run: node build.mjs
55 + if: steps.node_modules.outputs.cache-hit != 'true'
56 - name: Install fixture dependencies
57 working-directory: ./fixtures/eslint-v${{ matrix.eslint_major }}
58 run: yarn --frozen-lockfile
59 + if: steps.node_modules.outputs.cache-hit != 'true'
60 + - name: Build plugin
61 + working-directory: fixtures/eslint-v${{ matrix.eslint_major }}
62 + run: node build.mjs
63 - name: Run lint test
64 working-directory: ./fixtures/eslint-v${{ matrix.eslint_major }}
65 run: yarn lint
.github/workflows/runtime_prereleases.yml
+2
@@ -51,7 +51,9 @@ jobs:
51 - name: Ensure clean build directory
52 run: rm -rf build
53 - run: yarn install --frozen-lockfile
54 + if: steps.node_modules.outputs.cache-hit != 'true'
55 - run: yarn --cwd scripts/release install --frozen-lockfile
56 + if: steps.node_modules.outputs.cache-hit != 'true'
57 - run: |
58 GH_TOKEN=${{ secrets.GH_TOKEN }} scripts/release/prepare-release-from-ci.js --skipTests -r ${{ inputs.release_channel }} --commit=${{ inputs.commit_sha }}
59 cp ./scripts/release/ci-npmrc ~/.npmrc
.github/workflows/runtime_releases_from_npm_manual.yml
+2
@@ -78,7 +78,9 @@ jobs:
78 - name: Ensure clean build directory
79 run: rm -rf build
80 - run: yarn install --frozen-lockfile
81 + if: steps.node_modules.outputs.cache-hit != 'true'
82 - run: yarn --cwd scripts/release install --frozen-lockfile
83 + if: steps.node_modules.outputs.cache-hit != 'true'
84 - run: cp ./scripts/release/ci-npmrc ~/.npmrc
85 - if: '${{ inputs.only_packages }}'
86 name: 'Prepare ${{ inputs.only_packages }} from NPM'
.github/workflows/shared_lint.yml
+8
@@ -29,6 +29,7 @@ jobs:
29 cache-dependency-path: yarn.lock
30 - name: Restore cached node_modules
31 uses: actions/cache@v4
32 + id: node_modules
33 with:
34 path: |
35 **/node_modules
@@ -36,6 +37,7 @@ jobs:
37 - name: Ensure clean build directory
38 run: rm -rf build
39 - run: yarn install --frozen-lockfile
40 + if: steps.node_modules.outputs.cache-hit != 'true'
41 - run: yarn prettier-check
42
43 eslint:
@@ -50,6 +52,7 @@ jobs:
52 cache-dependency-path: yarn.lock
53 - name: Restore cached node_modules
54 uses: actions/cache@v4
55 + id: node_modules
56 with:
57 path: |
58 **/node_modules
@@ -57,6 +60,7 @@ jobs:
60 - name: Ensure clean build directory
61 run: rm -rf build
62 - run: yarn install --frozen-lockfile
63 + if: steps.node_modules.outputs.cache-hit != 'true'
64 - run: node ./scripts/tasks/eslint
65
66 check_license:
@@ -71,6 +75,7 @@ jobs:
75 cache-dependency-path: yarn.lock
76 - name: Restore cached node_modules
77 uses: actions/cache@v4
78 + id: node_modules
79 with:
80 path: |
81 **/node_modules
@@ -78,6 +83,7 @@ jobs:
83 - name: Ensure clean build directory
84 run: rm -rf build
85 - run: yarn install --frozen-lockfile
86 + if: steps.node_modules.outputs.cache-hit != 'true'
87 - run: ./scripts/ci/check_license.sh
88
89 test_print_warnings:
@@ -92,6 +98,7 @@ jobs:
98 cache-dependency-path: yarn.lock
99 - name: Restore cached node_modules
100 uses: actions/cache@v4
101 + id: node_modules
102 with:
103 path: |
104 **/node_modules
@@ -99,4 +106,5 @@ jobs:
106 - name: Ensure clean build directory
107 run: rm -rf build
108 - run: yarn install --frozen-lockfile
109 + if: steps.node_modules.outputs.cache-hit != 'true'
110 - run: ./scripts/ci/test_print_warnings.sh