- compose.matrix.yml: add trailing newline
- compose.ftp-222*.yml: fix YAML indentation (8->6 spaces)
- entrypoint.sh.tmpl: fix SC2198 ([ -n "$@" ] -> [ $# -gt 0 ])
- All .tmpl files: migrate from {{ env }} to {{ getenv }} for gomplate v5 compat
- uploads.ini.tmpl: add {{- / -}} whitespace trimming, fix double-space typo
- tests/run.sh: only run ShellCheck on *.sh.tmpl files
- tests/test_shell.sh: gracefully skip if shellcheck not installed
- tests/test_templates.sh: remove dead render() function,
gracefully skip if gomplate not found, use set -a/. for env sourcing
- tests/test_compose_config.sh: validate override files combined
with compose.yml, skip partial snippets needing more context
- README.md: add test instructions with brew install
51 lines
1.2 KiB
Bash
Executable File
51 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
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:-}"
|
|
|
|
# Run shellcheck on a Go template after stripping template tags
|
|
shellcheck_tmpl() {
|
|
local tmpl=$1
|
|
# Strip Go template tags ({{ ... }} and {{- ... -}}) into whitespace
|
|
# so shellcheck can parse the remaining bash.
|
|
local cleaned
|
|
cleaned=$(sed 's/{{[-]*[^}]*[-]*}}/true/g' "$tmpl")
|
|
|
|
local tmpfile
|
|
tmpfile=$(mktemp)
|
|
printf '%s\n' "$cleaned" > "$tmpfile"
|
|
|
|
if shellcheck $EXTRA_SHELLCHECK_OPTS "$tmpfile"; then
|
|
echo " PASS $tmpl"
|
|
pass=$((pass + 1))
|
|
else
|
|
echo " FAIL $tmpl"
|
|
fail=$((fail + 1))
|
|
fi
|
|
rm -f "$tmpfile"
|
|
}
|
|
|
|
echo "=== ShellCheck ==="
|
|
# Lint each template file passed as argument
|
|
for f in "$@"; do
|
|
[ -f "$f" ] && shellcheck_tmpl "$f"
|
|
done
|
|
|
|
echo "---"
|
|
echo "Passed: $pass Failed: $fail"
|
|
# Exit with failure if any template failed shellcheck
|
|
[ "$fail" -eq 0 ]
|