Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions cmake/tests-pre-pr-checks.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2026 bong-water-water-bong
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# engine#2384 added a guard to `scripts/pre-pr-checks.sh`: it refuses to run when `docs/pre-pr-checks.md` and its own `checks`
# array disagree about WHICH checks run, or their order. That guard was author-run only -- measured 2026-11-13, `git grep
# pre-pr-checks.sh` over the tree found nothing but the script itself: no CI step and no ctest row ever invoked it, so the
# page/runner drift that happened TWICE in one night (a count sentence six->seven, and three positions out of order) would still
# have needed a human to type the command. This row makes the agreement a build-time failure.
#
# `--list` runs the comparison first and then prints the list without executing anything, so this costs one script start: no
# network, no submodules, no compiler. The script cds to the git toplevel before resolving the page, so the row is independent of
# the ctest working directory.
add_test(NAME pre_pr_checks_agreement COMMAND ${CMAKE_SOURCE_DIR}/scripts/pre-pr-checks.sh --list)
20 changes: 10 additions & 10 deletions scripts/pre-pr-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ done
top=$(git rev-parse --show-toplevel 2>/dev/null) || { echo "pre-pr-checks: not inside a git work tree" >&2; exit 2; }
cd "$top" || { echo "pre-pr-checks: cannot enter $top" >&2; exit 2; }

# A `--base` that does not resolve is a USAGE error, not a skip: the caller asked for a comparison that
# cannot happen, and a run that prints "all 5 check(s) green, 1 skipped" then exits 0 is the shape this
# script exists to stop (review of engine#2313). A skip is for a check that cannot run in this
# environment; an argument that cannot be resolved is the caller's to fix.
git rev-parse --verify -q "$base^{commit}" >/dev/null || {
echo "pre-pr-checks: --base '$base' does not resolve to a commit here" >&2
echo " the registration check compares against it; pass a ref that exists (default: origin/main)" >&2
exit 2
}

# The checks, in the order docs/pre-pr-checks.md lists them: cheapest and most common first, the two
# that need a revision last.
checks=(
Expand Down Expand Up @@ -101,6 +91,16 @@ if [ "$list_only" = 1 ]; then
exit 0
fi

# A `--base` that does not resolve is a USAGE error, not a skip: the caller asked for a comparison that
# cannot happen, and a run that prints "all 5 check(s) green, 1 skipped" then exits 0 is the shape this
# script exists to stop (review of engine#2313). A skip is for a check that cannot run in this
# environment; an argument that cannot be resolved is the caller's to fix.
git rev-parse --verify -q "$base^{commit}" >/dev/null || {
echo "pre-pr-checks: --base '$base' does not resolve to a commit here" >&2
echo " the registration check compares against it; pass a ref that exists (default: origin/main)" >&2
exit 2
}

ok=0; failed=0; skipped=0; detail=""
for c in "${checks[@]}"; do
name=${c%% *}
Expand Down
Loading