Repository navigation
423 lines (402 loc) · 20.8 KB
/
Copy pathcompat.yml
File metadata and controls
423 lines (402 loc) · 20.8 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
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
# Where does Maltrail actually run?
#
# The README claimed six platforms; the harness covered five, and none of the result was published.
# The first widening to twelve found install.sh dead on the whole RHEL 9 family - curl-minimal
# conflicts with curl, dnf refused the transaction, and NOTHING installed - while Arch had worked
# since pacman support landed with nobody able to say so.
#
# So this records rather than asserts. Each job installs Maltrail in a real image, asks it
# questions, and uploads a row; the last job renders them into docs/compat and fails if the
# published page disagrees. A table nobody types cannot drift into marketing.
#
# The sensor comes from the RELEASE, not from a build here, and that is not incidental: a sensor
# built on 24.04 carries a glibc 2.39 floor and will not run on Debian 12, Rocky 9 or Leap 15.6 -
# which made five supported platforms look unsupported the first time this was recorded. The
# release targets 2.28.
name: Compatibility
on:
schedule:
- cron: '19 4 * * 2'
workflow_dispatch:
push:
branches: [ "master" ]
paths:
- 'install.sh'
- 'tests/install/**'
- '.github/workflows/compat.yml'
permissions:
contents: read
jobs:
linux:
name: ${{ matrix.label }} (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- { label: ubuntu, runner: ubuntu-latest, arch: x86_64 }
- { label: ubuntu2204, runner: ubuntu-latest, arch: x86_64 }
- { label: debian, runner: ubuntu-latest, arch: x86_64 }
- { label: debian13, runner: ubuntu-latest, arch: x86_64 }
- { label: fedora, runner: ubuntu-latest, arch: x86_64 }
- { label: fedora41, runner: ubuntu-latest, arch: x86_64 }
- { label: rocky, runner: ubuntu-latest, arch: x86_64 }
- { label: alma, runner: ubuntu-latest, arch: x86_64 }
- { label: arch, runner: ubuntu-latest, arch: x86_64 }
- { label: opensuse, runner: ubuntu-latest, arch: x86_64 }
- { label: tumbleweed, runner: ubuntu-latest, arch: x86_64 }
- { label: alpine, runner: ubuntu-latest, arch: x86_64, libc: musl }
# aarch64 is BUILT and shipped with every release and has never once been installed in a
# test. These are the same images on an arm runner.
- { label: ubuntu, runner: ubuntu-24.04-arm, arch: aarch64 }
- { label: debian13, runner: ubuntu-24.04-arm, arch: aarch64 }
- { label: fedora, runner: ubuntu-24.04-arm, arch: aarch64 }
- { label: alma, runner: ubuntu-24.04-arm, arch: aarch64 }
steps:
- uses: actions/checkout@v5
- name: Fetch the released sensor for this architecture
env:
GH_TOKEN: ${{ github.token }}
run: |
set -eu
# The libc is part of the target. Alpine gets the musl build - it used to be told there
# was none and to install a Rust toolchain instead.
target="${{ matrix.arch }}-unknown-linux-${{ matrix.libc || 'gnu' }}"
mkdir -p /tmp/sensor
# A release without an asset for this target is a real answer, not a reason to fall back
# to a locally built one - that is what made Debian 12 look unsupported.
#
# musl is the exception, and only until a release carries it: the targets were added
# after 3.3, so there is nothing to download yet. Built here instead, the same way
# release.yml builds it, rather than leaving Alpine's sensor columns blank for a release
# cycle.
# Retried: one job in twelve failed the download while eleven fetched the same asset,
# and a network flake reading as "this platform has no binary" is a lie in a table whose
# whole job is telling the truth.
got=0
for attempt in 1 2 3; do
if gh release download --repo "$GITHUB_REPOSITORY" \
--pattern "maltrail-sensor-*-${target}.tar.gz" --dir /tmp/sensor 2>/dev/null; then
got=1; break
fi
echo "[i] download attempt $attempt failed"; sleep 5
done
if [ "$got" = 0 ]; then
case $target in
*-musl)
echo "[i] no released ${target} asset yet - building one"
docker run --rm -v "$PWD:/src:ro" -v /tmp/sensor:/out alpine:3.20 sh -c '
set -e
apk add --no-cache -q cargo libpcap-dev musl-dev >/dev/null
mkdir -p /tmp/b && cd /tmp/b
tar -C /src -cf - --exclude=sensor/target --exclude=.git sensor data core | tar -xf -
cd sensor && cargo build --release --bin maltrail-sensor >/dev/null 2>&1
strip target/release/maltrail-sensor
cp target/release/maltrail-sensor /out/'
;;
*) echo "::error::no released asset for ${target}"; exit 1 ;;
esac
else
tar xzf /tmp/sensor/*.tar.gz -C /tmp/sensor
fi
find /tmp/sensor -name maltrail-sensor -type f -print
- name: Record the row
env:
MALTRAIL_RECORDED_BY: ci
run: |
set -eu
# Clear the committed rows first, so this job's artifact carries ONLY the row it just
# recorded. Uploading the whole directory meant sixteen artifacts each holding a dozen
# overlapping filenames, and merge-multiple made a mess of the collisions - the page job
# then read a file containing two JSON documents.
rm -f docs/compat/rows/*.json
bin=$(find /tmp/sensor -name maltrail-sensor -type f | head -1)
# run.sh picks the musl binary for musl environments; give it both so it never has to
# build one itself here.
export MALTRAIL_TEST_SENSOR="$bin" MALTRAIL_TEST_SENSOR_MUSL="$bin"
python3 tests/install/record.py record ${{ matrix.label }}
ls -1 docs/compat/rows/
- uses: actions/upload-artifact@v4
with:
name: compat-row-${{ matrix.label }}-${{ matrix.arch }}
path: docs/compat/rows/*.json
if-no-files-found: error
# A container shares the host kernel, so there is no image that stands in for these. FreeBSD gets
# a real VM on a Linux runner; macOS gets a real Mac. Both run assert.sh natively - it is POSIX sh
# and takes MALTRAIL_SRC, so the same checks that run in the containers run here.
#
# The sensor is built in-place rather than downloaded: no release carries a FreeBSD or darwin
# target yet. Proving install.sh, the rc.d/launchd scripts and the sensor work on these platforms
# is what decides whether adding those targets is worth doing.
freebsd:
name: freebsd (native VM)
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- uses: vmactions/freebsd-vm@v1
with:
release: '14.2'
usesh: true
copyback: true
prepare: |
pkg install -y git python3 rust
run: |
set -eu
cd /home/runner/work/maltrail/maltrail || cd "$GITHUB_WORKSPACE"
echo "--- building the sensor ---"
cd sensor && cargo build --release --bin maltrail-sensor && cd ..
echo "--- recording the row ---"
rm -f docs/compat/rows/*.json
MALTRAIL_TEST_SENSOR="$PWD/sensor/target/release/maltrail-sensor" \
MALTRAIL_RECORDED_BY=ci \
python3 tests/install/record.py record freebsd --native || true
echo "===== assert.sh transcript ====="
cat .compat-raw/freebsd.out || echo "(no transcript)"
# The `rm` above runs INSIDE the VM, and copyback rsyncs the VM's files onto the host
# without propagating deletions - so the host still holds every committed row and this job
# was uploading eighteen rows it never recorded. They are older than the ones the jobs that
# DID record them upload, and merge-multiple resolves a collision by last-writer-wins, so
# the published page could show a stale row from a job that never tested that platform.
# Observed: this artifact carried macOS 26.5.2 while the macOS job uploaded 26.6.2.
- name: Keep only the row this job recorded
run: |
set -eu
find docs/compat/rows -name '*.json' ! -name 'freebsd-*.json' -delete
echo "uploading:"; ls -1 docs/compat/rows/
- uses: actions/upload-artifact@v4
with:
name: compat-row-freebsd
path: docs/compat/rows/*.json
# error, not warn: an empty upload once made a native job go green while publishing
# nothing, which is the exact failure shape this matrix exists to catch.
if-no-files-found: error
# NetBSD and OpenBSD. Neither can be cross-checked from Linux the way FreeBSD can - the bundled
# SQLite needs a C compiler for the target, and rustup has no OpenBSD std at all (tier 3) - so a
# native VM is not a nicety here, it is the only way to compile them, let alone run them.
#
# They are also the last two platforms whose rc.d scripts were written and never executed.
netbsd:
name: netbsd (native VM)
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- uses: vmactions/netbsd-vm@v1
with:
release: '10.1'
# The reason the run phase produced nothing. NetBSD's base system has no bash, and
# without usesh the action runs the script with one - so ssh exited 1 before the first
# echo and the job looked like the action was broken. FreeBSD, the BSD job that has
# always worked, passes usesh for the same reason. bash is installed below as well, so
# the job no longer depends on which shell the action decides to use.
usesh: true
copyback: true
# Split, and the optional one tolerated. `py312-sqlite3 is not available in the
# repository` made a single pkgin call exit non-zero, the action treats a failing
# prepare as fatal, and so `run` never executed - which looked from the outside like the
# run phase failing to start a shell, because its output was simply never produced.
# Everything else in that line installed perfectly, which is what made it convincing.
prepare: |
/usr/sbin/pkg_add pkgin || true
pkgin -y install bash rust git python312 libpcap
pkgin -y install py312-sqlite3 || echo "(no py312-sqlite3 in this repository)"
# pkgsrc installs the interpreter as python3.12 and leaves `python3` to the
# administrator, so `sh: python3: not found` - which record.py, assert.sh and
# install.sh all need. Linked here rather than worked around in three scripts.
[ -x /usr/pkg/bin/python3 ] || ln -sf /usr/pkg/bin/python3.12 /usr/pkg/bin/python3
python3 --version
# No `set -e`, and diagnostics BEFORE anything that can fail. The first attempt began
# `set -eu; cd <guessed path> || cd "$GITHUB_WORKSPACE"` and the job died with `ssh
# exited with code 1` and not one line of output - the guessed path was wrong, the
# variable is not set inside the VM, and `set -u` took the shell down before the first
# echo. A run that cannot say where it got to is not worth repeating.
run: |
echo "--- where am I ---"
echo "pwd=$(pwd)"; ls
for d in "$GITHUB_WORKSPACE" /home/runner/work/maltrail/maltrail "$(pwd)"; do
if [ -n "$d" ] && [ -f "$d/tests/install/record.py" ]; then cd "$d"; break; fi
done
echo "working in $(pwd)"
test -f tests/install/record.py || { echo "the checkout is not visible from the VM"; exit 1; }
echo "--- toolchain ---"
(cargo --version && python3 --version) || echo "(missing toolchain)"
echo "--- building the sensor ---"
cargo build --release --manifest-path sensor/Cargo.toml --bin maltrail-sensor \
|| { echo "the sensor did not build here"; exit 1; }
echo "--- recording the row ---"
rm -f docs/compat/rows/*.json
MALTRAIL_TEST_SENSOR="$PWD/sensor/target/release/maltrail-sensor" \
MALTRAIL_RECORDED_BY=ci \
python3 tests/install/record.py record netbsd --native || true
echo "===== assert.sh transcript ====="
cat .compat-raw/netbsd.out || echo "(no transcript)"
- name: Keep only the row this job recorded
run: |
set -eu
find docs/compat/rows -name '*.json' ! -name 'netbsd-*.json' -delete
echo "uploading:"; ls -1 docs/compat/rows/
- uses: actions/upload-artifact@v4
with:
name: compat-row-netbsd
path: docs/compat/rows/*.json
if-no-files-found: error
openbsd:
name: openbsd (native VM)
runs-on: ubuntu-latest
timeout-minutes: 60
# Being brought up: reported, not enforced. See the notes in the steps below for what
# each one is currently blocked on - neither is a Maltrail failure.
continue-on-error: true
steps:
- uses: actions/checkout@v5
- uses: vmactions/openbsd-vm@v1
with:
release: '7.7'
copyback: true
# `pkg_add -I rust git python%3` found none of them: "Can't find rust", "Can't find
# python%3". The flavour syntax is not a package name, and each name is tried on its own
# here so one miss does not take the others with it. pkg_info -Q prints what this
# release actually offers, which is the thing worth knowing when a name is wrong.
prepare: |
# Named explicitly: the first run could not find git, rust or python, and pkg_info -Q
# returned nothing at all, which is what "no package source is reachable" looks like
# rather than "the names are wrong".
export PKG_PATH="https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(uname -m)/"
echo "PKG_PATH=$PKG_PATH"
pkg_add -I git || echo "(no git)"
pkg_add -I rust || pkg_add -I rust-- || echo "(no rust)"
pkg_add -I python%3.12 || pkg_add -I python%3.11 || pkg_add -I python3 || echo "(no python3)"
echo "--- what this release offers ---"
pkg_info -Q rust | head -5 || true
pkg_info -Q python- | head -8 || true
run: |
echo "--- where am I ---"
echo "pwd=$(pwd)"; ls
for d in "$GITHUB_WORKSPACE" /home/runner/work/maltrail/maltrail "$(pwd)"; do
if [ -n "$d" ] && [ -f "$d/tests/install/record.py" ]; then cd "$d"; break; fi
done
echo "working in $(pwd)"
test -f tests/install/record.py || { echo "the checkout is not visible from the VM"; exit 1; }
echo "--- toolchain ---"
(cargo --version && python3 --version) || echo "(missing toolchain)"
# libpcap is in OpenBSD's base system, but base ships no pkg-config file for it, so
# the pcap crate's build script probes with pkg-config and fails - everything else
# (rust 1.86, python 3.12, the checkout) was already working by this point. Naming the
# directory is what the release build does for the same crate.
echo "--- building the sensor ---"
LIBPCAP_LIBDIR=/usr/lib LIBPCAP_VER=1.10.1 MALTRAIL_SKIP_PCAP_CHECK=1 \
cargo build --release --manifest-path sensor/Cargo.toml --bin maltrail-sensor \
|| { echo "the sensor did not build here"; exit 1; }
echo "--- recording the row ---"
rm -f docs/compat/rows/*.json
MALTRAIL_TEST_SENSOR="$PWD/sensor/target/release/maltrail-sensor" \
MALTRAIL_RECORDED_BY=ci \
python3 tests/install/record.py record openbsd --native || true
echo "===== assert.sh transcript ====="
cat .compat-raw/openbsd.out || echo "(no transcript)"
- name: Keep only the row this job recorded
run: |
set -eu
find docs/compat/rows -name '*.json' ! -name 'openbsd-*.json' -delete
echo "uploading:"; ls -1 docs/compat/rows/
- uses: actions/upload-artifact@v4
with:
name: compat-row-openbsd
path: docs/compat/rows/*.json
if-no-files-found: error
macos:
name: ${{ matrix.label }} (native)
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- { label: macos-arm64, runner: macos-latest }
- { label: macos-intel, runner: macos-15-intel }
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- name: Build the sensor
run: cargo build --release --manifest-path sensor/Cargo.toml --bin maltrail-sensor
- name: Record the row
env:
MALTRAIL_RECORDED_BY: ci
run: |
set -eu
rm -f docs/compat/rows/*.json
sudo MALTRAIL_TEST_SENSOR="$PWD/sensor/target/release/maltrail-sensor" \
MALTRAIL_RECORDED_BY=ci \
python3 tests/install/record.py record ${{ matrix.label }} --native || true
# The WHOLE transcript, not just the marks. The first run reported three marks and exit 1
# with no way to see why, because the artifact was silently dropped for being hidden and
# the diagnostics were filtered out of the log as well.
echo "===== assert.sh transcript ====="
cat .compat-raw/${{ matrix.label }}.out || echo "(no transcript)"
- uses: actions/upload-artifact@v4
with:
name: compat-row-${{ matrix.label }}
path: docs/compat/rows/*.json
# error, not warn: an empty upload once made a native job go green while publishing
# nothing, which is the exact failure shape this matrix exists to catch.
if-no-files-found: error
page:
name: the published page says what the rows say
# Every row-producing job, not just linux: the page used to be rendered while the BSD and
# macOS VMs were still running, so it could publish a matrix that was missing them.
needs: [ linux, freebsd, netbsd, openbsd, macos ]
# Waits for them all, but renders whatever they produced. A platform being brought up should
# not stop the page describing the eighteen that already work - and the no-files-found guard
# on each row job is what reports the missing one, loudly, where it happened.
if: ${{ always() }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
# Downloaded UNMERGED first, to prove no two jobs claim the same row. merge-multiple
# silently resolves a collision by last-writer-wins, which is how a job that uploaded rows
# it had not recorded could overwrite a fresher row from the job that did.
- uses: actions/download-artifact@v4
with:
path: /tmp/unmerged
pattern: compat-row-*
- name: No two jobs may claim the same row
run: |
set -eu
dupes=$(find /tmp/unmerged -name '*.json' -printf '%f\n' | sort | uniq -d)
if [ -n "$dupes" ]; then
echo "::error::these rows were uploaded by more than one job, so the page depends on"
echo "::error::merge order rather than on which job actually tested the platform:"
printf '%s\n' "$dupes"
find /tmp/unmerged -name '*.json' | sort
exit 1
fi
echo "[i] every row was uploaded by exactly one job"
- uses: actions/download-artifact@v4
with:
path: /tmp/rows
pattern: compat-row-*
merge-multiple: true
# NOT `render --check` against these rows. They were recorded minutes ago on CI, so they
# carry today's date and recorded_by=ci and will never equal the committed page - checking
# them against it would fail every single run and teach everyone to ignore this job. The
# drift guard is tests/test_compat.py, which compares the COMMITTED page with the COMMITTED
# rows. What this job is for is producing fresh evidence and showing what changed.
- name: Render the page these rows produce
run: |
set -eu
cp /tmp/rows/*.json docs/compat/rows/
python3 tests/install/record.py render
echo "### Platform matrix" >> "$GITHUB_STEP_SUMMARY"
sed -n '/^| Platform/,/^$/p' docs/compat/README.md >> "$GITHUB_STEP_SUMMARY"
if ! git diff --quiet docs/compat; then
echo "[i] the recorded rows differ from what is committed:"
git --no-pager diff --stat docs/compat
echo "[i] commit docs/compat to publish them"
fi
- uses: actions/upload-artifact@v4
with:
name: compat-page
path: docs/compat