1818 uses : actions/setup-go@v4
1919 with :
2020 go-version-file : ' ./go.mod'
21- check-latest : true
2221 - name : golangci-lint
2322 uses : golangci/golangci-lint-action@v3
2423 with :
3433 uses : actions/setup-go@v4
3534 with :
3635 go-version-file : ' ./go.mod'
37- check-latest : true
3836 - name : Unit Tests
39- run : make t
37+ run : make t
38+ bench :
39+ runs-on : ubuntu-latest
40+ timeout-minutes : 5
41+ steps :
42+ - name : Checkout code
43+ uses : actions/checkout@v3
44+ with :
45+ fetch-depth : 0 # to be able to retrieve the last commit in master branch
46+
47+ - name : Set up Go
48+ uses : actions/setup-go@v4
49+ with :
50+ go-version-file : ' ./go.mod'
51+ cache-dependency-path : ' ./go.sum'
52+ check-latest : true
53+
54+ - name : Run benchmark and store the output to a file
55+ run : |
56+ set -o pipefail
57+ make bench | tee ${{ github.sha }}_bench_output.txt
58+
59+ - name : Get Master branch SHA
60+ id : get-master-branch-sha
61+ run : |
62+ SHA=$(git rev-parse origin/master)
63+ echo "sha=$SHA" >> $GITHUB_OUTPUT
64+
65+ - name : Try to get benchmark JSON from master branch
66+ uses : actions/cache/restore@v3
67+ id : cache
68+ with :
69+ path : ./cache/benchmark-data.json
70+ key : ${{ steps.get-master-branch-sha.outputs.sha }}-${{ runner.os }}-go-benchmark
71+
72+ - name : Compare benchmarks with master
73+ uses : benchmark-action/github-action-benchmark@v1
74+ if : steps.cache.outputs.cache-hit == 'true'
75+ with :
76+ # What benchmark tool the output.txt came from
77+ tool : ' go'
78+ # Where the output from the benchmark tool is stored
79+ output-file-path : ${{ github.sha }}_bench_output.txt
80+ # Where the benchmarks in master are (to compare)
81+ external-data-json-path : ./cache/benchmark-data.json
82+ # Do not save the data
83+ save-data-file : false
84+ # Workflow will fail when an alert happens
85+ fail-on-alert : true
86+ github-token : ${{ secrets.GITHUB_TOKEN }}
87+ # Enable Job Summary for PRs
88+ summary-always : true
89+
90+ - name : Run benchmarks
91+ uses : benchmark-action/github-action-benchmark@v1
92+ if : steps.cache.outputs.cache-hit != 'true'
93+ with :
94+ # What benchmark tool the output.txt came from
95+ tool : ' go'
96+ # Where the output from the benchmark tool is stored
97+ output-file-path : ${{ github.sha }}_bench_output.txt
98+ # Write benchmarks to this file, do not publish to Github Pages
99+ save-data-file : false
100+ external-data-json-path : ./cache/benchmark-data.json
101+ # Workflow will fail when an alert happens
102+ fail-on-alert : true
103+ # Enable alert commit comment
104+ github-token : ${{ secrets.GITHUB_TOKEN }}
105+ comment-on-alert : true
106+ # Enable Job Summary for PRs
107+ summary-always : true
0 commit comments