This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 168
72 lines (60 loc) · 1.99 KB
/
benchmark.yaml
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
name: Benchmarks
on:
pull_request:
branches: [ '**' ]
types: [opened, synchronize, reopened, labeled]
env:
PROMSCALE_LOGGING: false
SKIP_PROMQL_BENCHMARKS: true
golang-version: 1.19.4
jobs:
benchmark:
if: contains( github.event.pull_request.labels.*.name, 'action:benchmarks')
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@v3
- name: Set up Go ${{ env.golang-version }}
uses: actions/[email protected]
with:
go-version: ${{ env.golang-version }}
id: go
- name: Benchmark current PR
run: go test -bench=. -run=^$ -benchmem -cpu=1 -count=10 -timeout=6h ./... | tee current.txt
- name: Upload results
uses: actions/upload-artifact@v3
with:
name: current
path: current.txt
- name: Checkout master branch
uses: actions/checkout@v3
with:
ref: 'master'
- name: Benchmark Master
run: go test -bench=. -run=^$ -benchmem -cpu=1 -count=10 -timeout=6h ./... | tee master.txt
- name: Download results of "Benchmark current PR"
uses: actions/download-artifact@v3
with:
name: current
- name: Install benchstat
run: go install -a golang.org/x/perf/cmd/benchstat@latest
- name: Compare
id: compare
run: |
OUTPUT=$(benchstat master.txt current.txt)
echo "${OUTPUT}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "result=$OUTPUT" >> ${GITHUB_OUTPUT}
- name: Publish results as comment
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: compare
message: |
@${{ github.event.pull_request.user.login }}
## Benchmark Result for **${{ github.sha }}**
### Master vs PR
```
${{ steps.compare.outputs.result }}
```