-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (88 loc) · 3.26 KB
/
benchmark-pr-vs-frameworks.yml
File metadata and controls
104 lines (88 loc) · 3.26 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
name: Benchmark PR vs frameworks
on:
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest
env:
npm_config_legacy_peer_deps: "true"
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install repository dependencies
run: npm ci
- name: Build repository
run: npm run build
- name: Clone benchmark suite
run: git clone --depth=1 https://github.com/milomg/js-reactivity-benchmark.git .tmp/js-reactivity-benchmark
- name: Install benchmark dependencies
working-directory: .tmp/js-reactivity-benchmark
run: pnpm install --frozen-lockfile
- name: Build benchmark core runtime bundle
working-directory: .tmp/js-reactivity-benchmark/packages/core
run: pnpm exec esbuild src/index.ts --bundle --format=esm --target=esnext --outdir=dist --sourcemap=external
- name: Run PR vs frameworks benchmark
run: node scripts/ci/benchmark-pr-vs-frameworks.mjs
env:
BENCH_CORE_DIST_DIR: .tmp/js-reactivity-benchmark/packages/core/dist
CURRENT_SIGNALS_DIR: packages/rescript-signals
BENCH_OUT_DIR: benchmark-results/ci/pr-vs-frameworks
- name: Upload benchmark artifacts
uses: actions/upload-artifact@v4
with:
name: benchmark-pr-vs-frameworks
path: benchmark-results/ci/pr-vs-frameworks
if-no-files-found: error
- name: Add workflow summary
run: |
echo "## ReScript Signals benchmark: PR vs frameworks" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
cat benchmark-results/ci/pr-vs-frameworks/pr-comment-latest.md >> "$GITHUB_STEP_SUMMARY"
- name: Upsert PR benchmark comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require("fs");
const marker = "<!-- rescript-signals-benchmark-pr-vs-frameworks -->";
const body = fs.readFileSync("benchmark-results/ci/pr-vs-frameworks/pr-comment-latest.md", "utf8");
const commentBody = `${marker}\n${body}`;
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find((c) => c.body && c.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body: commentBody,
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: commentBody,
});
}