Problem
The managed pre-commit hook in modules/plain-repo/files/pre-commit only runs:
terraform fmt -check -recursive
terraform-docs .
- Trailing newline check
It does not check Python formatting (black --check) or any other linting. Repos that have a make lint target (which includes black --check, pylint, etc.) can pass the pre-commit hook locally but fail the CI lint step.
How we discovered it
In infrahouse/terraform-aws-actions-runner#87, a Python file that needed black reformatting passed the pre-commit hook and was pushed. CI's make lint caught it.
Proposed fix
Add a step to the pre-commit hook that runs make lint if a Makefile with a lint target exists:
# 4. Run project linter if available
if [ -f Makefile ] && grep -q '^lint:' Makefile; then
echo "🔍 Running project linter..."
if ! make lint; then
echo "❌ Linting failed"
echo " Run: make lint"
exit 1
fi
echo "✅ Linting passed"
fi
This would cover black, pylint, terraform fmt, and anything else a repo puts in its lint target — and is a no-op for repos without one.
Note: if make lint already includes terraform fmt -check, the existing step 1 becomes redundant but harmless. Could be deduplicated later.
Problem
The managed
pre-commithook inmodules/plain-repo/files/pre-commitonly runs:terraform fmt -check -recursiveterraform-docs .It does not check Python formatting (
black --check) or any other linting. Repos that have amake linttarget (which includesblack --check,pylint, etc.) can pass the pre-commit hook locally but fail the CI lint step.How we discovered it
In infrahouse/terraform-aws-actions-runner#87, a Python file that needed
blackreformatting passed the pre-commit hook and was pushed. CI'smake lintcaught it.Proposed fix
Add a step to the pre-commit hook that runs
make lintif aMakefilewith alinttarget exists:This would cover
black,pylint,terraform fmt, and anything else a repo puts in itslinttarget — and is a no-op for repos without one.Note: if
make lintalready includesterraform fmt -check, the existing step 1 becomes redundant but harmless. Could be deduplicated later.