1name: Benchmarks
2on:
3 workflow_dispatch:
4 push:
5 branches:
6 - master
7
8permissions:
9 # deployments permission to deploy GitHub pages website
10 deployments: write
11 # contents permission to update benchmark contents in gh-pages branch
12 contents: write
13
14jobs:
15 benchmark:
16 name: Performance regression check
17 runs-on: ubuntu-latest
18 steps:
19 - uses: actions/checkout@v2
20 - uses: actions/setup-go@v1
21 # Run benchmark with `go test -bench` and stores the output to a file
22 - name: Run benchmark
23 run: go test -v ./... -bench=. -run=xxx -benchmem | tee output.txt
24 # Download previous benchmark result from cache (if exists)
25 - name: Download previous benchmark data
26 uses: actions/cache@v1
27 with:
28 path: ./cache
29 key: ${{ runner.os }}-benchmark
30 # Run `github-action-benchmark` action
31 - name: Store benchmark result
32 uses: benchmark-action/github-action-benchmark@v1
33 with:
34 # What benchmark tool the output.txt came from
35 tool: 'go'
36 # Where the output from the benchmark tool is stored
37 output-file-path: output.txt
38 # Where the previous data file is stored
39 external-data-json-path: ./cache/benchmark-data.json
40 # Workflow will fail when an alert happens
41 fail-on-alert: false
42 # GitHub API token to make a commit comment
43 github-token: ${{ secrets.GITHUB_TOKEN }}
44 # Enable alert commit comment
45 comment-on-alert: true
46 # Push and deploy GitHub pages branch automatically
47 auto-push: true