-
-
Notifications
You must be signed in to change notification settings - Fork 504
78 lines (64 loc) · 2.11 KB
/
bench_parser.yml
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
# Parser benchmark, compares main and PR branch with Criterion.
# Comment with text containing `!bench_parser`, a new result will be commented at the bottom of this PR.
name: Parser Benchmark
on:
issue_comment:
types: [created]
env:
RUST_LOG: info
jobs:
bench:
permissions:
pull-requests: write
name: Bench
if: github.event.issue.pull_request && contains(github.event.comment.body, '!bench_parser')
runs-on: ubuntu-latest
steps:
- name: Get PR SHA
id: sha
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const response = await github.request(context.payload.issue.pull_request.url);
return response.data.head.sha;
- name: Checkout PR Branch
uses: actions/checkout@v4
with:
ref: ${{ steps.sha.outputs.result }}
- name: Install toolchain
uses: moonrepo/setup-rust@v1
- name: Install critcmp
run: cargo install critcmp
- name: Compile
run: cargo build --release --locked -p xtask_bench
- name: Run Bench on PR Branch
run: cargo bench_parser --save-baseline pr
- name: Checkout Main Branch
uses: actions/checkout@v4
with:
clean: false
ref: main
- name: Run Bench on Main Branch
run: cargo bench_parser --save-baseline main
- name: Compare Bench Results
id: bench_comparison
shell: bash
run: |
echo "### Parser Benchmark Results" > output
echo "\`\`\`" >> output
critcmp main pr >> output
echo "\`\`\`" >> output
cat output
echo "comment<<EOF" >> $GITHUB_OUTPUT
cat output >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Write a new comment
uses: peter-evans/create-or-update-comment@v3
continue-on-error: true
with:
issue-number: ${{ github.event.issue.number }}
body: |
${{ steps.bench_comparison.outputs.comment }}
- name: Remove Criterion Artifact
run: rm -rf ./target/criterion