ci: make badge checks portable to FreeBSD
Rust CI fader_master passed CI.
MadGobblins/fader_master/pipeline/head This commit looks good Details

Support both GNU and FreeBSD stat output and replace find -maxdepth with POSIX shell SVG counting so the rust_nodocker Jenkins worker can run the CI fixture and badge finalizer.

Tests: sh -n scripts/*.sh (passed)

Tests: scripts/test-ci.sh (passed)
This commit is contained in:
Dandaedre 2026-10-05 07:38:48 +02:00
parent bfbd42f9bd
commit 567aa13262
2 changed files with 30 additions and 6 deletions

View File

@ -54,7 +54,12 @@ for badge in $expected; do
exit 1
}
done
actual_count=$(find coverage -maxdepth 1 -name '*.svg' | wc -l)
actual_count=0
for candidate in coverage/*.svg; do
if [ -e "$candidate" ] || [ -L "$candidate" ]; then
actual_count=$((actual_count + 1))
fi
done
[ "$actual_count" -eq 3 ] || {
echo "expected exactly three SVG badges, found $actual_count" >&2
exit 1

View File

@ -22,6 +22,25 @@ assert_fails() {
fi
}
file_mode() {
if stat -c '%a' "$1" >/dev/null 2>&1; then
stat -c '%a' "$1"
else
stat -f '%Lp' "$1"
fi
}
svg_count() {
directory=$1
count=0
for candidate in "$directory"/*.svg; do
if [ -e "$candidate" ] || [ -L "$candidate" ]; then
count=$((count + 1))
fi
done
printf '%s\n' "$count"
}
renderer="$repository/scripts/ci-coverage-badges.sh"
render_dir="$workspace/render"
mkdir "$render_dir"
@ -153,7 +172,7 @@ assert_contains "$finalize_work/coverage/coverage.svg" '#9f9f9f'
assert_contains "$finalize_work/coverage/test.svg" 'passing'
assert_contains "$finalize_work/coverage/version.svg" '1.2.3'
[ ! -e "$finalize_work/coverage/.tests-passed-local" ] || fail 'test marker survived finalization'
[ "$(find "$finalize_work/coverage" -maxdepth 1 -name '*.svg' | wc -l)" -eq 3 ] \
[ "$(svg_count "$finalize_work/coverage")" -eq 3 ] \
|| fail 'finalization did not leave exactly three SVG files'
printf '<svg>fresh measurement</svg>\n' >"$finalize_work/coverage/coverage.svg"
@ -178,11 +197,11 @@ done
"$repository/scripts/ci-publish-badges.sh" "$publish_root" MadGobblins fader_master main coverage test version
)
destination="$publish_root/MadGobblins/fader_master/main"
[ "$(stat -c '%a' "$publish_root/MadGobblins")" = 755 ] || fail 'owner mode is not 0755'
[ "$(stat -c '%a' "$publish_root/MadGobblins/fader_master")" = 755 ] || fail 'project mode is not 0755'
[ "$(stat -c '%a' "$destination")" = 755 ] || fail 'branch mode is not 0755'
[ "$(file_mode "$publish_root/MadGobblins")" = 755 ] || fail 'owner mode is not 0755'
[ "$(file_mode "$publish_root/MadGobblins/fader_master")" = 755 ] || fail 'project mode is not 0755'
[ "$(file_mode "$destination")" = 755 ] || fail 'branch mode is not 0755'
for badge_name in coverage test version; do
[ "$(stat -c '%a' "$destination/$badge_name.svg")" = 644 ] || fail "$badge_name mode is not 0644"
[ "$(file_mode "$destination/$badge_name.svg")" = 644 ] || fail "$badge_name mode is not 0644"
done
assert_fails sh -c "cd '$publish_work' && '$repository/scripts/ci-publish-badges.sh' '$publish_root' MadGobblins fader_master main coverage coverage"