Add Docker Compose config validation test
This commit is contained in:
@ -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
43
tests/test_compose_config.sh
Executable 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 ]
|
||||
Reference in New Issue
Block a user