-
Notifications
You must be signed in to change notification settings - Fork 155
97 lines (78 loc) · 2.61 KB
/
bundle-size.yml
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
88
89
90
91
92
93
94
95
96
97
name: Measure bundle size
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
statuses: write
jobs:
measure:
runs-on: ubuntu-latest
steps:
# ------- Setup -----------------------------------------------------
- name: Checkout the PR branch
uses: actions/checkout@v4
with:
path: 'components'
- name: Setup the bundle measurement project
run: |
cp -r components/.github/workflows/bundle-size bundle-size
cd bundle-size
npm i --force
- uses: actions/github-script@v7
name: Create a pending status on the commit
with:
script: |
const { statusReportStart } = await import(process.cwd() + '/bundle-size/status-report.js');
await statusReportStart({ context, github });
# ------- Base branch size measurement ------------------------------
- name: Checkout the base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: 'components'
- name: Measure the bundle size of the base branch
run: |
cd components
npm i --force
npm run quick-build
cd ../bundle-size
npm run build
mv output.json output-basebranch.json
cat output-basebranch.json
# ------- Pull request size measurement -----------------------------
- name: Checkout the PR branch
uses: actions/checkout@v4
with:
path: 'components'
- name: Measure the bundle size of this PR
id: measure
run: |
cd components
npm i --force
npm run quick-build
cd ../bundle-size
npm run build
cat output.json
- name: Upload size report artifact
uses: actions/upload-artifact@v4
with:
name: size-report
path: bundle-size/output.json
- name: Update the commit status with calculated results
uses: actions/github-script@v7
with:
script: |
const { statusReportSuccess } = await import(process.cwd() + '/bundle-size/status-report.js');
await statusReportSuccess({ context, github });
# ------- Error reporting -------------------------------------------
- name: Report failure
if: failure()
uses: actions/github-script@v7
with:
script: |
const { statusReportFailure } = await import(process.cwd() + '/bundle-size/status-report.js');
await statusReportFailure({ context, github });