From a35b7d537afa356c12f6f04b25e7d4ef3440c03a Mon Sep 17 00:00:00 2001 From: John Bampton Date: Thu, 31 Jul 2025 01:34:26 +1000 Subject: [PATCH] pre-commit: run `markdown-link-check`, `oxipng`, `prettier` manually The "manual" stage in pre-commit refers to a specific hook stage designed for hooks that are not intended to run automatically during a standard git commit operation. Instead, these hooks are meant to be triggered explicitly by a user, typically when performing a full repository scan or a specific check. This speeds up the standard `pre-commit run --all-files` run by not running these two hooks. Both hooks are time consuming Can run the manual hooks with: `pre-commit run --all-files --hook-stage manual` Add pre-commit manual stage run on CI to keep full coverage --- .github/workflows/lint.yml | 2 ++ .pre-commit-config.yaml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a3972d413..f3b4f1d68 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,6 +25,8 @@ jobs: key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - name: Run pre-commit run: pre-commit run --all-files + - name: Run manual pre-commit hooks + run: pre-commit run --all-files --hook-stage manual ls-lint: name: Run ls-lint runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 83ade4960..f33dfcdaa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,7 @@ repos: files: \.(json|md|ya?ml)$ language: node additional_dependencies: ["prettier@3.6.2"] + stages: [manual] - repo: https://github.com/gitleaks/gitleaks rev: v8.27.2 hooks: @@ -39,6 +40,7 @@ repos: name: run oxipng description: use lossless compression to optimize PNG files args: ["--fix", "-o", "4", "--strip", "safe", "--alpha"] + stages: [manual] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: @@ -106,6 +108,7 @@ repos: name: run markdown-link-check description: checks hyperlinks in Markdown files args: [--config=.github/linters/mlc_config.json, -q] + stages: [manual] types: [markdown] files: \.md$ - repo: https://github.com/rubocop/rubocop