Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

ci(pre-commit): retry only hook install, not the lint run (#4826)

LearningCircuitb724eac6bc7e
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
index c8594fd7f1..df5216905c 100644
--- a/.github/workflows/pre-commit.yml
+++ b/.github/workflows/pre-commit.yml
@@ -61,20 +61,25 @@ jobs:
sudo apt-get update
sudo apt-get install -y libsqlcipher-dev
- # Replicate pre-commit/[email protected] manually so we can wrap the
- # actual `pre-commit run` invocation in nick-fields/retry. The
- # upstream action is a thin composite (set PY for cache key →
- # cache `~/.cache/pre-commit` → `pip install pre-commit` →
- # `pre-commit run`), and the failure that motivates the retry
- # always happens in that last step: pre-commit lazily downloads
- # hook environments from external sources (PyPI for ruff, GitHub
- # release binaries for shellcheck, etc.), and a single HTTP 5xx
- # from any one of them fails the whole job. See run #2524 where
- # `Building wheel for shellcheck_py` hit HTTP 502 fetching the
- # shellcheck binary during the wheel build. A second attempt
- # benefits from the partially-populated cache and almost always
- # succeeds. Two attempts is enough: a hook environment that
- # fails to install twice in a row is not a transient outage.
+ # Replicate pre-commit/[email protected] manually so the network-flaky hook
+ # *download* can be retried WITHOUT retrying the actual lint check.
+ #
+ # pre-commit lazily downloads hook environments from external sources
+ # (PyPI for ruff, GitHub release binaries for shellcheck, etc.), and a
+ # single HTTP 5xx from any one of them fails the whole job. See run #2524
+ # where `Building wheel for shellcheck_py` hit HTTP 502 fetching the
+ # shellcheck binary during the wheel build. A second attempt benefits from
+ # the partially-populated cache and almost always succeeds; two attempts is
+ # enough (a hook env that fails to install twice in a row is not a
+ # transient outage).
+ #
+ # That download is done up-front by `pre-commit install-hooks`, so only
+ # THAT step is wrapped in nick-fields/retry. The lint check itself runs
+ # exactly once: an auto-fixing hook (ruff-format, …) that modifies a file
+ # makes `pre-commit run` exit non-zero, and that MUST fail the job.
+ # Retrying the run would mask it — the second pass sees the already-fixed
+ # tree and exits 0, so unformatted code would sail through with a green
+ # check.
- name: Compute pre-commit cache key
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV"
@@ -96,11 +101,21 @@ jobs:
# Tracked as dismissed Scorecard alert #7777 ("won't fix").
run: python -m pip install pre-commit==4.6.0
- - name: Run pre-commit
+ # Retry ONLY the hook-environment download (the network-flaky step).
+ - name: Install pre-commit hook environments
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 15
max_attempts: 2
retry_on: error
shell: bash
- command: pre-commit run --show-diff-on-failure --color=always --all-files
+ command: pre-commit install-hooks
+
+ # Run the checks exactly once — NO retry. An auto-fixing hook that
+ # modifies a file must fail the job, not be masked by a clean re-run.
+ # timeout-minutes restores the 15-minute ceiling the retry wrapper used to
+ # put on this step (a hung hook is otherwise bounded only by GitHub's
+ # 6-hour job default); install-hooks keeps its own retry timeout above.
+ - name: Run pre-commit
+ timeout-minutes: 15
+ run: pre-commit run --show-diff-on-failure --color=always --all-files
diff --git a/changelog.d/+precommit-retry-scope.misc.md b/changelog.d/+precommit-retry-scope.misc.md
new file mode 100644
index 0000000000..44db8b7d0c
--- /dev/null
+++ b/changelog.d/+precommit-retry-scope.misc.md
@@ -0,0 +1 @@
+The pre-commit CI job now retries only the hook-environment download (the network-flaky step), not the lint run itself. Previously the entire `pre-commit run` was wrapped in a 2-attempt retry, so an auto-fixing hook (e.g. ``ruff-format``) that rewrote a file would fail the first attempt, leave the now-fixed tree in place, and pass the retry — silently turning a formatting violation into a green check while the unformatted code stayed on the branch. Hook downloads are retried via ``pre-commit install-hooks``; the check now runs exactly once and fails honestly.