-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (151 loc) · 5.46 KB
/
ci.yml
File metadata and controls
182 lines (151 loc) · 5.46 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
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
GO_VERSION: '1.26'
GOLANGCI_LINT_VERSION: 'v2.11.2'
jobs:
# ===========================================================================
# Lint Job
# ===========================================================================
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout=5m
- name: Check formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Code is not formatted. Run 'gofmt -w .'"
gofmt -d .
exit 1
fi
- name: Check go mod tidy
run: |
go mod tidy
git diff --exit-code go.mod go.sum
# ===========================================================================
# Test Job
# ===========================================================================
test:
name: Test (Go ${{ matrix.go-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ['1.26']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Download dependencies
run: go mod download
- name: Run tests with race detector
run: go test -v -race -coverprofile=coverage.out -covermode=atomic $(go list ./... | grep -v "/examples")
- name: Check coverage threshold
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Total coverage: ${COVERAGE}%"
if (( $(echo "$COVERAGE < 90" | bc -l) )); then
echo "FAIL: Coverage ${COVERAGE}% is below 90% threshold"
exit 1
fi
echo "PASS: Coverage ${COVERAGE}% meets 90% threshold"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
with:
file: ./coverage.out
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.go-version }}
path: coverage.out
# ===========================================================================
# Security Job
# ===========================================================================
security:
name: Security Scan
runs-on: ubuntu-latest
permissions:
security-events: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: '-no-fail -fmt sarif -out gosec-results.sarif -exclude-dir examples -exclude-dir safedeserialize/examples ./...'
- name: Fix SARIF relationships format
if: always()
run: |
jq '.runs[].tool.driver.rules |= if type == "array" then map(if has("relationships") and (.relationships | type) == "array" then .relationships |= map(select(type == "object")) else . end) else [] end' \
gosec-results.sarif > gosec-results-fixed.sarif
mv gosec-results-fixed.sarif gosec-results.sarif
- name: Upload Gosec SARIF
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: gosec-results.sarif
- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
- name: Run Nancy (Dependency Scanner)
run: |
go install github.com/sonatype-nexus-community/nancy@latest
go list -json -deps ./... | nancy sleuth || true
# ===========================================================================
# Agentic Fix Job — AST-based analysis with CWE-mapped fix suggestions
# ===========================================================================
agentic-fix:
name: Agentic Fix Analysis
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Test new packages (analyzer, middleware, safedecode)
run: go test ./analyzer/... ./middleware/... ./safedecode/... -v -count=1
- name: Run Agentic Analyzer
# Emits ::warning annotations inline on PR diffs for each finding.
# -exit-zero keeps the job green; remove it to make the job a hard gate.
run: go run ./cmd/analyzer/... -dir . -exit-zero
- name: Run Agentic Analyzer (JSON report)
run: go run ./cmd/analyzer/... -dir . -fmt json -exit-zero > agentic-findings.json
- name: Upload findings artifact
uses: actions/upload-artifact@v4
with:
name: agentic-findings
path: agentic-findings.json