-
Notifications
You must be signed in to change notification settings - Fork 378
62 lines (60 loc) · 2.2 KB
/
benchmark.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
name: benchmark
on:
push:
tags:
- v*
branches:
- main
pull_request:
env:
GO111MODULE: "on"
GOPROXY: https://proxy.golang.org
permissions:
# none-all, which doesn't exist, but
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow
# implies that the token still gets created. Elsewhere we learn that any
# permission not mentioned here gets turned to `none`.
actions: none
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: '^1.x'
- uses: actions/checkout@v4
- uses: actions/cache@v3
id: cache
with:
path: |
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac)
'%LocalAppData%\go-build' # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: install deps
if: steps.cache.output.cache-hit != 'true'
run: make --debug install_deps
- name: restore base benchmark result
uses: actions/cache@v3
with:
path: |
test-results/benchmark-results-main.txt
# Use base sha for PR, or new commit hash when in a push on main, in benchmark result key.
key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
- name: run benchmark
run: |
# If on a pull_request(_target) then GITHUB_HEAD_REF else strip all
# but last part of GITHUB_REF (i.e. on a push to branch)
BENCH_COUNT=5 HEAD_REF=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}} make --debug benchstat
ls -al test-results
mkdir -p benchmark-comment
cp test-results/benchstat.txt benchmark-comment
echo ${{ github.event.number }} > benchmark-comment/pr-number
- uses: actions/upload-artifact@v4
if: always ()
with:
name: benchmark-comment
path: benchmark-comment/