From 4fb11acd795310a97c5052733e3240a9517eae76 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 18 Jul 2024 16:19:11 -0400 Subject: [PATCH] [ci] Add sizebot to gh actions Wires up sizebot in gh actions. I also fixed sizebot incorrectly reporting that ReactAllWarnings was deleted. ghstack-source-id: d3b1bb2088651409e8656c66f1eb28ab534a0604 Pull Request resolved: https://github.com/facebook/react/pull/30380 --- .github/workflows/runtime_build_and_test.yml | 84 ++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/.github/workflows/runtime_build_and_test.yml b/.github/workflows/runtime_build_and_test.yml index b5dd8a9693438..19ee2c180fd64 100644 --- a/.github/workflows/runtime_build_and_test.yml +++ b/.github/workflows/runtime_build_and_test.yml @@ -522,3 +522,87 @@ jobs: - run: ./scripts/circleci/run_devtools_e2e_tests.js env: RELEASE_CHANNEL: experimental + + # ----- SIZEBOT ----- + download_base_build_for_sizebot: + name: Download base build for sizebot + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: scripts/release/node_modules + key: ${{ runner.arch }}-${{ runner.os }}-scripts-modules-${{ hashFiles('scripts/release/yarn.lock') }} + - run: yarn install --frozen-lockfile + - run: yarn install --frozen-lockfile + working-directory: scripts/release + - name: Download artifacts for base revision + run: | + git fetch origin main + GH_TOKEN=${{ github.token }} scripts/release/download-experimental-build-ghaction.js --commit=$(git rev-parse origin/main) + mv ./build ./base-build + # TODO: The `download-experimental-build` script copies the npm + # packages into the `node_modules` directory. This is a historical + # quirk of how the release script works. Let's pretend they + # don't exist. + - name: Delete extraneous files + run: rm -rf ./base-build/node_modules + - name: Display structure of base-build + run: ls -R base-build + - name: Archive base-build + uses: actions/upload-artifact@v4 + with: + name: base-build + path: base-build + + sizebot: + name: Run sizebot + needs: download_base_build_for_sizebot + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Restore archived build for PR + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - name: Scrape warning messages + run: | + mkdir -p ./build/__test_utils__ + node ./scripts/print-warnings/print-warnings.js > build/__test_utils__/ReactAllWarnings.js + - name: Display structure of build for PR + run: ls -R build + - name: Restore archived base-build from origin/main + uses: actions/download-artifact@v4 + with: + name: base-build + path: base-build + - name: Display structure of base-build from origin/main + run: ls -R base-build + - run: echo ${{ github.sha }} >> build/COMMIT_SHA + - run: node ./scripts/tasks/danger + - name: Archive sizebot results + uses: actions/upload-artifact@v4 + with: + name: sizebot-message + path: sizebot-message.md