Skip to content

CI — prek hooks ​

Runs the calling repository's prek (pre-commit) hooks in CI: prek run --all-files.

Local hooks only protect machines that ran prek install. A Renovate PR, an edit made through the GitHub web UI, a fresh clone that skipped the setup or a --no-verify push all bypass them. This workflow re-runs the same config server-side, turning the hooks into a gate instead of a convenience.

Usage ​

yaml
jobs:
  prek:
    uses: KevinDeBenedetti/github-workflows/.github/workflows/ci-prek.yml@v0.57.0 # x-release-please-version
    with:
      runner: '"ubuntu-26.04"'

Run a single hook instead of the whole suite:

yaml
    with:
      extra-args: renovate-config-validator --all-files

Inputs ​

InputTypeDefaultDescription
extra-argsstring--all-filesArguments passed to prek run — e.g. --all-files or a hook id
working-directorystring.Directory holding the prek config
prek-versionstringpinned (Renovate)prek release to install, without the leading v (or latest)
cachebooleantrueCache the prek hook environments between runs, in the GitHub cache
timeout-minutesnumber20Minutes before the job is cancelled
runnerstring'"ubuntu-26.04"'Runner labels as JSON — '"ubuntu-26.04"' or a label array

Steps ​

  1. Checkout
  2. Verify a prek config exists (prek.toml, .prek.toml, .pre-commit-config.yaml or .pre-commit-config.yml) — a missing config is an error, not a skip
  3. Run j178/prek-action (SHA-pinned), which installs prek and runs prek run --show-diff-on-failure --color=always <extra-args>

Notes ​

  • Thin wrapper by design. A reusable workflow checks out the calling repo, so this runs that repo's own prek.toml — one hook definition backing both CI and pre-commit, with nothing to keep in sync twice.
  • Expect overlap. A repo that already has dedicated jobs for shellcheck, actionlint or Gitleaks will run those tools twice — once here through the hooks, once in the dedicated job. That is usually acceptable (the hooks are cached and fast), but extra-args accepts a hook id when you would rather run only what the other jobs do not cover.
  • Hooks need network access. prek downloads hook repositories and, depending on the hook language, a managed toolchain (Node, Python, Go…). A runner behind a strict egress policy needs github.com plus the relevant package registry reachable.
  • cache: true reuses hook environments across runs; disable it when debugging a hook that appears to run against a stale environment.
  • Cold runs take the longest. The cache key is a hash of the prek config, with no fallback to an older entry, so the first run after a config change installs every hook environment from scratch, then uploads the cache, even when a hook failed. On a small runner that run can outlast the default 20 minutes: raise timeout-minutes rather than turning the cache off, since every later run with the same config restores it.
  • The action is pinned by commit SHA rather than by tag, since a mutable tag is a supply-chain risk. Renovate bumps it via the trailing # v3.0.0 comment.