99 - main
1010 workflow_dispatch :
1111
12+ permissions :
13+ contents : read # to fetch code (actions/checkout)
14+
15+ env :
16+ # run coverage and benchmarks only with the latest Go version
17+ LATEST_GO_VERSION : 1.19
18+
1219jobs :
1320 test :
1421 strategy :
2431 steps :
2532 - name : Checkout Code
2633 uses : actions/checkout@v3
27- with :
28- ref : ${{ github.ref }}
2934
3035 - name : Set up Go ${{ matrix.go }}
3136 uses : actions/setup-go@v3
@@ -35,21 +40,47 @@ jobs:
3540 - name : Run Tests
3641 run : go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
3742
38- - name : Install dependencies for checks
39- run : |
40- go install golang.org/x/lint/golint@latest
41- go install honnef.co/go/tools/cmd/staticcheck@latest
42-
43- - name : Run golint
44- run : golint -set_exit_status ./...
45-
46- - name : Run staticcheck
47- run : staticcheck ./...
48-
4943 - name : Upload coverage to Codecov
50- if : success() && matrix.go == 1.19 && matrix.os == 'ubuntu-latest'
44+ if : success() && matrix.go == env.LATEST_GO_VERSION && matrix.os == 'ubuntu-latest'
5145 uses : codecov/codecov-action@v3
5246 with :
5347 token :
5448 fail_ci_if_error : false
5549
50+ benchmark :
51+ needs : test
52+ name : Benchmark comparison
53+ runs-on : ubuntu-latest
54+ steps :
55+ - name : Checkout Code (Previous)
56+ uses : actions/checkout@v3
57+ with :
58+ ref : ${{ github.base_ref }}
59+ path : previous
60+
61+ - name : Checkout Code (New)
62+ uses : actions/checkout@v3
63+ with :
64+ path : new
65+
66+ - name : Set up Go ${{ matrix.go }}
67+ uses : actions/setup-go@v3
68+ with :
69+ go-version : ${{ env.LATEST_GO_VERSION }}
70+
71+ - name : Install Dependencies
72+ run : go install golang.org/x/perf/cmd/benchstat@latest
73+
74+ - name : Run Benchmark (Previous)
75+ run : |
76+ cd previous
77+ go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt
78+
79+ - name : Run Benchmark (New)
80+ run : |
81+ cd new
82+ go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt
83+
84+ - name : Run Benchstat
85+ run : |
86+ benchstat previous/benchmark.txt new/benchmark.txt
0 commit comments