Skip to content

fix(ci): make the update-constraints pre-commit hook work in CI - #6505

Open
DABH wants to merge 1 commit into
google:mainfrom
DABH:fix-precommit-constraints
Open

fix(ci): make the update-constraints pre-commit hook work in CI#6505
DABH wants to merge 1 commit into
google:mainfrom
DABH:fix-precommit-constraints

Conversation

@DABH

@DABH DABH commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

TL;DR

The Pre-commit Linter job fails on every main run since the update-constraints hook landed (e.g. this run), keeping main red. This PR makes it green again. No functional code is touched.

Why it fails

  1. The linter job never installs uv → the hook dies with uv: command not found (masked as "Resolution failed").
  2. The hook runs update_constraints.sh in update mode, whose --exclude-newer date moves daily and which exits 1 whenever it rewrites a file — so CI can't stay green even with uv installed.
  3. The constraints-<ver>.txt files the hook manages were never committed, so check mode has nothing to validate.

The fix

  • Install uv in the linter job (same pinned setup-uv action the other jobs use).
  • Run the hook with --check — the script's documented CI mode; it pins the date from the committed file header, so validation is deterministic. Devs still run the script directly to update pins.
  • Commit the five generated constraints-3.10…3.14.txt files; fail fast with a clear error if uv is missing; skip generated constraints files in codespell (it flags the astroid package name).
  • Set persist-credentials: false on this workflow's checkout steps so the zizmor gate is clean (it rescans the whole file on any edit and its four pre-existing artipacked findings otherwise fail fork-PR runs).

Testing plan

  • uvx pre-commit run --all-files: 13/13 hooks pass (previously update-constraints failed).
  • ./scripts/update_constraints.sh --check twice back-to-back: exit 0, idempotent. Reviewers can verify the files by regenerating with ./scripts/update_constraints.sh.
  • zizmor on the workflow file: 0 findings (was 4, all pre-existing).

The Pre-commit Linter job has failed on every run since the
update-constraints hook landed, keeping main red:

- The job never installs uv, so the hook died with 'uv: command not
  found' (masked as 'Resolution failed' by the script's error handling).
- The hook ran the script in update mode, which recomputes the
  --exclude-newer date daily and exits 1 whenever it rewrites a file, so
  CI could not stay green even with uv installed.
- The constraints-<ver>.txt files the hook manages were never committed,
  so check mode had nothing to validate.

Fix accordingly:

- Install uv in the Pre-commit Linter job, using the same pinned
  setup-uv action the type-check and test jobs already use.
- Run the hook with --check, the script's documented CI mode: it pins
  the exclude-newer date from the committed file header, so validation
  is deterministic day over day. Developers still run the script
  directly to update pins.
- Fail fast with a clear error when uv is not on PATH.
- Commit the five generated constraints files. They are the fixed point
  of the script's own regeneration (including uv's 'via' annotations),
  so --check passes idempotently; reviewers can regenerate with
  ./scripts/update_constraints.sh to verify.
- Skip generated constraints files in codespell (it flags the astroid
  package name as a typo).
- Set persist-credentials: false on this workflow's checkout steps so
  the zizmor gate stays clean when the file is rescanned (its four
  pre-existing artipacked findings otherwise fail fork-PR runs, which
  scan with --no-ignores).
@DABH
DABH force-pushed the fix-precommit-constraints branch from 574533f to f0a41ee Compare July 28, 2026 18:43
@DABH

DABH commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Hi @DeanChensj , this is related to my #6468 PR where I was noticing unexpected CI failures. However, this is now impacting everyone's PRs and main :) Let me know if you or anyone from the team is able to take a quick look at this today (or if you guys want to push your own solution of course, that's totally fine too). Thanks in advance!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant