-
Notifications
You must be signed in to change notification settings - Fork 64
245 lines (231 loc) · 8.73 KB
/
Copy pathci.yaml
File metadata and controls
245 lines (231 loc) · 8.73 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
name: CI
# Run CI when a commit lands on the main branch and when a PR for main is
# opened.
on:
push:
branches:
- main
- "ci/*"
pull_request:
branches:
- main
env:
REGISTRY: ghcr.io
permissions:
checks: write
contents: read
id-token: write
packages: write
pages: write
pull-requests: write
jobs:
create-images:
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
host:
- { name: 8-core-ubuntu, arch: x64 }
- { name: 4-core-ubuntu-arm, arch: arm64 }
distribution:
- { name: fedora, version: "rawhide", experimental: true }
- { name: fedora, version: "44" }
- { name: fedora, version: "43" }
- { name: fedora, version: "42" }
- { name: ubuntu, version: "24.04" }
- { name: ubuntu, version: "25.04" }
- { name: ubuntu, version: "25.10" }
runs-on: ["${{ matrix.host.name }}"]
continue-on-error: ${{ matrix.distribution.experimental || false }}
name: "Image: ${{ matrix.distribution.name }} ${{ matrix.distribution.version }} (${{ matrix.host.arch}})${{ matrix.distribution.experimental && ' [experimental]' || '' }}"
steps:
- name: Checkout bpfilter
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build the container images and use the existing images as cache
- name: Build and push container image
uses: docker/build-push-action@v7
with:
file: .github/${{ matrix.distribution.name }}-${{ matrix.distribution.version }}.Dockerfile
push: ${{ github.event_name == 'push' && 'true' || 'false' }}
tags: ghcr.io/facebook/bpfilter:${{ matrix.distribution.name }}-${{ matrix.distribution.version }}-${{ matrix.host.arch}}
cache-from: type=gha,scope=${{ matrix.distribution.name }}-${{ matrix.distribution.version }}-${{ matrix.host.arch}}
cache-to: type=gha,mode=max,scope=${{ matrix.distribution.name }}-${{ matrix.distribution.version }}-${{ matrix.host.arch}}
build:
needs: create-images
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
host:
- { name: 8-core-ubuntu, arch: x64 }
- { name: 4-core-ubuntu-arm, arch: arm64 }
distribution:
- { name: fedora, version: "rawhide", experimental: true }
- { name: fedora, version: "44" }
- { name: fedora, version: "43" }
- { name: fedora, version: "42" }
- { name: ubuntu, version: "24.04" }
- { name: ubuntu, version: "25.04" }
- { name: ubuntu, version: "25.10" }
runs-on: ["${{ matrix.host.name }}"]
continue-on-error: ${{ matrix.distribution.experimental || false }}
container: ghcr.io/facebook/bpfilter:${{ matrix.distribution.name }}-${{ matrix.distribution.version }}-${{ matrix.host.arch}}
name: "Build: ${{ matrix.distribution.name }} ${{ matrix.distribution.version }} (${{ matrix.host.arch}})${{ matrix.distribution.experimental && ' [experimental]' || '' }}"
steps:
- name: Checkout bpfilter
uses: actions/checkout@v6
- name: Configure the build
run: cmake -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -DNO_TESTS=1
- name: Build all
run: make -C $GITHUB_WORKSPACE/build -j `nproc`
test:
needs: create-images
timeout-minutes: 5
strategy:
matrix:
host:
- { name: 8-core-ubuntu, arch: x64 }
- { name: 4-core-ubuntu-arm, arch: arm64 }
runs-on: ["${{ matrix.host.name }}"]
container:
image: ghcr.io/facebook/bpfilter:fedora-44-${{ matrix.host.arch }}
options: --privileged
name: "Test: ${{ matrix.host.arch }}"
steps:
- name: Checkout bpfilter
uses: actions/checkout@v6
- name: Restore the cached test results
uses: actions/cache@v5
if: matrix.host.arch == 'x64'
with:
path: build/coverage
key: tests-results-${{ github.run_id }}
- name: Mount bpffs
run: mount bpffs /sys/fs/bpf -t bpf
- name: Configure the build
run: cmake -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -DWITH_COVERAGE=1
- name: Build tests
run: make -C $GITHUB_WORKSPACE/build -j `nproc` test_bin
- name: Run unit tests
run: ctest --test-dir $GITHUB_WORKSPACE/build -L unit --verbose
- name: Run end-to-end tests
run: ctest --test-dir $GITHUB_WORKSPACE/build -L e2e --verbose
- name: Run fuzzing tests
run: ctest --test-dir $GITHUB_WORKSPACE/build -R '^fuzzing\.parser\.60$' --verbose
- name: Upload fuzzer findings
uses: actions/upload-artifact@v7
if: always()
with:
name: fuzzer-findings-${{ matrix.host.arch }}
path: ${{ github.workspace }}/build/findings
if-no-files-found: ignore
- name: Run integration tests
run: ctest --test-dir $GITHUB_WORKSPACE/build -L integration --verbose
- name: Run checks
run: ctest --test-dir $GITHUB_WORKSPACE/build -L check --verbose
- name: Generate the coverage report
run: make -C $GITHUB_WORKSPACE/build coverage
benchmark:
runs-on: self-hosted
# Ensure benchmarks are not run concurrently on bf-bench-3
concurrency:
group: do-no-run-benchmarks-concurrently
cancel-in-progress: false
name: "Benchmark"
steps:
- name: Checkout bpfilter repository
uses: actions/checkout@v6
with:
fetch-depth: 0
# Run bfbencher with the same cache directory for every job, so
# results are shared.
# On pull requests, compare the X latest changes on main against the
# last commit of the PR. Otherwise, run the benchmarks up to HEAD.
# On job retry, the last commit of the PR will always be retried.
- name: Run bfbencher
env:
# Override rich's default terminal width to prevent wrapping.
COLUMNS: 150
IS_RETRY: ${{ github.run_attempt > 1 }}
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git fetch origin main
BENCH_UNTIL="origin/main"
BENCH_INCLUDE="--include HEAD"
BENCH_FAIL_ON="--fail-on-significant-change worse"
if [ "$IS_RETRY" = "true" ]; then
BENCH_RETRY="--retry HEAD"
else
BENCH_RETRY=""
fi
else
BENCH_UNTIL="HEAD"
BENCH_INCLUDE=""
BENCH_FAIL_ON=""
fi
python3 -m tests.benchmarks.bfbencher history \
--since 30bd49f \
--until $BENCH_UNTIL \
$BENCH_INCLUDE \
--cache-dir ~/bfbencher-cache \
--report-path index.html \
--pr-report-path $GITHUB_STEP_SUMMARY \
$BENCH_RETRY \
$BENCH_FAIL_ON \
--fail-on-last-commit-failure \
--bind-node 0 \
--no-preempt \
--cpu-pin 3 \
--slice benchmark.slice
- uses: actions/upload-artifact@v7
with:
name: benchmarks-report
path: index.html
doc:
needs: [test, benchmark]
timeout-minutes: 5
runs-on: ["8-core-ubuntu"]
container: ghcr.io/facebook/bpfilter:fedora-44-x64
name: "Documentation"
steps:
- name: Checkout bpfilter
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Mark the repository as safe for Git
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Configure the build
run: cmake -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build
- name: Restore the cached tests results
uses: actions/cache@v5
with:
path: build/coverage
key: tests-results-${{ github.run_id }}
- name: Build
run: make -C $GITHUB_WORKSPACE/build -j `nproc` doc
- uses: actions/download-artifact@v8
with:
name: benchmarks-report
path: ${{ github.workspace }}/build/doc/html/external/benchmarks/
- name: Fix permissions
if: github.ref == 'refs/heads/main'
run: |
chmod -c -R +rX "$GITHUB_WORKSPACE/build/doc/html" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
if: github.ref == 'refs/heads/main'
with:
path: build/doc/html
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v5
if: github.ref == 'refs/heads/main'