Skip to content

Commit 2172815

Browse files
committed
Refacotr CI flow process
1 parent dda13bd commit 2172815

File tree

2 files changed

+93
-14
lines changed

2 files changed

+93
-14
lines changed

.github/workflows/checks.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Run checks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read # to fetch code (actions/checkout)
14+
15+
env:
16+
# run static analysis only with the latest Go version
17+
LATEST_GO_VERSION: 1.19
18+
19+
jobs:
20+
check:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout Code
24+
uses: actions/checkout@v3
25+
26+
- name: Set up Go ${{ matrix.go }}
27+
uses: actions/setup-go@v3
28+
with:
29+
go-version: ${{ env.LATEST_GO_VERSION }}
30+
check-latest: true
31+
32+
- name: Run golint
33+
run: |
34+
go install golang.org/x/lint/golint@latest
35+
golint -set_exit_status ./...
36+
37+
- name: Run staticcheck
38+
run: |
39+
go install honnef.co/go/tools/cmd/staticcheck@latest
40+
staticcheck ./...
41+
42+
- name: Run govulncheck
43+
run: |
44+
go version
45+
go install golang.org/x/vuln/cmd/govulncheck@latest
46+
govulncheck ./...
47+
48+

.github/workflows/echo.yml

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ on:
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+
1219
jobs:
1320
test:
1421
strategy:
@@ -24,8 +31,6 @@ jobs:
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

Comments
 (0)