From 380f5d675d2269f090d15c3f92e10de66e12516c Mon Sep 17 00:00:00 2001 From: lauren Date: Wed, 13 Nov 2024 15:13:46 -0500 Subject: [PATCH] Fix sizebot (#31535) Our CI workflows generally cache `**/node_modules` (note the glob, it caches all transitive node_module directories) to speed up startup for new jobs that don't change any dependencies. However it seems like one of our caches got into a weird state (not sure how it happened) where the `build` directory (used in various other scripts as the directory for compiled React packages) would contain a `node_modules` directory as well. This made sizebot size change messages very big since it would try to compare every single file in `build/node_modules`. The fix is to ensure we always clean the `build` directory before doing anything with it. We can also delete that one problematic cache but this PR is a little more resilient to other weird behavior with that directory. --- .../workflows/devtools_regression_tests.yml | 4 +++ .github/workflows/runtime_build_and_test.yml | 30 +++++++++++++++++++ .../workflows/runtime_commit_artifacts.yml | 2 ++ .github/workflows/runtime_prereleases.yml | 2 ++ .github/workflows/shared_lint.yml | 8 +++++ 5 files changed, 46 insertions(+) diff --git a/.github/workflows/devtools_regression_tests.yml b/.github/workflows/devtools_regression_tests.yml index 213f58218cc2b..64d6707aa3688 100644 --- a/.github/workflows/devtools_regression_tests.yml +++ b/.github/workflows/devtools_regression_tests.yml @@ -31,6 +31,8 @@ jobs: with: path: "**/node_modules" key: runtime-release-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'scripts/release/yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile working-directory: scripts/release @@ -63,6 +65,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - name: Restore archived build uses: actions/download-artifact@v4 diff --git a/.github/workflows/runtime_build_and_test.yml b/.github/workflows/runtime_build_and_test.yml index c59d990ba0ced..b9cbe4d447bbb 100644 --- a/.github/workflows/runtime_build_and_test.yml +++ b/.github/workflows/runtime_build_and_test.yml @@ -53,6 +53,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: node ./scripts/tasks/flow-ci ${{ matrix.flow_inline_config_shortname }} @@ -73,6 +75,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: | yarn generate-inline-fizz-runtime @@ -95,6 +99,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: yarn flags @@ -144,6 +150,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: yarn test ${{ matrix.params }} --ci --shard=${{ matrix.shard }} @@ -173,6 +181,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: yarn build --index=${{ matrix.worker_id }} --total=20 --r=${{ matrix.release_channel }} --ci env: @@ -243,6 +253,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - name: Restore archived build uses: actions/download-artifact@v4 @@ -271,6 +283,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - name: Restore archived build uses: actions/download-artifact@v4 @@ -314,6 +328,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - name: Restore archived build uses: actions/download-artifact@v4 @@ -345,6 +361,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - name: Restore archived build uses: actions/download-artifact@v4 @@ -373,6 +391,8 @@ jobs: with: path: "**/node_modules" key: fixtures_dom-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn working-directory: fixtures/dom @@ -413,6 +433,8 @@ jobs: with: path: "**/node_modules" key: fixtures_flight-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - name: Restore archived build uses: actions/download-artifact@v4 @@ -469,6 +491,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - name: Restore archived build uses: actions/download-artifact@v4 @@ -515,6 +539,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - name: Restore archived build uses: actions/download-artifact@v4 @@ -547,6 +573,8 @@ jobs: with: path: "**/node_modules" key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock', 'scripts/release/yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile working-directory: scripts/release @@ -586,6 +614,8 @@ jobs: with: path: "**/node_modules" key: runtime-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - name: Restore archived build for PR uses: actions/download-artifact@v4 diff --git a/.github/workflows/runtime_commit_artifacts.yml b/.github/workflows/runtime_commit_artifacts.yml index 7842f07ba5888..4315256affe45 100644 --- a/.github/workflows/runtime_commit_artifacts.yml +++ b/.github/workflows/runtime_commit_artifacts.yml @@ -75,6 +75,8 @@ jobs: with: path: "**/node_modules" key: runtime-release-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'scripts/release/yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile name: yarn install (react) - run: yarn install --frozen-lockfile diff --git a/.github/workflows/runtime_prereleases.yml b/.github/workflows/runtime_prereleases.yml index 37516ea3cb19c..e52bed6bb16bf 100644 --- a/.github/workflows/runtime_prereleases.yml +++ b/.github/workflows/runtime_prereleases.yml @@ -41,6 +41,8 @@ jobs: with: path: "**/node_modules" key: runtime-release-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'scripts/release/yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile working-directory: scripts/release diff --git a/.github/workflows/shared_lint.yml b/.github/workflows/shared_lint.yml index 00155e8e55976..36c1df9eb86f9 100644 --- a/.github/workflows/shared_lint.yml +++ b/.github/workflows/shared_lint.yml @@ -30,6 +30,8 @@ jobs: with: path: "**/node_modules" key: shared-lint-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: yarn prettier-check @@ -48,6 +50,8 @@ jobs: with: path: "**/node_modules" key: shared-lint-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: node ./scripts/tasks/eslint @@ -66,6 +70,8 @@ jobs: with: path: "**/node_modules" key: shared-lint-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: ./scripts/ci/check_license.sh @@ -84,5 +90,7 @@ jobs: with: path: "**/node_modules" key: shared-lint-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - name: Ensure clean build directory + run: rm -rf build - run: yarn install --frozen-lockfile - run: ./scripts/ci/test_print_warnings.sh