Skip to content

Commit 95f43b0

Browse files
committed
feat(cicd): add bundle stats comparison
1 parent 7015095 commit 95f43b0

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@ jobs:
6868
NODE_OPTIONS: '--max_old_space_size=4096'
6969
# We want to ensure that static exports for all locales do not occur on `pull_request` events
7070
NEXT_PUBLIC_STATIC_EXPORT_LOCALE: ${{ github.event_name == 'push' }}
71+
# See https://github.com/vercel/next.js/pull/81318
72+
TURBOPACK_STATS: ${{ matrix.os == 'ubuntu-latest' }}
73+
74+
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
75+
if: matrix.os == 'ubuntu-latest'
76+
with:
77+
name: webpack-stats
78+
path: apps/site/.next/server/webpack-stats.json
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Compare Bundle Size
2+
3+
on:
4+
workflow_run:
5+
workflows: ['Build']
6+
types: [completed]
7+
8+
permissions:
9+
contents: read
10+
actions: read
11+
# To create the comment
12+
pull-requests: write
13+
14+
jobs:
15+
compare:
16+
name: Compare Bundle Stats
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Harden Runner
21+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
22+
with:
23+
egress-policy: audit
24+
25+
- name: Download Stats (HEAD)
26+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
27+
with:
28+
name: webpack-stats
29+
path: head-stats
30+
31+
- name: Get Run ID from BASE
32+
id: base-run
33+
env:
34+
WORKFLOW_ID: ${{ github.event.workflow_run.workflow_id }}
35+
run: |
36+
ID=$(gh run list -c $GITHUB_SHA -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId")
37+
echo "run_id=$ID" >> $GITHUB_OUTPUT
38+
39+
- name: Download Stats (BASE)
40+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
41+
with:
42+
name: webpack-stats
43+
path: base-stats
44+
run_id: ${{ steps.base-run.outputs.run_id }}
45+
46+
- uses: github/webpack-bundlesize-compare-action@89161bb25577f08577ce053c3264c0e3b7d7558f # v2.1.0
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
current-stats-json-path: ./head-stats/webpack-stats.json
50+
base-stats-json-path: ./base-stats/webpack-stats.json

apps/site/turbo.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"NEXT_PUBLIC_ORAMA_ENDPOINT",
2020
"NEXT_PUBLIC_DATA_URL",
2121
"TURBO_CACHE",
22-
"TURBO_TELEMETRY_DISABLED"
22+
"TURBO_TELEMETRY_DISABLED",
23+
"TURBOPACK_STATS"
2324
]
2425
},
2526
"build": {
@@ -45,7 +46,8 @@
4546
"NEXT_PUBLIC_ORAMA_ENDPOINT",
4647
"NEXT_PUBLIC_DATA_URL",
4748
"TURBO_CACHE",
48-
"TURBO_TELEMETRY_DISABLED"
49+
"TURBO_TELEMETRY_DISABLED",
50+
"TURBOPACK_STATS"
4951
]
5052
},
5153
"start": {
@@ -64,7 +66,8 @@
6466
"NEXT_PUBLIC_ORAMA_ENDPOINT",
6567
"NEXT_PUBLIC_DATA_URL",
6668
"TURBO_CACHE",
67-
"TURBO_TELEMETRY_DISABLED"
69+
"TURBO_TELEMETRY_DISABLED",
70+
"TURBOPACK_STATS"
6871
]
6972
},
7073
"deploy": {
@@ -89,7 +92,8 @@
8992
"NEXT_PUBLIC_ORAMA_ENDPOINT",
9093
"NEXT_PUBLIC_DATA_URL",
9194
"TURBO_CACHE",
92-
"TURBO_TELEMETRY_DISABLED"
95+
"TURBO_TELEMETRY_DISABLED",
96+
"TURBOPACK_STATS"
9397
]
9498
},
9599
"lint:js": {

0 commit comments

Comments
 (0)