forked from bpfman/bpfman
-
Notifications
You must be signed in to change notification settings - Fork 0
422 lines (349 loc) · 11.7 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
name: build
on: # yamllint disable-line rule:truthy
push:
branches: [main]
tags:
- v*
pull_request:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
check-license:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v4
- name: Check License Header
uses: apache/skywalking-eyes@cd7b195c51fd3d6ad52afceb760719ddc6b3ee91
build:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -qy \
git \
clang \
llvm \
protobuf-compiler \
cmake \
perl \
libssl-dev \
gcc-multilib \
libelf-dev \
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: libbpf/libbpf
path: libbpf
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt, clippy, rust-src
override: false
## TODO(astoycos) Deactivate the rust-cache action until we can determine
## why it's freezing at the end of the install.
## - uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@v2
with:
tool: taplo-cli
- run: taplo fmt --check
- name: yaml-lint
run: yamllint -c .yamllint.yaml --strict .
- name: Check C formatting
run: git ls-files -- '*.c' '*.h' | xargs clang-format --dry-run --Werror
- name: Build eBPF
run: |
cargo xtask build-ebpf --libbpf-dir ./libbpf
- name: Check formatting
run: |
cargo +nightly fmt --all -- --check
- name: Run clippy
run: |
cargo +nightly clippy --all -- --deny warnings
- name: Check public API
run: cargo xtask public-api
- name: Build
run: cargo build --verbose
- name: Build manpages
run: cargo xtask build-man-page
- name: Build CLI TAB Completion
run: cargo xtask build-completion
## 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: |
cargo build --release --target x86_64-unknown-linux-gnu
- name: Package-Binaries
if: startsWith(github.ref, 'refs/tags/v')
run: |
cd target/x86_64-unknown-linux-gnu/release
tar -czvf bpfman-linux-x86_64.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@v4
with:
name: bpfman-release
path: |
./target/x86_64-unknown-linux-gnu/release/bpfman-linux-x86_64.tar.gz
- name: Run tests
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
uses: actions/upload-artifact@v4
with:
name: coverage-rust
path: lcov.info
if-no-files-found: error
## Build go modules
build-go:
runs-on: ubuntu-latest
# k8s codegen requires this to be set
env:
GOPATH: ${{ github.workspace }}
defaults:
run:
## For us to run the controller-gen generate commands from within
## github actions the package name MUST match the directory layout
## (i.e `GOPATH/src/github.com/bpfman/bpfman`). Otherwise when
## running `make generate` generated code is deposited at
## `home/runner/work/bpfman/bpfman/bpfman-operator/PKG_NAME` instead
## of in `home/runner/work/bpfman/bpfman/bpfman-operator/pkg/client/...`.
## This is annoying and gross but cannot be resolved until
## https://github.com/kubernetes/kubernetes/issues/86753 is properly
## addressed.
working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman
- uses: actions/setup-go@v5
with:
# prettier-ignore
go-version: '1.21' # yamllint disable-line rule:quoted-strings
- name: Go mod check
run: |
go mod tidy
git diff --exit-code ../go.mod ../go.sum
- name: Lint
uses: golangci/golangci-lint-action@v4
with:
## https://github.com/golangci/golangci-lint-action/issues/369
working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman
version: v1.54.2
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
args: -v --timeout 5m
- name: Build Examples
run: |
go build ./...
- name: Build Operator
run: make build
- name: Verify Operator
run: make verify
- name: Run Tests
run: make test
- name: Archive Go code coverage results
uses: actions/upload-artifact@v4
with:
name: coverage-go
path: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator/cover.out
if-no-files-found: error
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Mkdocs Build
run: |
pip install mkdocs-material
pip install -r requirements.txt
mkdocs build --strict
basic-integration-tests:
runs-on: ubuntu-latest
needs: [build, build-go, build-docs]
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -qy \
git \
clang \
llvm \
protobuf-compiler \
cmake \
perl \
libssl-dev \
gcc-multilib \
libelf-dev
- uses: actions/checkout@v4
with:
repository: libbpf/libbpf
path: libbpf
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rust-src
override: true
- name: Build eBPF
run: cargo xtask build-ebpf --libbpf-dir ./libbpf
- name: Build bpfman
run: cargo build --verbose
- name: Build manpages
run: cargo xtask build-man-page
- name: Build CLI TAB Completion
run: cargo xtask build-completion
- name: Run the bpfman installer
run: sudo ./scripts/setup.sh install
- name: Give certs time to be created
run: sleep 5
- 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
kubernetes-integration-tests:
needs: [build, build-go, build-docs]
runs-on: ubuntu-latest
env:
BPFMAN_IMG: quay.io/bpfman/bpfman:int-test
BPFMAN_AGENT_IMG: quay.io/bpfman/bpfman-agent:int-test
BPFMAN_OPERATOR_IMG: quay.io/bpfman/bpfman-operator:int-test
XDP_PASS_PRIVATE_IMAGE_CREDS: ${{ secrets.XDP_PASS_PRIVATE_IMAGE_CREDS }}
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -qy \
git \
clang \
llvm \
gcc-multilib \
libbpf-dev
- name: setup golang
uses: actions/setup-go@v5
with:
# prettier-ignore
go-version: '1.21' # yamllint disable-line rule:quoted-strings
- name: cache go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-build-codegen-
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
## TODO(astoycos) Currently this is just done to ensure we have coverage
## on all image builds. Ultimately we should be running the integration
## tests with these locally built bytecode images.
- name: build example bytecode images
run: |
go install github.com/cilium/ebpf/cmd/bpf2go@v0.14.0
cd examples
make build-bc-images
- name: build example userspace images
run: cd examples && make build-us-images
- name: build images
run: cd bpfman-operator && make build-images
- name: run integration tests
run: cd bpfman-operator && make test-integration
## Upload diagnostics if integration test step failed.
- name: upload diagnostics
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: kubernetes-integration-test-diag
path: /tmp/ktf-diag*
if-no-files-found: ignore
coverage:
needs: [build, build-go, build-docs]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download golang coverage artifacts
uses: actions/download-artifact@v4
with:
name: coverage-go
- name: Download rust coverage artifacts
uses: actions/download-artifact@v4
with:
name: coverage-rust
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./cover.out,./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-latest
steps:
- uses: actions/checkout@v4
- name: Set env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
name: bpfman-release
- name: release
uses: softprops/action-gh-release@v2
with:
body_path: ./changelogs/CHANGELOG-${{ env.RELEASE_VERSION }}.md
files: |
bpfman-linux-x86_64.tar.gz
- name: publish bpfman-csi crate
run: cargo publish -p bpfman-csi --token ${{ secrets.BPFMAN_DEV_TOKEN }}
- 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 bpfman-log-exporter --token ${{ secrets.BPFMAN_DEV_TOKEN }}
- name: publish bpf-metrics-exporter crate
run: cargo publish -p bpfman-metrics-exporter --token ${{ secrets.BPFMAN_DEV_TOKEN }}
build-workflow-complete:
needs:
[
check-license,
build,
build-go,
build-docs,
coverage,
basic-integration-tests,
kubernetes-integration-tests,
]
runs-on: ubuntu-latest
steps:
- name: Build Complete
run: echo "Build Complete"