forked from bpfman/bpfman
-
Notifications
You must be signed in to change notification settings - Fork 0
519 lines (442 loc) · 17.8 KB
/
build.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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
name: build
on: # yamllint disable-line rule:truthy
push:
branches: [main]
tags:
- v*
pull_request:
branches:
- main
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
# Use to pin rust nightly to specific version.
NIGHTLY_VERSION: nightly-2024-09-24
jobs:
check-license:
runs-on: ubuntu-24.04
timeout-minutes: 3
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Check License Header
uses: apache/skywalking-eyes@cd7b195c51fd3d6ad52afceb760719ddc6b3ee91
build:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
arch:
- arch: amd64
rust-target: x86_64-unknown-linux-gnu
filename: linux-x86_64
command: cargo
- arch: arm64
rust-target: aarch64-unknown-linux-gnu
filename: linux-arm64
command: cross
- arch: ppc64le
rust-target: powerpc64le-unknown-linux-gnu
filename: linux-ppc64le
command: cross
- arch: s390x
rust-target: s390x-unknown-linux-gnu
filename: linux-s390x
command: cross
name: Build bpfman (${{ matrix.arch.arch }})
steps:
- name: Free up space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /usr/local/lib/android
- name: Install dependencies
# Dependencies only needed to build eBPF and used by integration-tests, only on amd64
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
sudo apt-get update
sudo apt-get install -qy \
git \
clang \
llvm \
protobuf-compiler \
cmake \
perl \
libssl-dev \
gcc-multilib \
libelf-dev \
- name: Checkout bpfman
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Checkout libbpf
# libbpf only needed to build eBPF and used by integration-tests, only on amd64
if: ${{ matrix.arch.arch == 'amd64' }}
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
with:
repository: libbpf/libbpf
path: libbpf
fetch-depth: 0
- name: Install rust toolchain - stable
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # @v1
with:
toolchain: stable
override: true
target: ${{ matrix.arch.rust-target }}
- name: Install rust toolchain - ${{ env.NIGHTLY_VERSION }}
# Only need for checks (like lint and clippy) that only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # @v1
with:
toolchain: ${{ env.NIGHTLY_VERSION }}
components: rustfmt, rust-src
override: false
# Only install cross if we need it
# Install via cargo-binstall which I found faster
- name: Install Cross
if: ${{ matrix.arch.command == 'cross' }}
shell: bash
run: |
cargo install cross --git https://github.com/cross-rs/cross
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # @v2
- name: Install cargo-llvm-cov
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
uses: taiki-e/install-action@ac87e9813a4968fd0c941361295f6d119b826393 # @cargo-llvm-cov
- name: Install toml linter
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
uses: taiki-e/install-action@e29814c376696105d80cec9e9efaa98bae8e7347 # @v2
with:
tool: taplo-cli
- name: toml-lint
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: taplo fmt --check
- name: yaml-lint
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: yamllint -c .yamllint.yaml --strict .
- name: Check C formatting
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: git ls-files -- '*.c' '*.h' | xargs clang-format --dry-run --Werror
- name: Build eBPF
# Only need to build eBPF once and used by integration-tests, only on amd64
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
${{ matrix.arch.command }} xtask build-ebpf --libbpf-dir ./libbpf
- name: Package Integration Test eBPF
# Only need to build eBPF once and used by integration-tests, only on amd64
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
tar -czvf integration-test.tar.gz tests/integration-test/bpf/.output
- name: Archive Integration Test eBPF
# Only need to build eBPF once and used by integration-tests, only on amd64
if: ${{ matrix.arch.arch == 'amd64' }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4
with:
name: bpfman-integration-test
path: |
integration-test.tar.gz
- name: Check formatting
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
cargo +${{ env.NIGHTLY_VERSION }} fmt --all -- --check
- name: Check public API
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: cargo xtask public-api --target ${{ matrix.arch.rust-target }} --toolchain ${{ env.NIGHTLY_VERSION }}
- name: Run documentation tests
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
cargo test --doc --all-features
- name: Build
run: |
${{ matrix.arch.command }} build --verbose --target ${{ matrix.arch.rust-target }}
- name: Package bpfman Binaries
# Tar and archive the build for basic-integration-tests, only on amd64
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
cd target/${{ matrix.arch.rust-target }}/debug
tar -czvf bpfman-debug-${{ matrix.arch.filename }}.tar.gz bpfman bpfman-rpc bpfman-ns bpf-metrics-exporter bpf-log-exporter
- name: Archive bpfman Binaries
# Tar and archive the build for basic-integration-tests, only on amd64
if: ${{ matrix.arch.arch == 'amd64' }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4
with:
name: bpfman-debug-${{ matrix.arch.filename }}
path: |
./target/${{ matrix.arch.rust-target }}/debug/bpfman-debug-${{ matrix.arch.filename }}.tar.gz
- name: Build manpages
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: cargo xtask build-man-page
- name: Package manpages
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
tar -czvf manpages.tar.gz .output/manpage/
- name: Archive manpages
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4
with:
name: bpfman-manpages
path: |
manpages.tar.gz
- name: Build CLI TAB Completion
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: cargo xtask build-completion
- name: Package CLI TAB Completion
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
tar -czvf cli-tab-completion.tar.gz .output/completions/
- name: Archive CLI TAB Completion
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4
with:
name: bpfman-cli-tab-completion
path: |
cli-tab-completion.tar.gz
## If the push is a tag....build and upload the release bpfman binaries to an archive
- name: Build Release
if: startsWith(github.ref, 'refs/tags/v')
run: |
${{ matrix.arch.command }} build --verbose --release --target ${{ matrix.arch.rust-target }}
- name: Package bpfman Release Binaries
if: startsWith(github.ref, 'refs/tags/v')
run: |
cd target/${{ matrix.arch.rust-target }}/release
tar -czvf bpfman-${{ matrix.arch.filename }}.tar.gz bpfman bpfman-rpc bpfman-ns bpf-metrics-exporter bpf-log-exporter
- name: Archive bpfman Release Binaries
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4
with:
name: bpfman-release-${{ matrix.arch.filename }}
path: ./target/${{ matrix.arch.rust-target }}/release/bpfman-${{ matrix.arch.filename }}.tar.gz
- name: Run Unit Tests
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
run: cargo llvm-cov test --all-features -p bpfman -p bpfman-api --lcov --output-path lcov.info
env:
RUST_BACKTRACE: full
- name: Archive Rust code coverage results
# Only need to run once
if: ${{ matrix.arch.arch == 'amd64' }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4
with:
name: coverage-rust
path: lcov.info
if-no-files-found: error
## Build go modules
build-go:
strategy:
fail-fast: false
matrix:
arch:
- arch: amd64
filename: linux-x86_64
- arch: arm64
filename: linux-arm64
- arch: ppc64le
filename: linux-ppc64le
- arch: s390x
filename: linux-s390x
runs-on: ubuntu-24.04
name: Build Go Modules (${{ matrix.arch.arch }})
steps:
- name: Checkout bpfman
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Install go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # @v5
with:
# prettier-ignore
go-version: '1.22' # yamllint disable-line rule:quoted-strings
- name: Go mod check
# Only need to run go mod once, so just pick one of the arch to run on.
if: ${{ matrix.arch.arch == 'amd64' }}
run: |
go mod tidy
git diff --exit-code go.mod go.sum
- name: Lint
# Only need to lint the code once, so just pick one of the arch to run on.
if: ${{ matrix.arch.arch == 'amd64' }}
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # @v6
with:
## https://github.com/golangci/golangci-lint-action/issues/369
version: v1.54.2
skip-cache: true
skip-save-cache: true
args: -v --timeout 5m
- name: Build Examples
run: |
cd examples
GOARCH=${{ matrix.arch.arch }} make build
basic-integration-tests:
runs-on: ubuntu-24.04
needs: [build, build-go]
steps:
- name: Set up environment for running integration tests from manual trigger
if: github.event_name == 'workflow_dispatch'
run: |
echo "XDP_PASS_IMAGE_LOC=quay.io/bpfman-bytecode/xdp_pass:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "TC_PASS_IMAGE_LOC=quay.io/bpfman-bytecode/tc_pass:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "TRACEPOINT_IMAGE_LOC=quay.io/bpfman-bytecode/tracepoint:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "UPROBE_IMAGE_LOC=quay.io/bpfman-bytecode/uprobe:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "URETPROBE_IMAGE_LOC=quay.io/bpfman-bytecode/uretprobe:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "KPROBE_IMAGE_LOC=quay.io/bpfman-bytecode/kprobe:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "KRETPROBE_IMAGE_LOC=quay.io/bpfman-bytecode/kretprobe:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "XDP_COUNTER_IMAGE_LOC=quay.io/bpfman-bytecode/go-xdp-counter:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "TC_COUNTER_IMAGE_LOC=quay.io/bpfman-bytecode/go-tc-counter:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "TCX_COUNTER_IMAGE_LOC=quay.io/bpfman-bytecode/go-tcx-counter:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "TRACEPOINT_COUNTER_IMAGE_LOC=quay.io/bpfman-bytecode/go-tracepoint-counter:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "FENTRY_IMAGE_LOC=quay.io/bpfman-bytecode/fentry:${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "FEXIT_IMAGE_LOC=quay.io/bpfman-bytecode/fexit:${GITHUB_REF_NAME}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # @v3
with:
driver-opts: network=host
- name: Checkout bpfman
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Download bpfman x86_64 build
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4
with:
name: bpfman-debug-linux-x86_64
merge-multiple: true
- name: Unpack binaries
run: |
mkdir -p target/debug
tar -C target/debug -xzvf bpfman-debug-linux-x86_64.tar.gz
- name: Download Integration Test eBPF
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4
with:
name: bpfman-integration-test
merge-multiple: true
- name: Unpack Integration Test eBPF
run: |
tar -xzvf integration-test.tar.gz
- name: Download manpages
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4
with:
name: bpfman-manpages
merge-multiple: true
- name: Unpack manpages
run: |
tar -xzvf manpages.tar.gz
- name: Download CLI TAB Completion
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4
with:
name: bpfman-cli-tab-completion
merge-multiple: true
- name: Unpack CLI TAB Completion
run: |
tar -xzvf cli-tab-completion.tar.gz
- name: Install libelf-dev
run: |
sudo apt-get update
sudo apt-get install -y linux-headers-`uname -r` clang lldb lld libelf-dev gcc-multilib libbpf-dev
- name: Generate go wrapped eBPF
run: |
cd examples && make generate
- name: Run the bpfman installer
run: sudo ./scripts/setup.sh install
- name: Verify the bpfman systemd service is active
run: systemctl is-active bpfman.socket
- name: Verify the CLI can reach bpfman
run: sudo bpfman list
- name: Verify the manpages are installed
run: man bpfman list
- name: Stop the bpfman systemd service
run: |
sudo systemctl stop bpfman
sudo ./scripts/setup.sh uninstall
- name: Run integration tests
run: cargo xtask integration-test
build-docs:
runs-on: ubuntu-24.04
steps:
- name: Checkout bpfman
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Install Python3
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # @v5
with:
python-version: 3.x
- name: Mkdocs Build
run: |
pip install mkdocs-material
pip install -r requirements.txt
mkdocs build --strict
coverage:
needs: [build, build-go]
runs-on: ubuntu-24.04
steps:
- name: Download rust coverage artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4
with:
name: coverage-rust
- name: Upload coverage to Codecov
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # @v4
with:
files: ./lcov.info
verbose: true
# Creates Release
# Copies built bpfman binaries to release artifacts
# Publish's bpfman and bpfman-api crates to crates.io
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build]
environment: crates.io
runs-on: ubuntu-24.04
steps:
- name: Checkout bpfman
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Set env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
if [[ ${GITHUB_REF#refs/*/} =~ "rc" ]]; then
echo "PRE_RELEASE=true" >> $GITHUB_ENV
else
echo "PRE_RELEASE=false" >> $GITHUB_ENV
fi
- name: Download bpfman Release Binaries
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4
with:
pattern: bpfman-release-*
merge-multiple: true
- name: release
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # @v2
with:
body_path: ./changelogs/CHANGELOG-${{ env.RELEASE_VERSION }}.md
prerelease: ${{ env.PRE_RELEASE }}
files: |
bpfman-linux-x86_64.tar.gz
bpfman-linux-arm64.tar.gz
bpfman-linux-ppc64le.tar.gz
bpfman-linux-s390x.tar.gz
- name: publish bpfman crate
run: cargo publish -p bpfman --token ${{ secrets.BPFMAN_DEV_TOKEN }}
- name: publish bpfman-api crate
run: cargo publish -p bpfman-api --token ${{ secrets.BPFMAN_DEV_TOKEN }}
- name: publish bpf-log-exporter crate
run: cargo publish -p bpf-log-exporter --token ${{ secrets.BPFMAN_DEV_TOKEN }}
- name: publish bpf-metrics-exporter crate
run: cargo publish -p bpf-metrics-exporter --token ${{ secrets.BPFMAN_DEV_TOKEN }}
build-workflow-complete:
needs:
[
check-license,
build,
build-go,
build-docs,
coverage,
basic-integration-tests,
]
runs-on: ubuntu-24.04
steps:
- name: Build Complete
run: echo "Build Complete"