-
Notifications
You must be signed in to change notification settings - Fork 1
146 lines (142 loc) · 4.07 KB
/
client.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: NPM build, test & bundle size diff
on:
push:
branches:
- main
paths:
- "frontend/**"
pull_request:
types: [opened]
branches:
- main
paths:
- "frontend/**"
jobs:
build-head:
name: Build head
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./frontend
yarn install --force --frozen-lockfile
- name: Test head
run: |
cd ./frontend
yarn test
- name: Build head
run: |
cd ./frontend
yarn build-stats
mv ./packages/host/dist/stats.json ./packages/host/dist/head.json
- name: Zip head stats
run: zip -j head.zip ./frontend/packages/host/dist/head.json
- name: Delete old head stats
uses: actions/github-script@v6
id: artifact
with:
script: |
const res = await github.rest.actions.listArtifactsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
});
res.data.artifacts
.forEach(({ id }) => {
github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: id,
})
});
- name: Upload new head stats
uses: actions/upload-artifact@v3
with:
name: head
path: head.zip
retention-days: 1
build-base:
name: Build base
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: main
- name: Install dependencies
run: |
cd ./frontend
yarn install --force --frozen-lockfile
- name: Test base
run: |
cd ./frontend
yarn test
- name: Build base
run: |
cd ./frontend
yarn build-stats
mv ./packages/host/dist/stats.json ./packages/host/dist/base.json
- name: Zip base stats
run: zip -j base.zip ./frontend/packages/host/dist/base.json
- name: Delete old base stats
uses: actions/github-script@v6
id: artifact
with:
script: |
const res = await github.rest.actions.listArtifactsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
});
res.data.artifacts
.forEach(({ id }) => {
github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: id,
})
});
- name: Upload new base stats
uses: actions/upload-artifact@v3
with:
name: base
path: base.zip
retention-days: 1
report:
# Skip generating bundle diff report for base branch (i.e. main)
if: ${{ github.ref != 'refs/heads/main' }}
name: Generate report
runs-on: ubuntu-latest
needs: [build-base, build-head]
steps:
- uses: actions/checkout@v3
- name: Download base stats
uses: actions/download-artifact@v3
with:
name: base
- name: Unzip base stats
run: |
unzip -o base.zip
unzip -o base.zip
- name: Download head stats
uses: actions/download-artifact@v3
with:
name: head
- name: Unzip head stats
run: |
unzip -o head.zip
unzip -o head.zip
- name: Diff between base & head
id: get-diff
uses: NejcZdovc/bundle-size-diff@v1
with:
base_path: ./base.json
pr_path: ./head.json
- name: Comment
uses: NejcZdovc/[email protected]
with:
file: "comment.md"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
OLD: ${{steps.get-diff.outputs.base_file_string}}
NEW: ${{steps.get-diff.outputs.pr_file_string}}
DIFF: ${{steps.get-diff.outputs.diff_file_string}}
DIFF_PERCENT: ${{steps.get-diff.outputs.percent}}