Skip to content

Commit ee6135d

Browse files
Use only actions/checkout and do parallel benchmark.
1 parent 0bfaff0 commit ee6135d

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

.github/workflows/bench.yml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ on:
99
pull_request:
1010

1111
jobs:
12-
benchmark:
12+
benchmark-pr:
1313
runs-on: ubuntu-latest
14+
outputs:
15+
result: ${{ steps.benchmark.outputs.result }}
1416
steps:
1517
- name: Setup go
1618
uses: actions/setup-go@v5
@@ -20,14 +22,40 @@ jobs:
2022
uses: actions/checkout@v4
2123

2224
- name: Run benchmark on commit
23-
run: go test -bench=. -benchmem -count=20 -run=^# > pr.bench
25+
id: benchmark
26+
run: |
27+
echo "result<<EOF" >> "$GITHUB_OUTPUT"
28+
go test -bench=. -benchmem -count=20 -run=^# >> "$GITHUB_OUTPUT"
29+
echo "EOF" >> "$GITHUB_OUTPUT"
2430
31+
benchmark-master:
32+
runs-on: ubuntu-latest
33+
outputs:
34+
result: ${{ steps.benchmark.outputs.result }}
35+
steps:
36+
- name: Setup go
37+
uses: actions/setup-go@v5
38+
with:
39+
go-version: "1.21"
2540
- name: Switch to master branch
26-
run: git checkout master
41+
uses: actions/checkout@v4
42+
with:
43+
ref: master
2744
- name: Run benchmark on master
28-
id: benchmark-master
29-
run: go test -bench=. -benchmem -count=20 -run=^# > master.bench
45+
id: benchmark
46+
run: |
47+
echo "result<<EOF" >> "$GITHUB_OUTPUT"
48+
go test -bench=. -benchmem -count=20 -run=^# >> "$GITHUB_OUTPUT"
49+
echo "EOF" >> "$GITHUB_OUTPUT"
3050
51+
benchmark:
52+
runs-on: ubuntu-latest
53+
needs: [benchmark-pr, benchmark-master]
54+
steps:
55+
- name: Setup go
56+
uses: actions/setup-go@v5
57+
with:
58+
go-version: "1.21"
3159
- name: Restore benchstat
3260
id: cache-benchstat
3361
uses: actions/cache@v3
@@ -47,6 +75,8 @@ jobs:
4775
- name: Compare benchmarks
4876
id: compare
4977
run: |
78+
echo "${{ needs.benchmark-pr.outputs.result }}" > pr.bench
79+
echo "${{ needs.benchmark-master.outputs.result }}" > master.bench
5080
echo "STAT<<EOF" >> "$GITHUB_OUTPUT"
5181
benchstat pr.bench master.bench >> "$GITHUB_OUTPUT"
5282
echo "EOF" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)