9
9
- main
10
10
workflow_dispatch :
11
11
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
+
12
19
jobs :
13
20
test :
14
21
strategy :
24
31
steps :
25
32
- name : Checkout Code
26
33
uses : actions/checkout@v3
27
- with :
28
- ref : ${{ github.ref }}
29
34
30
35
- name : Set up Go ${{ matrix.go }}
31
36
uses : actions/setup-go@v3
@@ -35,21 +40,47 @@ jobs:
35
40
- name : Run Tests
36
41
run : go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
37
42
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
-
49
43
- 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'
51
45
uses : codecov/codecov-action@v3
52
46
with :
53
47
token :
54
48
fail_ci_if_error : false
55
49
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