Skip to content
This repository was archived by the owner on May 16, 2026. It is now read-only.
This repository was archived by the owner on May 16, 2026. It is now read-only.

pre-commit hook should run make lint when available #269

@akuzminsky

Description

@akuzminsky

Problem

The managed pre-commit hook in modules/plain-repo/files/pre-commit only runs:

  1. terraform fmt -check -recursive
  2. terraform-docs .
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions