Repository navigation
152 lines (124 loc) · 3.9 KB
/
Copy pathci.yml
File metadata and controls
152 lines (124 loc) · 3.9 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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
pull-requests: read
security-events: write
jobs:
go-test:
name: Go Tests
runs-on: ubuntu-latest
strategy:
matrix:
# go.mod requires 1.25; anything older cannot build this module.
go-version: ['1.25', '1.26']
steps:
- name: Check out code
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Download dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Run go vet
run: go vet ./...
# -race is not optional here. The session holds cipher state behind a
# mutex and is documented as safe for concurrent use; a data race in that
# path is a nonce-reuse bug, not a flake.
- name: Run tests
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Upload coverage to Codecov
if: matrix.go-version == '1.25'
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
flags: go
name: go-coverage
continue-on-error: true
go-lint:
name: Go Lint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: '1.25'
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.6.1
args: --timeout=5m
go-security:
name: Go Security Scan
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: '1.25'
cache: true
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: '-no-fail -fmt sarif -out results.sarif ./...'
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v4.37.3
with:
sarif_file: results.sarif
govulncheck:
name: Vulnerability Check
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: '1.25'
cache: true
# A cryptographic library inherits the vulnerabilities of what it links.
# This catches an advisory against flynn/noise or x/crypto without waiting
# for someone to notice the Dependabot mail.
- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
quality:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v7
- name: Check for TODOs on main
if: github.ref == 'refs/heads/main'
run: |
if grep -rn "TODO\|FIXME\|XXX" --include="*.go" .; then
echo "Found TODO/FIXME/XXX on main"
exit 1
fi
- name: Check for debug statements
run: |
if grep -rn "fmt.Print\|log.Print" --include="*.go" --exclude="*_test.go" .; then
echo "Found debug print statements in production code"
exit 1
fi
# The protocol name is load-bearing: it is what reviewers and interop
# partners rely on. A suite change that forgets to update the advertised
# name would be a silent interop break, so the assertion is a build gate
# rather than only a unit test.
- name: Assert the advertised protocol name matches the suite
run: go test -run TestProtocolName_matchesSuite -v ./...