forked from bpfman/bpfman
-
Notifications
You must be signed in to change notification settings - Fork 0
362 lines (300 loc) · 9.34 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
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@ed436a5593c63a25f394ea29da61b0ac3731a9fe
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 \
musl-tools
- 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
- 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: Build
run: cargo build --verbose
## 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: |
rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl
- name: Package-Binaries
if: startsWith(github.ref, 'refs/tags/v')
run: |
tar -czvf bpfman-linux-x86_64.tar.gz ./target/x86_64-unknown-linux-musl/release/bpfman
- name: Archive bpfman Release Binaries
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: bpfman-release
path: |
./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
defaults:
run:
working-directory: ./bpfman-operator
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Go mod check
working-directory: ${{ github.workspace }}
run: |
go mod tidy
git diff --exit-code go.mod go.sum
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
args: -v --timeout 5m --enable=gofmt
- 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: ./bpfman-operator/cover.out
if-no-files-found: error
basic-integration-tests:
runs-on: ubuntu-latest
needs: ["build", "build-go"]
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: 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: Stop the bpfman systemd service
run: sudo systemctl stop bpfman
- name: Run integration tests
run: cargo xtask integration-test
kubernetes-integration-tests:
needs: ["build", "build-go"]
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:
go-version: "^1.19"
- 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/[email protected]
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"]
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@v3
with:
fail_ci_if_error: true
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@v1
with:
body_path: ./changelogs/CHANGELOG-${{ env.RELEASE_VERSION }}.md
files: |
bpfman-linux-x86_64.tar.gz
## TODO once we're using an aya mainline version
# - 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 }}
build-workflow-complete:
needs:
[
"check-license",
"build",
"build-go",
"coverage",
"basic-integration-tests",
"kubernetes-integration-tests",
]
runs-on: ubuntu-latest
steps:
- name: Build Complete
run: echo "Build Complete"