-
Notifications
You must be signed in to change notification settings - Fork 26
119 lines (103 loc) · 3.51 KB
/
lint.yml
File metadata and controls
119 lines (103 loc) · 3.51 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
name: Lint and Scan
on:
# Only run on PRs targeting master
pull_request:
branches: [ master ]
types: [opened, synchronize, reopened]
# For direct pushes to master only
push:
branches: [ master ]
paths-ignore:
- '**.md'
- 'docs/**'
- '.github/**'
- '!.github/workflows/lint.yml'
# Prevent duplicate workflow runs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
golangci:
name: Go Linting
runs-on: ubuntu-latest
# Allow job to succeed even with lint issues for now
continue-on-error: true
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.26.x
cache: true
# Simple linting first using standard go tools
- name: Run go fmt
run: |
go fmt ./...
- name: Run go vet
run: |
go vet ./...
- name: Run golangci-lint
id: lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
gosec-issues:
name: Security Scan Issues
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
# Fail only on high severity issues
- name: Run gosec security scan
uses: securego/gosec@master
with:
args: -exclude-generated -fmt=json -out=results.json ./...
- name: Check for high severity issues
run: |
if [ ! -f results.json ]; then
echo "Error: gosec scan results not found"
exit 1
fi
# Check if any high severity issues exist (level 3)
HIGH_ISSUES=$(cat results.json | grep -c '"severity":"HIGH"' || true)
if [ "$HIGH_ISSUES" -gt 0 ]; then
echo "Found $HIGH_ISSUES high severity security issues!"
cat results.json | grep -A 5 -B 5 '"severity":"HIGH"'
exit 1
else
echo "No high severity security issues found."
fi
- name: Upload security scan results
if: always() # Run even if previous steps failed
uses: actions/upload-artifact@v7
with:
name: gosec-results
path: results.json
retention-days: 7
if-no-files-found: warn
license-check:
name: License Compliance
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.26.x
- name: Check License Headers
run: |
# Only check Go files that aren't in vendor or generated
echo "Checking for Apache License headers in Go files..."
# Store files missing license in a variable
MISSING_LICENSE=$(find . -name "*.go" -type f -not -path "*/vendor/*" -not -path "*/mocks/*" | xargs grep -L "Licensed under the Apache License" || true)
# If any files are missing license headers, report and exit with error
if [ -n "$MISSING_LICENSE" ]; then
echo "ERROR: The following files are missing Apache License headers:"
echo "$MISSING_LICENSE"
echo "License check failed. Please add the appropriate license headers."
exit 1
else
echo "License check passed. All files have proper license headers."
fi