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).