Files
Aurora.3/tools/ci/check_shell_scripts.sh
lew bef246dc8a adds shellcheck to ci/cd (#22616)
ci/cd script to shellcheck .sh files and make sure they're executable as
part of cicd so it fails loud with the specific problem if Permissions
Issue 2 The Revengeance happens again
2026-06-06 10:23:52 +00:00

31 lines
875 B
Bash
Executable File

#!/usr/bin/env bash
# Enforces an executable bit and static analysis on shell scripts.
set -uo pipefail
severity="${SHELLCHECK_SEVERITY:-error}"
status=0
ok() { printf ' OK %s\n' "$1"; }
fail() { printf ' FAIL %s\n' "$1"; status=1; }
mapfile -t scripts < <(git ls-files '*.sh')
echo "Checking executable bit"
for f in "${scripts[@]}"; do
mode="$(git ls-files -s -- "$f" | awk '{print $1; exit}')"
if [ "$mode" = "100755" ]; then ok "$f"; else fail "$f: not executable -> git update-index --chmod=+x '$f'"; fi
done
if command -v shellcheck >/dev/null 2>&1; then
echo "shellcheck (severity=$severity)"
for f in "${scripts[@]}"; do
if shellcheck --severity="$severity" -- "$f"; then ok "$f"; else status=1; fi
done
else
echo "shellcheck not available"
fi
if [ "$status" -ne 0 ]; then echo "FAIL"; else echo "PASS"; fi
exit "$status"