-
Notifications
You must be signed in to change notification settings - Fork 23
66 lines (60 loc) · 1.99 KB
/
main-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
63
64
65
66
name: Benchmark main
## Only trigger tests if source is changing
on:
push:
branches:
- main
paths:
- '**.go'
- '**.mod'
- 'go.sum'
- .github/workflows/main-benchmark.yml
permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write
jobs:
go-bench:
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Import environment variables from file
run: cat ".github/env" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ">=${{ env.golang-version }}"
cache: false
- name: Run benchmark
run: make benchmark/go | tee benchmark.txt
# Remove log statements and leave just the benchmark results
- name: Cleanup benchmark file
run: sed -i -n '/goos:/,$p' benchmark.txt
# Download previous benchmark result from cache (if exists)
- name: Download previous benchmark data
uses: actions/cache/restore@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-benchmark-
# Run `github-action-benchmark` action
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
# What benchmark tool the output.txt came from
tool: 'go'
# Where the output from the benchmark tool is stored
output-file-path: benchmark.txt
# Where the previous data file is stored
external-data-json-path: ./cache/benchmark-data.json
save-data-file: true
- name: Save benchmark data
uses: actions/cache/save@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark-${{ github.run_id }}