-
Notifications
You must be signed in to change notification settings - Fork 714
362 lines (308 loc) · 10.7 KB
/
ci.yml
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: ci
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
TMPDIR: /tmp
CI_MAX_KERNEL_VERSION: '6.11'
CI_MAX_EFW_VERSION: '0.20.0'
CI_MIN_CLANG_VERSION: '11'
go_version: '~1.23'
prev_go_version: '~1.22'
CGO_ENABLED: '0'
# This needs to match whatever Netlify supports.
# Also defined in Pipfile.
python_version: '~3.8'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build-and-lint:
name: Build and Lint
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '${{ env.go_version }}'
- name: Run golangci-lint
uses: golangci/[email protected]
with:
args: "--out-format colored-line-number"
- name: Generate and format code
run: |
make clean && make container-all
if ! git diff --exit-code; then
echo "found unformatted source files, or generated files are not up to date, run 'make'" >&2
exit 1
fi
- name: Test bpf2go
run: |
sudo apt-get install clang-11 llvm-11
go test -v ./cmd/bpf2go
- name: Build examples
run: go build -v ./...
working-directory: ./examples
- name: Cross build windows
env:
GOOS: windows
run: |
go build -v ./...
go test -c -o /dev/null ./... >/dev/null
- name: Cross build arm32
env:
GOARCH: arm
GOARM: 6
run: |
go build -v ./...
go test -c -o /dev/null ./... >/dev/null
build-docs:
name: Build Documentation
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
# The mkdocs git-authors plugin needs access to the full revision
# history to correctly generate its statistics.
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '${{ env.go_version }}'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '${{ env.python_version }}'
cache: 'pipenv'
- name: Install pipenv
run: pip3 install pipenv
- name: Install Dependencies
run: pipenv install
working-directory: ./docs
- name: Build Documentation
run: make build
working-directory: ./docs
test-on-prev-go:
name: Run tests on previous stable Go
runs-on: ubuntu-latest
needs: build-and-lint
timeout-minutes: 15
env:
CI_KERNEL_SELFTESTS: '/usr/src/linux/tools/testing/selftests/bpf'
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '${{ env.prev_go_version }}'
- run: go install lmb.io/vimto@latest
- run: go install gotest.tools/[email protected]
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86
- run: sudo chmod 0666 /dev/kvm
- name: Test
env:
GOTRACEBACK: crash
run: |
gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :stable-selftests -- go test -timeout 5m -short -count 1 -json ./...
- name: Benchmark
run: vimto -kernel :stable-selftests -- go test -short -run '^$' -bench . -benchtime=1x ./...
- name: Upload coredumps
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: cores
if-no-files-found: ignore
path: |
**/core-*
**/*.test
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Test Results (previous stable Go)
path: junit.xml
test-on-arm64:
name: Run tests on arm64
runs-on: ubuntu-22.04-arm64
needs: build-and-lint
timeout-minutes: 15
env:
EBPF_TEST_IGNORE_VERSION: 'TestKprobeMulti,TestKprobeMultiErrors,TestKprobeMultiCookie,TestKprobeMultiProgramCall,TestHaveBPFLinkKprobeMulti,TestKprobeSession,TestHaveBPFLinkKprobeSession,TestHaveProgramType/LircMode2'
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '${{ env.go_version }}'
- run: go install gotest.tools/[email protected]
- name: Test
# Skip TestGoarches/loong64 because the GH arm64 Go toolchain seems to be weird.
run: gotestsum --ignore-non-json-output-lines --junitfile junit.xml -- -exec 'sudo -E' -short -count 1 -skip '^TestGoarches/loong64$' -json ./...
- name: Benchmark
run: go test -exec sudo -short -run '^$' -bench . -benchtime=1x ./...
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Test Results (arm64)
path: junit.xml
- name: Show dmesg
if: failure()
run: |
sudo dmesg
linux-test:
name: Run tests (Linux)
runs-on: ubuntu-latest
needs: build-and-lint
timeout-minutes: 15
strategy:
matrix:
tag:
- "mainline"
- "stable"
- "6.6"
- "6.1"
- "5.15"
- "5.10"
- "5.4"
- "4.19"
- "4.14"
- "4.9"
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '${{ env.go_version }}'
- run: go install gotest.tools/[email protected]
- run: go install lmb.io/vimto@latest
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86
- run: sudo chmod 0666 /dev/kvm
- name: Test
run: gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :${{ matrix.tag }} -- go test -short -count 1 -json ./...
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Test Results (linux ${{ matrix.tag }})
path: junit.xml
windows-test:
name: Run tests (Windows)
runs-on: windows-2022
needs: build-and-lint
timeout-minutes: 15
strategy:
matrix:
version:
- "main"
env:
# Fix slow Go compile and cache restore
# See https://github.com/actions/setup-go/pull/515
GOCACHE: D:\gocache
GOMODCACHE: D:\gomodcache
# Avoid putting temp on slow C:
TEMP: D:\temp
steps:
- run: mkdir D:\temp
shell: pwsh
- name: Get eBPF for Windows download URL
id: determine-url
uses: actions/github-script@v6
with:
script: |
if ("${{ matrix.version }}" != "main") {
// TODO: Workflow artifact and release artifact don't have the
// same folder structure.
core.setFailed('Installing tagged versions is not supported');
return;
}
// Get the latest successful merge_group run
const workflow_runs = await github.rest.actions.listWorkflowRuns({
owner: 'microsoft',
repo: 'ebpf-for-windows',
workflow_id: 'cicd.yml',
event: 'merge_group',
status: 'success',
per_page: 1
});
if (workflow_runs.data.workflow_runs.length === 0) {
core.setFailed('No successful merge_group workflow runs found');
return;
}
// Get artifacts from this run
const run_id = workflow_runs.data.workflow_runs[0].id;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: 'microsoft',
repo: 'ebpf-for-windows',
run_id: run_id
});
// Find the specific artifact
const artifact = artifacts.data.artifacts.find(a => a.name === 'Build-x64-Debug');
if (!artifact) {
console.log('Available artifacts:', artifacts.data.artifacts.map(a => a.name));
core.setFailed('Build-x64-Debug artifact not found in the workflow run');
return;
}
// Get the download URL via redirect
const response = await github.rest.actions.downloadArtifact({
owner: 'microsoft',
repo: 'ebpf-for-windows',
artifact_id: artifact.id,
archive_format: 'zip',
request: {
redirect: 'manual'
}
});
// Extract the location header which contains the actual download URL
const download_url = response.headers.location;
if (!download_url) {
core.setFailed('Failed to get redirect URL from headers');
return;
}
core.setOutput('download_url', download_url);
- name: Download and Install eBPF for Windows
shell: pwsh
run: |
Invoke-WebRequest -Uri "${{ steps.determine-url.outputs.download_url }}" -OutFile "$env:TEMP\efw.zip"
Expand-Archive -Path "$env:TEMP\efw.zip" -DestinationPath "$env:TEMP"
Expand-Archive -Path "$env:TEMP\build-Debug.zip" -DestinationPath "$env:TEMP\ebpf"
$setupScript = Get-ChildItem -Path "$env:TEMP\ebpf" -Filter "setup-ebpf.ps1" -Recurse | Select-Object -First 1
if ($setupScript) {
Write-Host "Found setup script: $($setupScript.FullName)"
Set-Location -Path $setupScript.DirectoryName
Write-Host "Changed directory to: $(Get-Location)"
& $setupScript.FullName
} else {
Write-Error "Setup script not found in the extracted package"
exit 1
}
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '${{ env.go_version }}'
- run: go install gotest.tools/[email protected]
- name: Test
run: >
gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml --
go test -short -count 1 -json
./asm
./internal
./internal/kallsyms
./internal/kconfig
./internal/linux
./internal/sysenc
./internal/testutils
./internal/tracefs
./internal/unix
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Test Results (windows ${{ matrix.tag }})
path: junit.xml