mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-09 12:17:13 +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>
68 lines
2.5 KiB
Bash
Executable File
68 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Dispatcher for scripts/lint/<TYPE>.sh based on INFINITO_LINT_RUNNER:
|
|
# host -- directly on the host shell (tools resolved via PATH).
|
|
# docker -- inside the running infinito compose container
|
|
# (requires `make compose-up`; auto-brings the stack up).
|
|
#
|
|
# Argv: <TYPE> [extra args forwarded to the lint script]
|
|
# TYPE is the basename (without `.sh`) of a sibling script next to this
|
|
# one, e.g. `ansible` resolves to scripts/lint/ansible.sh.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
|
|
cd "${REPO_ROOT}"
|
|
# shellcheck source=scripts/meta/env/load.sh
|
|
source scripts/meta/env/load.sh
|
|
|
|
: "${1:?lint type required (e.g. ansible, python, shellcheck, markdown, action, galaxy, makefile, javascript, autoformat)}"
|
|
: "${INFINITO_LINT_RUNNER:?INFINITO_LINT_RUNNER must be set}"
|
|
|
|
lint_type="$1"
|
|
shift
|
|
target_script="scripts/lint/${lint_type}.sh"
|
|
|
|
if [[ ! -f "${target_script}" ]]; then
|
|
echo "scripts/lint/wrapper.sh: unknown lint type '${lint_type}' (no ${target_script})" >&2 # nocheck: self-path-reference
|
|
exit 2
|
|
fi
|
|
|
|
# shellcheck source=scripts/lint/diff/files.sh
|
|
source scripts/lint/diff/files.sh
|
|
diff_files="$(lint_diff_write "${lint_type}")"
|
|
|
|
case "${INFINITO_LINT_RUNNER}" in
|
|
host)
|
|
LINT_DIFF_FILES="${diff_files}" exec bash --login "${target_script}" "$@"
|
|
;;
|
|
docker)
|
|
# like ruff / mbake / ansible-lint undiscoverable. BASH_ENV via -e
|
|
echo "============================================================"
|
|
echo ">>> Running lint '${lint_type}' in ${INFINITO_DISTRO} container (compose stack)"
|
|
echo "============================================================"
|
|
|
|
if ! docker compose ps -q infinito 2>/dev/null | grep -q .; then
|
|
echo ">>> 'infinito' container not running; starting the stack via 'make compose-up'..."
|
|
"${MAKE:-make}" compose-up
|
|
fi
|
|
|
|
INFINITO_DISTRO="${INFINITO_DISTRO}" \
|
|
docker compose exec -T \
|
|
-e ACT="${ACT:-}" \
|
|
-e BASH_ENV="${INFINITO_SRC_DIR}/scripts/meta/env/load.sh" \
|
|
-e GITHUB_ACTIONS="${GITHUB_ACTIONS:-}" \
|
|
-e GITHUB_REPOSITORY="${GITHUB_REPOSITORY:-}" \
|
|
-e GITHUB_REPOSITORY_OWNER="${GITHUB_REPOSITORY_OWNER:-}" \
|
|
-e GITHUB_SHA="${GITHUB_SHA:-}" \
|
|
-e LINT_DIFF_FILES="${diff_files}" \
|
|
--workdir "${INFINITO_SRC_DIR}" \
|
|
infinito \
|
|
bash "${INFINITO_SRC_DIR}/${target_script}" "$@"
|
|
;;
|
|
*)
|
|
echo "scripts/lint/wrapper.sh: unknown INFINITO_LINT_RUNNER='${INFINITO_LINT_RUNNER}' (expected: host|docker)" >&2 # nocheck: self-path-reference
|
|
exit 2
|
|
;;
|
|
esac
|