Skip to content

fix(ci): split pre-commit into auto-fix (local) and check-only (CI) - #384

Open
mkultraWasHere wants to merge 2 commits into
mainfrom
fix/pre-commit-ci-stages
Open

fix(ci): split pre-commit into auto-fix (local) and check-only (CI)#384
mkultraWasHere wants to merge 2 commits into
mainfrom
fix/pre-commit-ci-stages

Conversation

@mkultraWasHere

Copy link
Copy Markdown
Contributor

Summary

  • Split markdownlint into two hooks: --fix (local) and check-only (CI)
  • Skip terraform_validate in CI via SKIP env var (tflint covers validation)
  • Add a second CI step for manual-stage check-only hooks

Problem

markdownlint --fix and terraform_validate both modify files on disk during execution. Pre-commit reports this as "files were modified by this hook" and exits non-zero. This is unfixable by committing locally — CI regenerates different artifacts (terraform lock hashes for linux_amd64 vs local darwin_arm64, .terraform/ directories).

Solution

Hook Local CI
markdownlint --fix (auto-fixes on commit) check-only (reports errors, no modifications)
terraform_validate full validate with init skipped (tflint covers validation)

Test plan

  • CI pre-commit job passes on this PR
  • Local pre-commit run --all-files still auto-fixes markdown
  • Local git commit triggers auto-fix hooks as before

🤖 Generated with Claude Code

…(CI)

markdownlint --fix and terraform_validate both modify files on disk,
which always reports "files were modified by this hook" in CI and fails
the required status check. This is unfixable by committing locally
because CI environments regenerate different artifacts (terraform lock
hashes, .terraform/ dirs).

Fix by splitting the CI run into two stages:
1. Default stage: runs all hooks except markdownlint and
   terraform_validate (skipped via SKIP env var)
2. Manual stage: runs markdownlint in check-only mode (no --fix)

terraform_validate has no check-only counterpart — tflint already
covers validation in CI.

Local workflow is unchanged: `git commit` triggers auto-fix hooks
as before.

Co-Authored-By: Claude <noreply@anthropic.com>
@dreadnode-renovate-bot dreadnode-renovate-bot Bot added area/github Changes made to github actions area/pre-commit Changes made to pre-commit hooks labels Jul 27, 2026
@mkultraWasHere
mkultraWasHere requested a review from Copilot July 27, 2026 02:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the repo’s pre-commit and CI configuration to prevent CI failures caused by hooks that legitimately modify files on disk during execution, while still enforcing lint/validation behavior in CI.

Changes:

  • Split markdownlint into a local auto-fix hook (pre-commit stage) and a CI check-only hook (manual stage).
  • Skip terraform_validate in CI via SKIP to avoid terraform init side effects during the main pre-commit run.
  • Add a second CI step to run manual-stage (check-only) hooks and include its result in the autofix patch capture condition.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.pre-commit-config.yaml Splits markdownlint into fix vs check-only hooks and documents CI skipping for terraform validation.
.github/workflows/pre-commit.yaml Adjusts CI to skip autofixing hooks in the main pre-commit run, adds a manual-stage run, and updates patch capture logic accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/pre-commit.yaml Outdated
…rpart

Co-Authored-By: Claude <noreply@anthropic.com>
@mkultraWasHere

Copy link
Copy Markdown
Contributor Author

@l50 You alright with this one?

Cant get clean CI checks on outstanding PRs that touch terraform files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/github Changes made to github actions area/pre-commit Changes made to pre-commit hooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants