-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (75 loc) · 2.72 KB
/
code-quality.yml
File metadata and controls
92 lines (75 loc) · 2.72 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
name: Code Quality
# This workflow checks code quality: formatting, linting, security, and dependency verification
on:
pull_request:
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- 'openapi.yaml'
- '.spectral.yaml'
- '.github/workflows/code-quality.yml'
concurrency:
group: code-quality-${{ github.head_ref }}
cancel-in-progress: true
jobs:
code-quality:
name: Code Quality Checks
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Set up Node (for Spectral)
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: '20'
- name: Lint OpenAPI spec
run: npx --yes @stoplight/spectral-cli@6 lint openapi.yaml
- name: Set up Go
id: setup-go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff
with:
go-version: '1.26.0'
- name: Cache Go modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: go mod download
- name: Verify go.mod and go.sum
run: |
go mod verify
go mod tidy
git diff --exit-code go.mod go.sum || (echo "Error: go.mod or go.sum are out of sync. Run 'go mod tidy' and commit the changes." && exit 1)
# Pin tool versions for reproducible builds (must match Makefile)
# Cache key includes Go version so tools are rebuilt when Go upgrades
- name: Cache development tools
id: cache-tools
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: |
~/go/bin/golangci-lint
~/go/bin/govulncheck
key: ${{ runner.os }}-go${{ steps.setup-go.outputs.go-version }}-lint2.10.1-vuln1.1.4
- name: Install development tools
if: steps.cache-tools.outputs.cache-hit != 'true'
run: |
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.10.1
go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
- name: Format check (make fmt)
run: |
make fmt
git diff --exit-code . || (echo "Error: code is not formatted. Run 'make fmt' and commit the changes." && exit 1)
- name: Run linter
run: golangci-lint run --timeout 10m ./...
- name: Security scan
run: govulncheck ./...
- name: Verify build
run: go build ./...