-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
87 lines (84 loc) · 3.09 KB
/
Copy pathbenchmark.yml
File metadata and controls
87 lines (84 loc) · 3.09 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
name: Benchmark
on:
pull_request:
branches: [master]
workflow_dispatch:
inputs:
base:
description: 'Ref to compare this branch against'
default: master
permissions:
contents: read
jobs:
benchmark:
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: read
# the comment on the pull request. Read-only on a pull request from a fork, where the
# job summary is the only output
pull-requests: write
env:
# the PostgreSQL that comes with the runner image, over its unix socket: no container
# and no TCP between the client and the server, so the numbers are the client's.
# The role is named after the OS user, which is what peer authentication wants
PGHOST: /var/run/postgresql
PGDATABASE: benchmark
steps:
- name: Start PostgreSQL
run: |
sudo systemctl start postgresql.service
sudo -u postgres createuser "$USER"
sudo -u postgres createdb -O "$USER" benchmark
- uses: actions/checkout@v4
with:
path: head
persist-credentials: false
- uses: actions/checkout@v4
with:
path: base
ref: ${{ github.event.pull_request.base.sha || inputs.base }}
persist-credentials: false
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 26
cache: yarn
cache-dependency-path: |
head/yarn.lock
base/yarn.lock
- name: Build both arms
run: |
for arm in base head; do
(cd $arm && yarn install --frozen-lockfile && yarn build)
done
- name: Run benchmark
working-directory: head
run: node benchmark/compare.js --base ../base --head . --rounds 4 --duration 3 --output ../benchmark_summary.md
- name: Publish the summary
run: cat benchmark_summary.md >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@v4
with:
name: benchmark-summary
path: benchmark_summary.md
- name: Comment on the pull request
if: github.event_name == 'pull_request'
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
const fs = require('fs')
const marker = '<!-- benchmark-comment -->'
const body = fs.readFileSync('benchmark_summary.md', 'utf8')
const issue_number = context.payload.pull_request.number
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number,
})
const existing = comments.find((c) => c.user?.type === 'Bot' && 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, body })
}