-
Notifications
You must be signed in to change notification settings - Fork 173
87 lines (75 loc) · 2.88 KB
/
Copy pathsize.yml
File metadata and controls
87 lines (75 loc) · 2.88 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Size
on:
pull_request:
paths-ignore:
- "docs/**"
- "website/**"
- "README.md"
- ".github/actions/build-docs/action.yml"
- ".github/workflows/deploy.yml"
- ".github/workflows/pr-preview.yml"
- ".github/workflows/pr-preview-cleanup.yml"
permissions:
contents: read
pull-requests: write
concurrency:
group: size-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
bundle-size:
name: Bundle Size
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup toolchain
uses: ./.github/actions/setup-node-pnpm
- name: Preserve report script
run: cp scripts/size-report.mjs /tmp/agent-device-size-report.mjs
# dist is fully determined by the base commit, so reuse it across PR runs
# against the same base. Startup medians are still measured fresh on this
# runner so the base/PR comparison stays same-machine.
- name: Restore base dist cache
id: base-dist-cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
with:
path: dist
key: size-base-dist-${{ github.event.pull_request.base.sha }}
- name: Measure base size
run: |
git checkout --detach "${{ github.event.pull_request.base.sha }}"
pnpm install --frozen-lockfile
if [ "${{ steps.base-dist-cache.outputs.cache-hit }}" != "true" ]; then
pnpm build
fi
node /tmp/agent-device-size-report.mjs \
--startup-runs 7 \
--json /tmp/agent-device-size-base.json
# Save immediately: the job-end dist belongs to the PR head, not the base.
- name: Save base dist cache
if: steps.base-dist-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
with:
path: dist
key: size-base-dist-${{ github.event.pull_request.base.sha }}
- name: Measure PR size
run: |
git checkout --detach "${{ github.event.pull_request.head.sha }}"
pnpm install --frozen-lockfile
pnpm build
node scripts/size-report.mjs \
--compare /tmp/agent-device-size-base.json \
--startup-runs 7 \
--json .tmp/size-report.json \
--markdown .tmp/size-report.md
- name: Add job summary
run: cat .tmp/size-report.md >> "$GITHUB_STEP_SUMMARY"
- name: Comment on PR
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
run: node scripts/size-report.mjs --post-comment .tmp/size-report.md