-
Notifications
You must be signed in to change notification settings - Fork 247
108 lines (90 loc) · 3.98 KB
/
wasm-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
98
99
100
101
102
103
104
105
106
107
108
name: "QE: WASM size"
on:
pull_request:
paths-ignore:
- ".github/**"
- "!.github/workflows/wasm-size.yml"
- ".buildkite/**"
- "*.md"
- "LICENSE"
- "CODEOWNERS"
- "renovate.json"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pr-wasm-size:
name: calculate module size (pr)
runs-on: ubuntu-latest
outputs:
size: ${{ steps.measure.outputs.size }}
size_gz: ${{ steps.measure.outputs.size_gz }}
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
- name: Build and measure PR branch
id: measure
run: |
nix build -L .#query-engine-wasm .#query-engine-wasm-gz
echo "size=$(wc --bytes < ./result/query_engine_bg.wasm)" >> $GITHUB_OUTPUT
echo "size_gz=$(wc --bytes < ./result-1/query_engine_bg.wasm.gz)" >> $GITHUB_OUTPUT
base-wasm-size:
name: calculate module size (main)
runs-on: ubuntu-latest
outputs:
size: ${{ steps.measure.outputs.size }}
size_gz: ${{ steps.measure.outputs.size_gz }}
steps:
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
- uses: cachix/install-nix-action@v24
- name: Build and measure base branch
id: measure
run: |
nix build -L .#query-engine-wasm .#query-engine-wasm-gz
echo "size=$(wc --bytes < ./result/query_engine_bg.wasm)" >> $GITHUB_OUTPUT
echo "size_gz=$(wc --bytes < ./result-1/query_engine_bg.wasm.gz)" >> $GITHUB_OUTPUT
report-diff:
name: report module size
runs-on: ubuntu-latest
needs:
- pr-wasm-size
- base-wasm-size
steps:
- name: Compute difference
id: compute
run: |
base=$(echo "${{ needs.base-wasm-size.outputs.size }}" | numfmt --format '%.3f' --to=iec-i --suffix=B)
base_gz=$(echo "${{ needs.base-wasm-size.outputs.size_gz }}" | numfmt --format '%.3f' --to=iec-i --suffix=B)
pr=$(echo "${{ needs.pr-wasm-size.outputs.size }}" | numfmt --format '%.3f' --to=iec-i --suffix=B)
pr_gz=$(echo "${{ needs.pr-wasm-size.outputs.size_gz }}" | numfmt --format '%.3f' --to=iec-i --suffix=B)
diff=$(echo "$((${{ needs.pr-wasm-size.outputs.size }} - ${{ needs.base-wasm-size.outputs.size }}))" | numfmt --format '%.3f' --to=iec-i --suffix=B)
diff_gz=$(echo "$((${{ needs.pr-wasm-size.outputs.size_gz }} - ${{ needs.base-wasm-size.outputs.size_gz }}))" | numfmt --format '%.3f' --to=iec-i --suffix=B)
echo "base=$base" >> $GITHUB_OUTPUT
echo "base_gz=$base_gz" >> $GITHUB_OUTPUT
echo "pr=$pr" >> $GITHUB_OUTPUT
echo "pr_gz=$pr_gz" >> $GITHUB_OUTPUT
echo "diff=$diff" >> $GITHUB_OUTPUT
echo "diff_gz=$diff_gz" >> $GITHUB_OUTPUT
- name: Find past report comment
uses: peter-evans/find-comment@v2
id: findReportComment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "<!-- wasm-size -->"
- name: Create or update report
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.findReportComment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- wasm-size -->
### WASM Size
|Engine | This PR | Base branch | Diff
|--------------|-----------------------------------|--------------------------------------|------------------------------------
| WASM | ${{ steps.compute.outputs.pr}} | ${{ steps.compute.outputs.base}} | ${{ steps.compute.outputs.diff}}
| WASM (gzip) | ${{ steps.compute.outputs.pr_gz}} | ${{ steps.compute.outputs.base_gz}} | ${{ steps.compute.outputs.diff_gz}}
edit-mode: replace