Revert "Fix lint issues and improve test suite resilience"
This reverts commit 90d44bd3bc.
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ done < <(find "$ROOT/.." -maxdepth 1 -name 'compose*.yml' | sort)
|
||||
SHELL_TMPL_FILES=()
|
||||
while IFS= read -r f; do
|
||||
SHELL_TMPL_FILES+=("$f")
|
||||
done < <(find "$ROOT/.." -maxdepth 1 -name '*.sh.tmpl' | sort)
|
||||
done < <(find "$ROOT/.." -maxdepth 1 -name '*.tmpl' | sort)
|
||||
|
||||
# Track total failures across all test suites
|
||||
failures=0
|
||||
|
||||
@@ -15,7 +15,7 @@ fi
|
||||
|
||||
# Validate a compose file against the Docker Compose specification
|
||||
test_compose_config() {
|
||||
local file=$1 main=${2:-}
|
||||
local file=$1
|
||||
|
||||
# Skip if Docker Compose is not available on this system
|
||||
if [ -z "$compose_cmd" ]; then
|
||||
@@ -23,27 +23,13 @@ test_compose_config() {
|
||||
return
|
||||
fi
|
||||
|
||||
# Main compose file is validated standalone
|
||||
if [ -z "$main" ]; then
|
||||
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
|
||||
return
|
||||
fi
|
||||
|
||||
# Override files are validated combined with the main compose file.
|
||||
# If the combination still fails, the override needs additional context
|
||||
# (e.g. other override files) and is skipped rather than failed.
|
||||
if $compose_cmd -f "$main" -f "$file" config -q 2>/dev/null; then
|
||||
# config -q exits with non-zero if the compose file is invalid
|
||||
if $compose_cmd -f "$file" config -q 2>/dev/null; then
|
||||
echo " PASS $file"
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
echo " SKIP $file (partial override, needs additional context)"
|
||||
pass=$((pass + 1))
|
||||
echo " FAIL $file"
|
||||
fail=$((fail + 1))
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -55,7 +41,7 @@ test_compose_config "$ROOT/compose.yml"
|
||||
while IFS= read -r f; do
|
||||
# Skip the main compose file (already tested above)
|
||||
[ "$f" = "$ROOT/compose.yml" ] && continue
|
||||
[ -f "$f" ] && test_compose_config "$f" "$ROOT/compose.yml"
|
||||
[ -f "$f" ] && test_compose_config "$f"
|
||||
done < <(find "$ROOT" -maxdepth 1 -name 'compose*.yml' | sort)
|
||||
|
||||
echo "---"
|
||||
|
||||
@@ -4,15 +4,6 @@ set -euo pipefail
|
||||
pass=0
|
||||
fail=0
|
||||
|
||||
# Skip if shellcheck is not installed
|
||||
if ! command -v shellcheck &>/dev/null; then
|
||||
echo "=== ShellCheck ==="
|
||||
echo " SKIP shellcheck not found"
|
||||
echo "---"
|
||||
echo "Passed: 0 Failed: 0"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Allow overriding shellcheck options via env var (e.g. -s bash)
|
||||
EXTRA_SHELLCHECK_OPTS="${SHELLCHECK_OPTS:-}"
|
||||
|
||||
|
||||
+14
-7
@@ -11,20 +11,27 @@ gomplate="${GOMPLATE_BIN:-gomplate}"
|
||||
# Ensure gomplate is installed before running template tests
|
||||
require_gomplate() {
|
||||
if ! command -v "$gomplate" &>/dev/null; then
|
||||
echo " SKIP gomplate not found (install from https://github.com/hairyhenderson/gomplate or set GOMPLATE_BIN)"
|
||||
exit 0
|
||||
echo "gomplate not found. Install it from https://github.com/hairyhenderson/gomplate"
|
||||
echo "or set GOMPLATE_BIN env var."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
render() {
|
||||
local tmpl=$1 envfile=$2
|
||||
"$gomplate" \
|
||||
--template t="$tmpl" \
|
||||
--context "_=fmt:%s" \
|
||||
--datasource "env=env://?$envfile" \
|
||||
-f "$tmpl" 2>/dev/null
|
||||
}
|
||||
|
||||
# Render a template by exporting env vars directly
|
||||
# This avoids gomplate datasource quirks with .env files
|
||||
render_via_env() {
|
||||
local tmpl=$1 envfile=$2
|
||||
set -a
|
||||
# shellcheck disable=1090,1091
|
||||
. "$envfile"
|
||||
set +a
|
||||
"$gomplate" -f "$tmpl" 2>/dev/null
|
||||
# shellcheck disable=2046
|
||||
env $(xargs < "$envfile") "$gomplate" -f "$tmpl" 2>/dev/null
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user