Add Docker Compose config validation test

This commit is contained in:
2026-06-02 22:41:03 +01:00
parent 426e0367f1
commit fe8744e20e
2 changed files with 47 additions and 0 deletions

View File

@ -39,6 +39,10 @@ echo "========================================================================"
"$ROOT/test_templates.sh" || failures=$((failures + 1))
echo ""
echo "========================================================================"
"$ROOT/test_compose_config.sh" || failures=$((failures + 1))
echo ""
echo "==================================="
if [ "$failures" -eq 0 ]; then
echo " All tests passed!"

43
tests/test_compose_config.sh Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
set -euo pipefail
ROOT="$(dirname "$(realpath "$0")")/.."
pass=0
fail=0
compose_cmd=""
if command -v docker &>/dev/null && docker compose version &>/dev/null 2>&1; then
compose_cmd="docker compose"
elif command -v docker-compose &>/dev/null; then
compose_cmd="docker-compose"
fi
test_compose_config() {
local file=$1
if [ -z "$compose_cmd" ]; then
echo " SKIP $file (no docker compose available)"
return
fi
if $compose_cmd -f "$file" config -q 2>/dev/null; then
echo " PASS $file"
pass=$((pass + 1))
else
echo " FAIL $file"
fail=$((fail + 1))
fi
}
echo "=== Docker Compose Config Validation ==="
test_compose_config "$ROOT/compose.yml"
while IFS= read -r f; do
[ "$f" = "$ROOT/compose.yml" ] && continue
[ -f "$f" ] && test_compose_config "$f"
done < <(find "$ROOT" -maxdepth 1 -name 'compose*.yml' | sort)
echo "---"
echo "Passed: $pass Failed: $fail"
[ "$fail" -eq 0 ]