From 95f43b01b7790b2af237d3dd6f015d2212dd495f Mon Sep 17 00:00:00 2001 From: avivkeller Date: Sun, 19 Oct 2025 16:37:17 -0400 Subject: [PATCH 1/7] feat(cicd): add bundle stats comparison --- .github/workflows/build.yml | 8 +++++ .github/workflows/bundle-compare.yml | 50 ++++++++++++++++++++++++++++ apps/site/turbo.json | 12 ++++--- 3 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/bundle-compare.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d9b9fbdad286..a7f3e0aafb24c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,3 +68,11 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' # We want to ensure that static exports for all locales do not occur on `pull_request` events NEXT_PUBLIC_STATIC_EXPORT_LOCALE: ${{ github.event_name == 'push' }} + # See https://github.com/vercel/next.js/pull/81318 + TURBOPACK_STATS: ${{ matrix.os == 'ubuntu-latest' }} + + - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 + if: matrix.os == 'ubuntu-latest' + with: + name: webpack-stats + path: apps/site/.next/server/webpack-stats.json diff --git a/.github/workflows/bundle-compare.yml b/.github/workflows/bundle-compare.yml new file mode 100644 index 0000000000000..07608d7058385 --- /dev/null +++ b/.github/workflows/bundle-compare.yml @@ -0,0 +1,50 @@ +name: Compare Bundle Size + +on: + workflow_run: + workflows: ['Build'] + types: [completed] + +permissions: + contents: read + actions: read + # To create the comment + pull-requests: write + +jobs: + compare: + name: Compare Bundle Stats + runs-on: ubuntu-latest + + steps: + - name: Harden Runner + uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 + with: + egress-policy: audit + + - name: Download Stats (HEAD) + uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 + with: + name: webpack-stats + path: head-stats + + - name: Get Run ID from BASE + id: base-run + env: + WORKFLOW_ID: ${{ github.event.workflow_run.workflow_id }} + run: | + ID=$(gh run list -c $GITHUB_SHA -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId") + echo "run_id=$ID" >> $GITHUB_OUTPUT + + - name: Download Stats (BASE) + uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 + with: + name: webpack-stats + path: base-stats + run_id: ${{ steps.base-run.outputs.run_id }} + + - uses: github/webpack-bundlesize-compare-action@89161bb25577f08577ce053c3264c0e3b7d7558f # v2.1.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + current-stats-json-path: ./head-stats/webpack-stats.json + base-stats-json-path: ./base-stats/webpack-stats.json diff --git a/apps/site/turbo.json b/apps/site/turbo.json index a42602d86ff53..8cbaee9d8800e 100644 --- a/apps/site/turbo.json +++ b/apps/site/turbo.json @@ -19,7 +19,8 @@ "NEXT_PUBLIC_ORAMA_ENDPOINT", "NEXT_PUBLIC_DATA_URL", "TURBO_CACHE", - "TURBO_TELEMETRY_DISABLED" + "TURBO_TELEMETRY_DISABLED", + "TURBOPACK_STATS" ] }, "build": { @@ -45,7 +46,8 @@ "NEXT_PUBLIC_ORAMA_ENDPOINT", "NEXT_PUBLIC_DATA_URL", "TURBO_CACHE", - "TURBO_TELEMETRY_DISABLED" + "TURBO_TELEMETRY_DISABLED", + "TURBOPACK_STATS" ] }, "start": { @@ -64,7 +66,8 @@ "NEXT_PUBLIC_ORAMA_ENDPOINT", "NEXT_PUBLIC_DATA_URL", "TURBO_CACHE", - "TURBO_TELEMETRY_DISABLED" + "TURBO_TELEMETRY_DISABLED", + "TURBOPACK_STATS" ] }, "deploy": { @@ -89,7 +92,8 @@ "NEXT_PUBLIC_ORAMA_ENDPOINT", "NEXT_PUBLIC_DATA_URL", "TURBO_CACHE", - "TURBO_TELEMETRY_DISABLED" + "TURBO_TELEMETRY_DISABLED", + "TURBOPACK_STATS" ] }, "lint:js": { From aac3847cba3fefb122c63e9909920ecd918a1974 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 27 Oct 2025 20:25:44 -0400 Subject: [PATCH 2/7] [test] --- .github/workflows/bundle-compare.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bundle-compare.yml b/.github/workflows/bundle-compare.yml index 07608d7058385..ed4cd9ccd9075 100644 --- a/.github/workflows/bundle-compare.yml +++ b/.github/workflows/bundle-compare.yml @@ -1,9 +1,10 @@ name: Compare Bundle Size on: - workflow_run: - workflows: ['Build'] - types: [completed] + pull_request: + # workflow_run: + # workflows: ['Build'] + # types: [completed] permissions: contents: read @@ -27,13 +28,14 @@ jobs: with: name: webpack-stats path: head-stats + run_id: 18859999262 - name: Get Run ID from BASE id: base-run env: - WORKFLOW_ID: ${{ github.event.workflow_run.workflow_id }} + WORKFLOW_ID: ${{ github.event.workflow_run.workflow_id || 64771488 }} run: | - ID=$(gh run list -c $GITHUB_SHA -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId") + ID=$(gh run list -c 95f43b01b7790b2af237d3dd6f015d2212dd495f -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId") echo "run_id=$ID" >> $GITHUB_OUTPUT - name: Download Stats (BASE) From 476ec380630ecc8c27557c25c07861cce32142cd Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 27 Oct 2025 20:26:52 -0400 Subject: [PATCH 3/7] fixup! --- .github/workflows/bundle-compare.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bundle-compare.yml b/.github/workflows/bundle-compare.yml index ed4cd9ccd9075..ecb059890839c 100644 --- a/.github/workflows/bundle-compare.yml +++ b/.github/workflows/bundle-compare.yml @@ -28,7 +28,7 @@ jobs: with: name: webpack-stats path: head-stats - run_id: 18859999262 + run-id: 18859999262 - name: Get Run ID from BASE id: base-run @@ -43,7 +43,7 @@ jobs: with: name: webpack-stats path: base-stats - run_id: ${{ steps.base-run.outputs.run_id }} + run-id: ${{ steps.base-run.outputs.run_id }} - uses: github/webpack-bundlesize-compare-action@89161bb25577f08577ce053c3264c0e3b7d7558f # v2.1.0 with: From 533e92c9b386f22653f82e0813f135eb80a04ecb Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 27 Oct 2025 20:35:11 -0400 Subject: [PATCH 4/7] fixup! --- .github/workflows/bundle-compare.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bundle-compare.yml b/.github/workflows/bundle-compare.yml index ecb059890839c..26db238a61e78 100644 --- a/.github/workflows/bundle-compare.yml +++ b/.github/workflows/bundle-compare.yml @@ -28,7 +28,7 @@ jobs: with: name: webpack-stats path: head-stats - run-id: 18859999262 + run-id: 18860058714 - name: Get Run ID from BASE id: base-run From 895d7b4d219b3771d61848e5e573371080253529 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 27 Oct 2025 20:36:46 -0400 Subject: [PATCH 5/7] fixup! --- .github/workflows/bundle-compare.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/bundle-compare.yml b/.github/workflows/bundle-compare.yml index 26db238a61e78..7226f118ce79a 100644 --- a/.github/workflows/bundle-compare.yml +++ b/.github/workflows/bundle-compare.yml @@ -29,6 +29,7 @@ jobs: name: webpack-stats path: head-stats run-id: 18860058714 + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Get Run ID from BASE id: base-run From 80a610635f2b83982ceccae8475a0ff0660f7757 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 27 Oct 2025 20:37:43 -0400 Subject: [PATCH 6/7] fixup! --- .github/workflows/bundle-compare.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/bundle-compare.yml b/.github/workflows/bundle-compare.yml index 7226f118ce79a..b81c3a41bb252 100644 --- a/.github/workflows/bundle-compare.yml +++ b/.github/workflows/bundle-compare.yml @@ -35,6 +35,7 @@ jobs: id: base-run env: WORKFLOW_ID: ${{ github.event.workflow_run.workflow_id || 64771488 }} + GH_TOKEN: ${{ github.token }} run: | ID=$(gh run list -c 95f43b01b7790b2af237d3dd6f015d2212dd495f -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId") echo "run_id=$ID" >> $GITHUB_OUTPUT @@ -45,6 +46,7 @@ jobs: name: webpack-stats path: base-stats run-id: ${{ steps.base-run.outputs.run_id }} + github-token: ${{ secrets.GITHUB_TOKEN }} - uses: github/webpack-bundlesize-compare-action@89161bb25577f08577ce053c3264c0e3b7d7558f # v2.1.0 with: From 1117c2c45ed442cc017beb0751dfab801afa3c63 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 27 Oct 2025 20:39:14 -0400 Subject: [PATCH 7/7] fixup! --- .github/workflows/bundle-compare.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bundle-compare.yml b/.github/workflows/bundle-compare.yml index b81c3a41bb252..15d8002daacbc 100644 --- a/.github/workflows/bundle-compare.yml +++ b/.github/workflows/bundle-compare.yml @@ -37,7 +37,7 @@ jobs: WORKFLOW_ID: ${{ github.event.workflow_run.workflow_id || 64771488 }} GH_TOKEN: ${{ github.token }} run: | - ID=$(gh run list -c 95f43b01b7790b2af237d3dd6f015d2212dd495f -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId") + ID=$(gh run list --repo $GITHUB_REPOSITORY -c 95f43b01b7790b2af237d3dd6f015d2212dd495f -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId") echo "run_id=$ID" >> $GITHUB_OUTPUT - name: Download Stats (BASE)