mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-09 04:06:42 +00:00
Local lint runs hand the container the files changed since the merge-base with INFINITO_LINT_DIFF_BASE; a changed tool config or shared lint script, CI, or a missing base fall back to the full run. autoformat records a content stamp after a clean ansible-lint --fix, so lint-ansible skips the second pass on an unchanged tree. shellcheck and sqlfluff check in parallel. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
52 lines
1.1 KiB
Bash
Executable File
52 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../.." && pwd)"
|
|
|
|
cd "${REPO_ROOT}"
|
|
|
|
# shellcheck source=scripts/lint/diff/files.sh
|
|
source "${SCRIPT_DIR}/diff/files.sh"
|
|
|
|
if lint_diff_active shellcheck; then
|
|
mapfile -t shellcheck_files < <(lint_diff_files '\.sh$')
|
|
else
|
|
mapfile -t shellcheck_files < <(find . -type f -name '*.sh' 2>/dev/null | sed 's|^\./||' | sort)
|
|
fi
|
|
if [[ "${#shellcheck_files[@]}" -eq 0 ]]; then
|
|
printf 'No shell scripts found.\n'
|
|
exit 0
|
|
fi
|
|
|
|
: "${INFINITO_WORKER_CPU:?INFINITO_WORKER_CPU must be set (provided by default.env via the env loader)}"
|
|
|
|
check() {
|
|
printf '%s\0' "${shellcheck_files[@]}" |
|
|
xargs -0 -n 25 -P "${INFINITO_WORKER_CPU}" shellcheck -x
|
|
}
|
|
|
|
if check; then
|
|
exit 0
|
|
fi
|
|
|
|
diff_file="$(mktemp)"
|
|
cleanup() {
|
|
rm -f "${diff_file}"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
set +e
|
|
shellcheck -f diff -x "${shellcheck_files[@]}" >"${diff_file}" 2>/dev/null
|
|
set -e
|
|
|
|
if [[ ! -s "${diff_file}" ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
printf 'Applying ShellCheck autofixes.\n'
|
|
git apply --whitespace=nowarn "${diff_file}"
|
|
check
|