-
Notifications
You must be signed in to change notification settings - Fork 14
271 lines (231 loc) · 7.84 KB
/
Copy pathci.yml
File metadata and controls
271 lines (231 loc) · 7.84 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: CI
on:
pull_request:
branches: [ main, 'release/**' ]
push:
branches: [ main, 'release/**' ]
env:
GO_VERSION: '1.26.6'
GOFLAGS: '-trimpath'
permissions:
contents: read
jobs:
secret-detection:
name: Secret Detection
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for comprehensive scanning
- name: Set up Python
run: |
# Ensure Python and pip are available
python3 --version
pip3 --version
- name: Install detect-secrets
run: |
# Install detect-secrets from PyPI with user flag to avoid permission issues
pip3 install --user detect-secrets
# Add user bin to PATH
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Run detect-secrets scan
run: |
# Scan for new secrets not in baseline
echo "Scanning for secrets..."
if detect-secrets scan --baseline .secrets.baseline --all-files; then
echo "No new secrets detected!"
else
echo "New secrets detected!"
echo "::error::New secrets found that are not in the baseline"
echo ""
echo "To fix this:"
echo "1. Review the detected secrets above"
echo "2. If they are false positives, run: detect-secrets scan --update .secrets.baseline"
echo "3. If they are real secrets, remove them from the code"
echo "4. Commit the updated .secrets.baseline file"
exit 1
fi
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Download dependencies
run: go mod download
- name: Clean previous lint cache
run: |
rm -rf ~/.cache/golangci-lint || true
mkdir -p ~/.cache/golangci-lint
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --timeout=5m
# otelcol/auth/sakauth is a separate Go module, so the root run above does
# not descend into it. It resolves the same root .golangci.yml.
- name: Run golangci-lint (sakauth module)
uses: golangci/golangci-lint-action@v8
with:
version: latest
working-directory: otelcol/auth/sakauth
args: --timeout=5m
- name: Check license headers in third_party
run: |
missing=$(find third_party -name "*.go" | xargs grep -rL "Copyright\|SPDX" 2>/dev/null)
if [ -n "$missing" ]; then
echo "ERROR: missing license header in:"
echo "$missing" | sed 's/^/ /'
exit 1
fi
- name: Run govulncheck
run: make vuln
unit_test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Download dependencies
run: go mod download
- name: Clean previous test artifacts
run: |
rm -rf ./coverage || true
mkdir -p ./coverage
- name: Run unit tests
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
# "file" was renamed to "files" in v5.
files: ./coverage/coverage.out
flags: unittests
name: codecov-umbrella
# Coverage upload is informational; a Codecov outage must not fail CI.
fail_ci_if_error: false
build_check:
name: Build Check
runs-on: ubuntu-latest
needs: [lint]
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Download dependencies
run: go mod download
- name: Install ARM64 cross compiler
if: matrix.goarch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Clean previous build artifacts
run: |
rm -f fleetint-${{ matrix.goos }}-${{ matrix.goarch }} || true
- name: Build all packages
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 1
CC: ${{ matrix.goarch == 'arm64' && 'aarch64-linux-gnu-gcc' || 'gcc' }}
CXX: ${{ matrix.goarch == 'arm64' && 'aarch64-linux-gnu-g++' || 'g++' }}
run: go build ./...
- name: Smoke build main binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 1
CC: ${{ matrix.goarch == 'arm64' && 'aarch64-linux-gnu-gcc' || 'gcc' }}
CXX: ${{ matrix.goarch == 'arm64' && 'aarch64-linux-gnu-g++' || 'g++' }}
run: go build -o fleetint-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/fleetint
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: fleetint-${{ matrix.goos }}-${{ matrix.goarch }}
path: fleetint-${{ matrix.goos }}-${{ matrix.goarch }}
retention-days: 7
build_check_otelcol:
name: Build Check (otelcol)
runs-on: ubuntu-latest
needs: [lint]
strategy:
matrix:
goarch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# This job installs and executes third-party tooling (the OTel
# Collector Builder and its transitive dependencies). Do not leave
# GITHUB_TOKEN in the git config where that tooling can read it.
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Install OTel Collector Builder
run: go install go.opentelemetry.io/collector/cmd/builder@v0.156.0
- name: Build fleetint-otelcol
working-directory: otelcol
env:
GOOS: linux
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: builder --config=otelcol-builder.yaml
# The sakauth unit and config tests run in the unit_test job, since
# `make test` now descends into the nested module. This step covers only
# the integration test, which needs the collector binary built above and
# self-skips without FLEETINT_OTELCOL_INTEGRATION=1.
# Only on amd64: the runner cannot execute arm64 test binaries.
- name: Run OTel gateway integration test
if: matrix.goarch == 'amd64'
working-directory: otelcol/auth/sakauth
env:
FLEETINT_OTELCOL_INTEGRATION: "1"
run: go test -race -run '^TestCollectorGatewayEndToEnd$' .
codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Download dependencies
run: go mod download
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: go
build-mode: manual
env:
CODEQL_EXTRACTOR_GO_BUILD_TRACING: on
- name: Build with CodeQL
run: go build ./...
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:go"