-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (120 loc) · 5.08 KB
/
Copy pathperf.yml
File metadata and controls
139 lines (120 loc) · 5.08 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
131
132
133
134
135
136
137
138
139
name: Performance Tests
on:
push:
branches:
- main
pull_request:
paths-ignore:
- '**.md'
permissions:
contents: read
pull-requests: write
actions: read
jobs:
perf:
name: Continuous Integration
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: "1.3.6"
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Install Playwright browsers
run: bunx --bun playwright install --with-deps chromium
- name: Build
run: bunx --bun turbo run build
# ── PR: download baseline from main ────────────────────────
- name: Download baseline from main
if: github.event_name == 'pull_request'
id: baseline
uses: dawidd6/action-download-artifact@b6e2e70617bc3265edd6dab6c906732b2f1ae151 # v21
with:
name: perf-baseline
workflow: perf.yml
branch: main
path: apps/host/tests/performance/results
if_no_artifact_found: warn
- name: Rename baseline
if: github.event_name == 'pull_request'
run: |
if [ -f apps/host/tests/performance/results/last.json ]; then
mv apps/host/tests/performance/results/last.json apps/host/tests/performance/results/base.json
echo "HAVE_BASE=true" >> "$GITHUB_ENV"
else
echo "HAVE_BASE=false" >> "$GITHUB_ENV"
echo "::warning::No baseline found — run will be recorded without comparison"
fi
# ── Run perf tests ─────────────────────────────────────────
# On main: long run (baseline). On PR: shorter run (compare).
- name: Run perf tests (baseline)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
working-directory: apps/host
env:
PERF_RUNS: "20"
PERF_SAVE_BASE: "1"
PERF_DOMAIN_A: explore
PERF_DOMAIN_B: host-playground
run: bunx --bun playwright test --config=tests/performance/playwright.config.ts tests/performance/cold-start.spec.ts || true
- name: Run perf tests (PR)
if: github.event_name == 'pull_request'
working-directory: apps/host
env:
PERF_RUNS: "10"
PERF_DOMAIN_A: explore
PERF_DOMAIN_B: host-playground
run: bunx --bun playwright test --config=tests/performance/playwright.config.ts tests/performance/cold-start.spec.ts || true
# ── main: upload baseline artifact ─────────────────────────
- name: Upload baseline artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: perf-baseline
path: apps/host/tests/performance/results/last.json
retention-days: 90
overwrite: true
# ── PR: build comparison report and comment ────────────────
- name: Generate comparison
if: github.event_name == 'pull_request' && env.HAVE_BASE == 'true'
working-directory: apps/host
run: bun tests/performance/compare.ts --markdown > /tmp/perf-comment.md || true
- name: Generate standalone report
if: github.event_name == 'pull_request' && env.HAVE_BASE != 'true'
run: |
cat <<'EOF' > /tmp/perf-comment.md
## ⚡ Performance Report
> ⚠️ No baseline found on `main`. This PR's results are recorded but cannot be compared.
> Merge to `main` to establish a baseline.
EOF
- name: Post or update PR comment
if: github.event_name == 'pull_request'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const fs = require('fs');
const body = fs.readFileSync('/tmp/perf-comment.md', 'utf8');
const marker = '## ⚡ Performance Report';
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,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}