forked from truvami/decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
252 lines (207 loc) · 6.71 KB
/
Copy pathci.yml
File metadata and controls
252 lines (207 loc) · 6.71 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
# Cancel older runs of the same branch/PR to save minutes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Default to least privilege; Codecov only needs these for OIDC upload & (optionally) PR comments
permissions:
contents: read
id-token: write
pull-requests: write
attestations: write
env:
GOFLAGS: -mod=readonly
jobs:
commitlint:
name: Commit message lint (conventional commits)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install commitlint dependencies
run: npm i --no-save --no-package-lock @commitlint/cli @commitlint/config-conventional
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --last --verbose
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
lint:
name: Lint (fmt + vet [+ staticcheck])
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.24.0"
cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install yamllint
- name: go mod tidy check
run: |
cp go.mod go.mod.prev
cp go.sum go.sum.prev
go mod tidy
diff -u go.mod.prev go.mod || (echo "::error file=go.mod::Run 'go mod tidy' and commit changes."; exit 1)
diff -u go.sum.prev go.sum || (echo "::error file=go.sum::Run 'go mod tidy' and commit changes."; exit 1)
- name: go fmt (no diffs allowed)
run: |
# Lists files that would change if formatted; fail if any are returned
CHANGED=$(gofmt -s -l . || true)
if [ -n "$CHANGED" ]; then
echo "::error ::Run 'gofmt -s -w .' to format:"
echo "$CHANGED"
exit 1
fi
- name: go vet
run: go vet ./...
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
- name: staticcheck
run: $(go env GOPATH)/bin/staticcheck ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.1
- name: Run JSON tags camelCase check
run: make check-json-tags
- name: Check Prometheus metrics
run: make check-metrics
- name: Run yamllint
run: yamllint .
detect-secrets:
name: Detect secrets (baseline check)
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install detect-secrets
run: |
pip install detect-secrets
- name: Detect secrets
run: |
echo "🔍 Scanning for secrets..."
if command -v detect-secrets >/dev/null 2>&1; then
detect-secrets scan --baseline .secrets.baseline --all-files || echo "Secret detection completed with findings"
if [ -f ".secrets.baseline" ]; then
detect-secrets audit .secrets.baseline --statistics || echo "Baseline audit completed"
fi
else
echo "detect-secrets not available, skipping secret scan (basic validation will still run)"
fi
test:
name: Test (matrix)
needs: lint
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
go: ["1.24.x", "1.25.x"]
include:
# Run race+coverage once on Linux with the newest Go
- os: ubuntu-latest
go: "1.24.x"
coverage: true
runs-on: ${{ matrix.os }}
env:
ENV: test
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: true
- name: Verify modules
run: |
go mod verify
- name: Build
run: go build ./...
# Regular tests (fast) on all OS/Go combos without race/coverage to keep CI time down
- name: Test (no race/coverage)
if: ${{ !matrix.coverage }}
run: go test ./...
# Single canonical run with race + coverage profile (Linux, newest Go)
- name: Test (race + coverage)
if: ${{ matrix.coverage }}
run: |
# Use atomic mode for consistent results under -race
go test -race -covermode=atomic -coverpkg=./... -coverprofile=cover.out ./...
- name: Upload coverage artifact
if: ${{ matrix.coverage }}
uses: actions/upload-artifact@v4
with:
name: coverage
path: cover.out
retention-days: 7
codecov:
name: Upload coverage to Codecov
needs: test
# still attempt upload even if some matrix legs fail
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download coverage artifact
uses: actions/download-artifact@v5
with:
name: coverage
path: .
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
goreleaser-snapshot:
name: GoReleaser (snapshot check)
needs: test
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.24.0"
cache: true
- uses: docker/setup-buildx-action@v3
with:
install: true
- name: GoReleaser (snapshot)
uses: goreleaser/goreleaser-action@v6
with:
version: "~> v2"
args: release --snapshot --skip=publish --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}