-
Notifications
You must be signed in to change notification settings - Fork 31
130 lines (110 loc) · 3.76 KB
/
bench.yml
File metadata and controls
130 lines (110 loc) · 3.76 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
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
name: bench
on:
push:
branches:
- main
paths:
- 'packages/evlog/src/**'
- 'packages/evlog/tsdown.config.ts'
pull_request:
branches:
- main
paths:
- 'packages/evlog/src/**'
- 'packages/evlog/tsdown.config.ts'
workflow_dispatch:
jobs:
bundle-size:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.11"
- name: Install dependencies
run: bun install
- name: Build evlog package
run: bunx turbo run build --filter=evlog
- name: Measure current bundle size
working-directory: packages/evlog
run: bun bench/scripts/size.ts --json > /tmp/size-current.json
- name: Get baseline from main
run: |
git show origin/main:packages/evlog/bench/baseline/size.json > /tmp/size-baseline.json 2>/dev/null || echo '{"entries":[],"total":{"raw":0,"gzip":0}}' > /tmp/size-baseline.json
- name: Compare sizes
id: compare
working-directory: packages/evlog
run: |
set +e
REPORT=$(bun bench/scripts/compare.ts \
--size /tmp/size-baseline.json /tmp/size-current.json)
EXIT_CODE=$?
echo "exit_code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "report<<$EOF" >> "$GITHUB_OUTPUT"
echo "$REPORT" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Post PR comment
uses: actions/github-script@v8
with:
script: |
const body = `${{ steps.compare.outputs.report }}`;
const marker = '<!-- evlog-size -->';
const fullBody = `${marker}\n${body}`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body?.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: fullBody,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: fullBody,
});
}
update-size-baseline:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.11"
- name: Install dependencies
run: bun install
- name: Build evlog package
run: bunx turbo run build --filter=evlog
- name: Measure bundle size
working-directory: packages/evlog
run: |
mkdir -p bench/baseline
bun bench/scripts/size.ts --json > bench/baseline/size.json
- name: Create baseline PR
uses: peter-evans/create-pull-request@v8
with:
commit-message: "chore(bench): update size baseline"
title: "chore(bench): update size baseline"
body: Automated bundle size baseline update from main.
branch: chore/update-bench-baseline
add-paths: |
packages/evlog/bench/baseline/size.json
delete-branch: true
labels: performance