mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 21:27:02 +01:00
Adds an arch-tests job on archlinux:base-devel so the pacman wrapper, makepkg wrapper and hosts-guard tests finally run somewhere. They need an Arch userland and root, which a disposable container provides. Four more tests still referenced pre-reorganisation paths and could never find their targets; repairing them took the container set from two passing to five. All five were verified with --network=none, so the job installs nothing beyond git (base-devel ships no git, and actions/checkout needs it). Also removes the silent-failure mode behind the earlier music_parallelism confusion. The test now derives its temp-worktree path from the script's real position instead of hardcoding the depth, checks up front that ../../lib/common.sh resolves to the stub, and has the stub write a marker asserted after every run. Previously a reorganisation made the script source the real /usr/local/lib/common.sh, so the test measured the live system and failed as though the daemon were broken. Three tests stay out, each for a different reason, documented in the workflow: test_i3blocks_efficiency.sh needs strace and could not be verified locally (containers here have no DNS); test_hosts_guard_pacman_integration.sh fails a real assertion worth investigating; test_security_hardening.sh asserts live host state and can never pass in a fresh container.
105 lines
3.6 KiB
YAML
105 lines
3.6 KiB
YAML
name: Shell tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
shell-tests:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install bats
|
|
run: sudo apt-get update && sudo apt-get install -y bats
|
|
|
|
- name: Run bats suites
|
|
run: bats linux_configuration/tests/*.bats
|
|
|
|
# Only the side-effect-free tests run here. The rest of
|
|
# linux_configuration/tests/ drives pacman, /etc, systemd or adb and
|
|
# cannot run on an Ubuntu runner without root and an Arch container --
|
|
# see the accompanying evidence artifacts for the full list.
|
|
- name: Run side-effect-free shell tests
|
|
run: |
|
|
set -euo pipefail
|
|
tests=(
|
|
test_android_guardian_post_fs_data.sh
|
|
test_android_guardian_service.sh
|
|
test_i3blocks_persist_common.sh
|
|
test_music_parallelism.sh
|
|
test_setup_dns_blocker.sh
|
|
test_usage_monitoring_installer_efficiency.sh
|
|
)
|
|
failed=0
|
|
for t in "${tests[@]}"; do
|
|
printf '\n=== %s ===\n' "$t"
|
|
if bash "linux_configuration/tests/$t"; then
|
|
printf 'PASS %s\n' "$t"
|
|
else
|
|
printf 'FAIL %s\n' "$t"
|
|
failed=$((failed + 1))
|
|
fi
|
|
done
|
|
if [ "$failed" -gt 0 ]; then
|
|
printf '\n%d shell test(s) failed\n' "$failed"
|
|
exit 1
|
|
fi
|
|
|
|
# Tests that assume Arch: they exercise the pacman wrapper, makepkg wrapper
|
|
# and hosts-guard hooks, so they need an Arch userland rather than Ubuntu.
|
|
# They run as root here, which is what lets them touch /etc safely — the
|
|
# container is disposable.
|
|
arch-tests:
|
|
runs-on: ubuntu-latest
|
|
container: archlinux:base-devel
|
|
steps:
|
|
# base-devel ships no git, and actions/checkout needs it to clone.
|
|
- name: Install git
|
|
run: pacman -Sy --noconfirm --needed git
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
# Verified to pass in `docker run --network=none archlinux:base-devel`,
|
|
# so this list needs no package installs beyond git.
|
|
#
|
|
# Deliberately excluded:
|
|
# test_i3blocks_efficiency.sh
|
|
# needs strace (and SYS_PTRACE) to count execve calls. Could not be
|
|
# validated locally because this machine's containers have no DNS,
|
|
# so pacman cannot install strace. Add it once someone can confirm
|
|
# it passes in a container that can reach the mirrors.
|
|
# test_hosts_guard_pacman_integration.sh
|
|
# fails on a real assertion ('wrapper detects when pacman hooks
|
|
# already manage hosts guard'), not a path or environment problem.
|
|
# test_security_hardening.sh
|
|
# asserts live machine state (e.g. '/etc/hosts is immutable'). It
|
|
# validates a configured host, not the repo, so it can never pass
|
|
# in a fresh container.
|
|
- name: Run Arch-specific shell tests
|
|
run: |
|
|
set -euo pipefail
|
|
tests=(
|
|
test_hosts_file_monitor.sh
|
|
test_makepkg_capped.sh
|
|
test_makepkg_wrapper.sh
|
|
test_pacman_wrapper_security.sh
|
|
test_shutdown_timer_monitor.sh
|
|
)
|
|
failed=0
|
|
for t in "${tests[@]}"; do
|
|
printf '\n=== %s ===\n' "$t"
|
|
if bash "linux_configuration/tests/$t"; then
|
|
printf 'PASS %s\n' "$t"
|
|
else
|
|
printf 'FAIL %s\n' "$t"
|
|
failed=$((failed + 1))
|
|
fi
|
|
done
|
|
if [ "$failed" -gt 0 ]; then
|
|
printf '\n%d shell test(s) failed\n' "$failed"
|
|
exit 1
|
|
fi
|