-
Notifications
You must be signed in to change notification settings - Fork 59
65 lines (54 loc) · 1.94 KB
/
bundle_size.yml
File metadata and controls
65 lines (54 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Check bundle size
on:
pull_request:
jobs:
size:
if: ${{ github.repository == 'primer/brand' }}
name: Report bundle size
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create main branch worktree
run: git worktree add /tmp/main ${{ github.event.pull_request.base.sha }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 24
- name: Caching dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install and build (PR)
run: |
npm ci
npm run build:lib
- name: Measure bundle size (PR)
run: npx size-limit --json > /tmp/pr-sizes.json
- name: Install and build (main branch)
working-directory: /tmp/main
run: |
npm ci
cp ${{ github.workspace }}/.size-limit.js .size-limit.js
npm run build:lib || true
- name: Measure bundle size (main branch)
working-directory: /tmp/main
run: npx size-limit --json > /tmp/main-sizes.json 2>/dev/null || echo "[]" > /tmp/main-sizes.json
- name: Generate size report
id: size-report
run: |
REPORT=$(node packages/repo-configs/scripts/bundle-size-report.js /tmp/pr-sizes.json /tmp/main-sizes.json)
echo "comment-body<<EOF" >> "$GITHUB_OUTPUT"
echo "$REPORT" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Add or update bundle size comment
uses: phulsechinmay/rewritable-pr-comment@v0.3.0
with:
message: ${{ steps.size-report.outputs.comment-body }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENT_IDENTIFIER: 'bundle-size-report'