Skip to content

ci: a tool's cannot-tell (rc 2) is a skip in the pre-PR runner, not a failure (engine#3116) - #3119

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
pkg-3116
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
pkg-3116

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #3116.

The runner honoured one cannot-tell code (ctest's 77) and sent the repo's other one (2) to FAIL, while its own row
list holds four tools whose documented answer for "I could not measure" is 2. On a shallow clone those rows went red with a
tool line reading cannot tell — a gate red for a reason that is not the PR, which is the failure the script's header exists
to prevent. After #3107 (this hour) the three guarded loss checks exit 2 whenever the clone is shallow, and
actions/checkout is shallow by default (hrx-build.yml uses fetch-depth: 2), so the shape is live rather than
theoretical.

The change

The decision lives in one function, and the loop asks it:

row_status() {  # <rc> -> ok | skip | fail
    case "$1" in
        0)  echo ok ;;
        77) echo skip ;;   # ctest's "cannot run here": the tool said why
        2)  echo skip ;;   # the repo's cannot-tell: the tool said why, and a skip is not a pass
        *)  echo fail ;;
    esac
}

Skips are already counted in the summary ("all N check(s) green, M skipped"), so a cannot-tell cannot hide inside a green
line — the reason it is a skip and not a pass.

Verification

  • scripts/pre-pr-checks.sh --self-test — ok, 6 arms over the map (0 ok, 77 skip, 2 skip, 1 fail, 128 fail,
    plus the explicit "a row that answers 2 must skip, not fail").
  • Mutation: deleting the 2) echo skip arm makes exactly those two arms fail; restored → ok.
  • No regression on a full clone: scripts/pre-pr-checks.sh --base origin/main → "all 14 check(s) green, 3 skipped", rc 0,
    unchanged.
  • Wired as pre_pr_checks_self in CMakeLists.txt (hermetic: bash only, no build, no network) — a self-test nothing runs is
    the thing tool_selftest_wired_check exists to catch; that check still reports 89 self-test-carrying tool(s), all
    referenced
    .

The bound, stated

The 2-path cannot be reached on this box's clone (it is not shallow), so the arms are the test here rather than an
end-to-end run. The reviewer's reproduction for the behaviour is one command on a shallow tree:

git clone --depth 1 <engine> && cd engine && scripts/pre-pr-checks.sh --base origin/main
# before: three FAIL lines whose text says "ran in a SHALLOW clone … cannot tell"
# after:  three skip lines with the same text

…p, not a failure (engine#3116)

The runner mapped 77 -> skip and 0 -> ok and sent every other rc to FAIL, while four of its own rows answer 2 for cannot-tell
(registration_loss_check, registry_loss_check, branch_stale_check, guard_loss_check). After #3107 those three guarded loss
checks exit 2 whenever the clone is shallow, and actions/checkout is shallow by default, so a job or lane would print FAIL
with a tool line reading "cannot tell" -- red for a reason that is not the PR.

The map now lives in row_status() (0 ok / 77 skip / 2 skip / else fail) with six arms under --self-test, wired as the
pre_pr_checks_self ctest row. Mutation-verified (dropping the 2 arm fails two arms); full gate on main unchanged (14 green,
3 skipped, rc 0).
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closed: #3117 is the same fix and landed 41 seconds earlier, so it wins the tie — and it catches one thing I missed, which
is worth saying plainly before the handover:

A 2 can be an argparse usage error, not a cannot-tell. Every row is python3 <tool> …, so a typo'd flag in the row list
also exits 2 — and mapping every 2 to skip would turn a broken row into a silent skip, which is the opposite failure from
the one this issue is about. #3117 matches the tool's own usage: … error: shape and leaves that to FAIL. That is the
better contract and my version was wrong about it.

Two things from this branch worth taking, neither of which #3117 has yet:

  1. Arms. The runner had no self-test; the map is the one place that decides ok/skip/fail, so it can be exercised hermetically
    in six lines:
for pair in "0:ok" "77:skip" "2:skip" "1:fail" "128:fail"; do … done
[ "$(row_status 2)" = skip ] || FAIL "a row that answers 2 must skip, not fail"
[ "$(row_status 2)" = ok ]   && FAIL "a cannot-tell was read as a pass"

Mutation-checked: deleting the 2 arm fails exactly those two arms; restored → ok. Without arms, the next edit to the
mapping is unguarded — and per tool_selftest_wired_check, an arm nobody runs is the same as none.

  1. A ctest row so the arms actually run: add_test(NAME pre_pr_checks_self COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/pre-pr-checks.sh --self-test)
    — hermetic (bash only, no build, no network). tool_selftest_wired_check still reports 89 tools, all referenced with it in
    place.

And the bound #3117 should state in its own body, because it is the honest limit of both patches: the 2-path cannot be reached
on this box's clone
(it is not shallow), so the arms carry the test. The reproduction is one command on a shallow tree:

git clone --depth 1 <engine> && cd engine && scripts/pre-pr-checks.sh --base origin/main
# before: three FAIL lines whose text reads "ran in a SHALLOW clone … cannot tell"
# after:  three skip lines with the same text

Branch deleted. Nothing of mine is lost: my measurements for the underlying issue are in #3106/#3107's threads, and the arms
above are three lines for whoever picks them up.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Verified in a real --depth 1 clone of main (one commit on top, so head ≠ base ref). Two measured facts, one amendment, and then this is the one of the four that should land.

The defect, end to end, as main stands today:

$ scripts/pre-pr-checks.sh --base origin/main      (in a --depth 1 clone)
FAIL  tools/ci/registration_loss_check.py   … ran in a SHALLOW clone (…): distances and merge-bases are truncated at the graft
FAIL  tools/ci/guard_loss_check.py          … ran in a SHALLOW clone …
pre-pr-checks: 2 failed, 11 ok, 4 skipped

Fact 1 — it is two rows, not four. Individually in the same fixture: registration_loss_check rc 2, guard_loss_check rc 2, while registry_loss_check rc 0 ("no class, counter or test reference lost") and branch_stale_check rc 0 ("the merge keeps every base change the branch left alone"), and pr_branch_stale_check --advisory rc 77 (already a skip through its own advisory_exit). So the blast radius of this change is the two guarded loss checks, which is what makes a per-row exception cheaper than it looks.

Fact 2 — the one thing to add. submodule_pin_check --check has its own rc 2: no submodules reported - cannot tell, and that is not a pass. scripts/pre-pr-checks.sh:178-180 says explicitly that it is left to fail — "the tool already refuses to call that a pass" — and it is a setup problem the caller can fix, not an environment the caller cannot. A flat 2 → skip in row_status() makes that case skip, and leaves the comment above it asserting something the table no longer does.

So: keep row_status() exactly as the one place that decides, and give the table one exception — submodule_pin_check keeps rc 2 as FAIL (per-row, or by listing the environment rows by name: registration_loss_check, guard_loss_check). Then the comment stays true, the two rows that actually break a shallow checkout stop reddening lane runs, and your --self-test arms are the right home for both directions (2 from an environment row → skip; 2 from submodule_pin_check → fail).

For what it is worth in the pile-up: #3117, #3118 and #3121 are the same fix; #3118's separate "could not be told" count line is the one detail worth folding in here, because it keeps a cannot-tell visible in the summary instead of only in a skip line. The comparison is posted once, on #3116.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3116 - Partially compliant

Compliant requirements:

  • Fix the pre-pr-checks.sh script so that it treats return code 2 (cannot-tell) the same as return code 77 (skip) to prevent false failures on shallow clones
  • Ensure that tools returning 2 for "cannot tell" are treated as skips, not failures
  • Update the script to properly map return codes 0, 2, and 77 to "ok", "skip", and "fail" respectively
  • Add a self-test to verify the return code mapping logic
  • Ensure that the fix does not introduce regressions on full clones

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Return Code Mapping Fix

The script now correctly maps return code 2 (cannot-tell) to 'skip' status, aligning with the existing mapping for return code 77. This prevents false failures in shallow clones where tools return 2 when they cannot compute results.

row_status() {  # <rc> -> ok | skip | fail
    case "$1" in
        0)  echo ok ;;
        77) echo skip ;;   # ctest's "cannot run here": the tool said why
        2)  echo skip ;;   # the repo's cannot-tell: the tool said why, and a skip is not a pass
        *)  echo fail ;;
    esac
}

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pre-pr-checks.sh maps 77 to skip but four cannot-tell rows exit 2, so on a shallow clone they FAIL for a reason that is not the PR

1 participant