-
-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (58 loc) · 2.02 KB
/
benchmark.yml
File metadata and controls
71 lines (58 loc) · 2.02 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
name: Benchmark
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Run benchmarks
run: npm run bench:ci
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: benchmarks/results/
- name: Update README with benchmark results
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: node scripts/update-readme-benchmarks.js
- name: Commit updated results
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote set-url origin https://x-access-token:${PAT_TOKEN}@github.com/${{ github.repository }}.git
git add benchmarks/results/ README.md
git diff --staged --quiet || git commit -m "ci: update benchmark results [skip ci]"
git push
- name: Comment benchmark results on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('benchmarks/results/BENCHMARK.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 🚀 Benchmark Results\n\n${report}`
});