From 866ff0104f26dbed9c2efad3b3428ced7a33f3c9 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Tue, 1 Dec 2026 00:41:42 -0500 Subject: [PATCH] ci(hooks): check the advertised-schema summary before pushing source changes (#15428) * ci(hooks): check the advertised-schema summary before pushing source changes A stale advertised-schema summary was the most common PR CI failure in a recent window (10 of 28 failing runs). The pre-push hook now runs npm run verify:advertised-schemas when the branch changes non-test files under src/, and skips it otherwise. On a schema change it took 6.5-9.5 s to rebuild with a warm Turbo cache plus 0.9-2.6 s to check, and printed the update command. * ci(hooks): refuse pushes with uncommitted schema summaries and document the check The schema check reads the working tree while CI reads the pushed commit, so running --update-summary without committing the result passed the hook and still failed CI. The hook now refuses the push while files under scripts/verify/advertised-schemas/tools are uncommitted. The testing guide and CONTRIBUTING describe when the hook runs the check. --- .husky/pre-push | 16 ++++++++++++++++ CONTRIBUTING.md | 4 +++- docs/development/testing.md | 6 ++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.husky/pre-push b/.husky/pre-push index e2a8fa8395..931441383b 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1 +1,17 @@ npm run check:fast + +# CI compares the committed advertised-schema summary on every code change, and +# a stale summary was the most common PR CI failure. Check it here only when +# the branch changes production source, so other pushes skip the build. +base=$(git merge-base HEAD origin/main 2>/dev/null || true) +if [ -n "$base" ] && + git diff --quiet "$base" HEAD -- src ':(exclude)**/*.test.ts'; then + exit 0 +fi +npm run verify:advertised-schemas +# The check reads the working tree; CI reads the pushed commit. +summaries=scripts/verify/advertised-schemas/tools +if [ -n "$(git status --porcelain -- "$summaries")" ]; then + echo "Commit the updated files in $summaries before pushing." >&2 + exit 1 +fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0bbdce0b39..f8697c356a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -394,7 +394,9 @@ It guides reproduction and comparable measurements before changing checks. `docs:check` also runs the onboarding example consistency suite for README-only changes. -Pre-commit formats and lints staged files; pre-push runs `check:fast`. +Pre-commit formats and lints staged files; pre-push runs `check:fast`, and +`verify:advertised-schemas` when the branch changes non-test files under +`src/`. ### Generated files and command ownership diff --git a/docs/development/testing.md b/docs/development/testing.md index eea3e98d5d..4a3d958658 100644 --- a/docs/development/testing.md +++ b/docs/development/testing.md @@ -362,8 +362,10 @@ environment with `pip install --require-hashes -r` and set as not verified rather than passed; `REA_REQUIRE_SCHEMA_ENGINES=1` turns it into a failure. CI's build job sets it after uploading the build, using the runner's Go and a virtual environment cached by the requirements file's -digest, so every code change runs every engine. The pre-push hook does not -run the check, because it needs a current build. `--package-root=DIR` lists +digest, so every code change runs every engine. The pre-push hook runs the +check, after a cached build, when the branch changes non-test files under +`src/`, and refuses the push while the regenerated summaries are uncommitted. +`--package-root=DIR` lists an installed package instead of the checkout's build; the release guide uses it to [check the qualified archive](releasing.md#check-the-packed-catalog-with-client-engines).