-
Notifications
You must be signed in to change notification settings - Fork 11
73 lines (60 loc) · 2.08 KB
/
benchmark.yml
File metadata and controls
73 lines (60 loc) · 2.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
name: Benchmark
on:
workflow_run:
workflows: ["Publish"]
types: [completed]
workflow_dispatch:
permissions: {}
jobs:
benchmark:
runs-on: ubuntu-latest
if: >-
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success'
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: "22"
- run: npm install
- name: Run benchmark
run: node scripts/benchmark.js 2>/dev/null > benchmark-result.json
- name: Update report
run: node scripts/update-benchmark-report.js benchmark-result.json
- name: Check for changes
id: changes
run: |
if git diff --quiet HEAD -- generated/BENCHMARKS.md README.md; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit and push via PR
if: steps.changes.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
BRANCH="benchmark/update-$(date +%Y%m%d-%H%M%S)"
git checkout -b "$BRANCH"
git add generated/BENCHMARKS.md README.md
git commit -m "docs: update performance benchmarks"
git push origin "$BRANCH"
gh pr create \
--base main \
--head "$BRANCH" \
--title "docs: update performance benchmarks" \
--body "Automated benchmark update from workflow run [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
- name: Upload result artifact
uses: actions/upload-artifact@v4
with:
name: benchmark-result
path: benchmark-result.json