From cedd868fd71010ed7c99632241c3e298e2749fb4 Mon Sep 17 00:00:00 2001 From: joshlf's Agent Date: Mon, 24 Aug 2026 22:47:01 +0000 Subject: [PATCH] [ci] Let hook inventory skip data directories Check only regular files when verifying that pre-push invokes every CI check. Preserve the existing reminder for new scripts while allowing review data to live in a named directory under ci. Tests: ./githooks/pre-push gherrit-pr-id: Gtynnl3k4vyrtzrvdux7rxs4dkq7l7f6m --- githooks/pre-push | 18 +++++++++++------- githooks/test_pre_push.py | 11 +++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/githooks/pre-push b/githooks/pre-push index 6c4445bae3..f2c487c3a1 100755 --- a/githooks/pre-push +++ b/githooks/pre-push @@ -133,18 +133,21 @@ if [[ "$TOOLCHAINS_READY" -eq 1 ]]; then wait_for_check "zerocopy/ci/check_msrv_is_minimal.sh" "$MSRV_PID" fi -# Ensure that this script calls all scripts in `ci/*` and `zerocopy/ci/*`. This -# isn't a foolproof check since it just checks for the string in this script -# (e.g., it could be in a comment, which would trigger a false positive), but it -# should catch obvious errors. Also note that this entire hook is a nice-to-have -# - failures that aren't caught here will still be caught in CI. +# Ensure that this script calls all `*.sh` checks in `ci` and `zerocopy/ci`. +# Documentation, registries, and baseline data also live in these directories; +# they are inputs to checks rather than standalone commands. This isn't a +# foolproof check since it just checks for the string in this script (e.g., it +# could be in a comment, which would trigger a false positive), but it should +# catch obvious errors. Also note that this entire hook is a nice-to-have - +# failures that aren't caught here will still be caught in CI. # # This was added because, in #728, we added # `zerocopy/ci/check_all_toolchains_tested.sh` without calling it from this # script. shopt -s extglob GLOBIGNORE="./*/@(release_crate_version|check_todo|release_anneal_version).sh" # We don't want to run these -for f in ./ci/*; do +for f in ./ci/*.sh; do + [[ -f "$f" ]] || continue if ! grep "$f" githooks/pre-push >/dev/null; then echo "$f not called from githooks/pre-push" >&2 CHECKS_FAILED=1 @@ -153,7 +156,8 @@ done # We don't want to run release_crate_version here, and zerocopy/ci/check_fmt.sh # is called by ci/check_fmt.sh above rather than directly. GLOBIGNORE="./zerocopy/ci/@(release_crate_version|check_fmt).sh" -for f in ./zerocopy/ci/*; do +for f in ./zerocopy/ci/*.sh; do + [[ -f "$f" ]] || continue if ! grep "$f" githooks/pre-push >/dev/null; then echo "$f not called from githooks/pre-push" >&2 CHECKS_FAILED=1 diff --git a/githooks/test_pre_push.py b/githooks/test_pre_push.py index 994e2e64fa..03ca23245d 100755 --- a/githooks/test_pre_push.py +++ b/githooks/test_pre_push.py @@ -140,6 +140,17 @@ def __init__(self): path.write_text("#!/usr/bin/env bash\nexit 99\n", encoding="utf-8") path.chmod(0o755) + # These files are CI inputs or documentation, not standalone checks. + # Their presence proves that the hook inventories only `*.sh` scripts. + for data_file in ( + "ci/README.md", + "ci/workflow-jobs.tsv", + "zerocopy/ci/README.md", + ): + path = self.path / data_file + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text("not a check script\n", encoding="utf-8") + cargo = self.path / "zerocopy/cargo.sh" cargo.write_text(_CARGO_STUB, encoding="utf-8") cargo.chmod(0o755)