-
Notifications
You must be signed in to change notification settings - Fork 17
122 lines (103 loc) · 3.38 KB
/
Copy pathgeneral.yml
File metadata and controls
122 lines (103 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: General workflows
on:
push:
branches: [master]
pull_request:
branches: [master]
# Cancel superseded runs on a branch so a force-push / amend doesn't waste CI.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v5
with:
# Keep in sync with go.mod's `go` directive (currently 1.19). Using
# stable runs the newest toolchain Go will accept while still
# exercising the minimum language level declared in go.mod.
go-version: stable
check-latest: true
cache: true
- name: Verify go.mod / go.sum are tidy
run: |
go mod tidy
if ! git diff --quiet go.mod go.sum; then
echo "::error::go.mod or go.sum is not tidy — run 'go mod tidy' locally and commit."
git diff go.mod go.sum
exit 1
fi
- name: Check gofmt
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "::error::The following files are not gofmt'd:"
echo "$unformatted"
exit 1
fi
- name: go vet
run: go vet ./...
- name: go build
run: go build ./...
- name: Install mockgen
# Required by the //go:generate directives across the tree.
# Pinned to v1.6.0 to match the github.com/golang/mock dep in go.mod.
run: go install github.com/golang/mock/mockgen@v1.6.0
- name: go generate produces no diff
run: |
go generate ./...
if ! git diff --quiet; then
echo "::error::go generate produced changes — regenerate mocks locally and commit."
git status
git diff
exit 1
fi
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v5
with:
# golangci-lint v1.64.5 was built against Go 1.23. Pinning matches
# the linter's bundled type-checker version; using `stable` here
# makes typecheck fail to resolve methods promoted through embedded
# external types (e.g. testify's suite.Suite.Assert), even though
# `go build` and `go test` succeed against the same code.
go-version: '1.23'
check-latest: true
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
# Pin a recent stable release; bump with intent, not passively.
# When bumping the linter, also bump go-version above to match.
version: v1.64.5
args: --timeout=5m
test:
name: Test Coverage
runs-on: ubuntu-latest
needs: verify
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
check-latest: true
cache: true
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Unit Test
run: make test
- name: Upload coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=cover.out -service=github