mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-11 16:07:36 +01:00
bef246dc8a
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
31 lines
875 B
Bash
Executable File
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"
|