Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,23 @@ jobs:

- name: Run pre-commit
id: precommit
env:
# Skip hooks that auto-fix files — markdownlint (uses --fix) and
# terraform_validate (runs terraform init which writes .terraform/).
# Their check-only counterparts run in the next step.
Comment thread
mkultraWasHere marked this conversation as resolved.
Outdated
SKIP: markdownlint,terraform_validate
run: |
pre-commit run --show-diff-on-failure --color=always --all-files

- name: Run check-only hooks
id: precommit-check
if: ${{ !cancelled() }}
run: |
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual

- name: Capture autofix patch
id: capture
if: ${{ failure() && steps.precommit.outcome == 'failure' }}
if: ${{ failure() && (steps.precommit.outcome == 'failure' || steps.precommit-check.outcome == 'failure') }}
run: |
if git diff --quiet HEAD; then
echo "pre-commit failed without modifying tracked files; no autofix possible"
Expand Down
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,17 @@ repos:
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.49.1
hooks:
# Local: auto-fix markdown issues on commit.
- id: markdownlint
args: ['--fix', '--config', '.hooks/linters/markdownlint.json']
stages: [pre-commit]
# CI: check-only (no file modifications) so the hook never reports
# "files were modified" in read-only CI environments.
- id: markdownlint
alias: markdownlint-check
name: markdownlint (check-only)
args: ['--config', '.hooks/linters/markdownlint.json']
stages: [manual]

- repo: https://github.com/ansible/ansible-lint
rev: v26.6.0
Expand All @@ -74,6 +83,9 @@ repos:
files: ^(modules|infra)/
- id: terragrunt_fmt
files: ^infra/
# Skipped in CI (SKIP=terraform_validate) because terraform init
# writes .terraform/ which triggers "files were modified". tflint
# covers validation in CI instead.
- id: terraform_validate
files: ^modules/
args:
Expand Down
Loading