Skip to content

Scripts: pr_check takes the newest clean main smoke block as the baseline (#2226) - #2230

Open
Creaa wants to merge 1 commit into
xcl-dev:mainfrom
Creaa:scripts/pr-check-main-baseline
Open

Creaa wants to merge 1 commit into
xcl-dev:mainfrom
Creaa:scripts/pr-check-main-baseline

Conversation

@Creaa

@Creaa Creaa commented Nov 25, 2026 •

Copy link
Copy Markdown

The smoke check of pr_check.py let the author pick the main baseline: a main block with local changes counted as main (the PR's block already had to be clean), and with several matching main blocks the first pasted one was used, so an older, more favourable run could be put first. Fixes parts 2 and 3 of #2226; part 1 (how old a baseline may be) is reported, not judged.

What is in it

  • scripts/pr_check.py:
    • a main block whose commit: line says (uncommitted changes) is not a baseline; when only such a block is there, the check asks for a rerun on a clean checkout of main;
    • check(..., main_behind=...): with the distance of each main commit from main known, the baseline is the block of the newest main commit with the PR's title and time, wherever it is pasted; without it, or when any candidate's distance is unknown (a failed API call), the first block as before (main_baseline);
    • when the frames or peak-commit comparison fails against a baseline that is behind main, the message says how many commits behind it is;
    • main() gives that distance (git rev-list --count <sha>..origin/main with --local, compare/<sha>...main ahead_by on GitHub) and prints one line per main block, main regression run <sha>: N commit(s) behind main, without failing on it.
  • scripts/test_pr_check.py: test_a_main_run_with_uncommitted_changes_is_not_a_baseline, test_the_newest_main_block_is_the_baseline_whatever_its_place (both orders of an old and a current main block; without main_behind, or with an unknown distance, the first block is used; a failing comparison names the baseline's distance).

Tested

  • Windows 11 build 26300, Python 3.14.
  • python -m unittest discover -s scripts -p "test_pr_check.py": 15 tests, OK. With pr_check.py from main the two new tests fail (one failure, one error), the other 13 pass.
  • python scripts/pr_check.py --local on a body with two main blocks (cbc296a and current main) and a PR block: prints 54 commit(s) behind main and 0 commit(s) behind main, then description ok.

Regression run

  • None: only scripts/ changes, not the runtime.

Not tested

AI use

  • Claude Code (Claude Opus 5.5) wrote the change and the tests, ran them, and drafted this description; I checked it.

🤖 Generated with Claude Code

@itsonewi

Copy link
Copy Markdown

The fix covers parts 2 and 3, and the tests read well. Two small things:

  1. When the chosen baseline is behind main and the frames/commit comparison fails, include the distance in that message. The standalone main regression run <sha>: N commit(s) behind main line is printed before the failure, but a reader who jumps to the failure will not connect the two. Something like the main block is 54 commits behind main; rerun it before comparing.
  2. In main_baseline, a candidate whose main_behind is None sorts as 1 << 30. If the newest block's compare call fails transiently but an older one succeeds, the older block wins - the opposite of the intent. Treat "any unknown distance" as "do not reorder" (fall back to candidates[0]), or fail the check with a message. The current behavior is only safe if the API never fails.

Neither blocks the merge for me. Part 1 (how old a baseline may be) is still open in #2226; the printed line is a good interim.

…line (xcl-dev#2226)

The PR's own smoke block already had to be free of "(uncommitted changes)",
but a main block with local changes counted as main. When several main blocks
had the PR's title and time, the first pasted one was the baseline, so an
older, more favourable run could be put first.

- A main block whose commit line says "(uncommitted changes)" is not a
  baseline; when it is the only one, the check says to rerun on a clean main.
- With the commit distance known (`main_behind`: git rev-list locally,
  compare/...main ahead_by on GitHub), the baseline is the matching block of
  the newest main commit; without it, the first block as before.
- How many commits behind main each main block is gets printed, not judged:
  the cut-off for an old baseline is the maintainer's call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Creaa
Creaa force-pushed the scripts/pr-check-main-baseline branch from 3369021 to 4e4c508 Compare November 25, 2026 10:58
@Creaa

Creaa commented Nov 25, 2026

Copy link
Copy Markdown
Author

Thanks, both fixed in 4e4c508 (squashed into the PR's commit):

  1. When the frames or peak-commit comparison fails and the baseline is behind main, the message now ends with ; the main block is N commit(s) behind main: rerun it before comparing.
  2. You're right, a failed compare call made an older block win. main_baseline now keeps the first pasted block when the distance of any candidate is unknown. The test covers it (newest block's distance None, older one 40): it fails on the previous commit and passes now.

python -m unittest discover -s scripts -p "test_pr_check.py": 15 tests, OK. #2235 is rebased onto this.

AI use: Claude Code (Claude Opus 5.5) made the change and drafted this reply.

@raylitebull

Copy link
Copy Markdown
Member

Code review on 3369021 (scripts/pr_check.py, scripts/test_pr_check.py):

  • Rejecting main xcl-smoke blocks tagged (uncommitted changes) and selecting min(candidates, key=behind) via main_baseline cleanly closes the stale/dirty baseline loophole from #2226 while preserving fallback behavior when main_behind is None, with 15/15 unit tests covering both orders.
  • Diff audited and CI workflow approved (45598235181).
  • Note: the GitHub compare/<sha>...main ahead_by branch (!o.local) will be exercised live by the PR workflow once CI completes.

@itsonewi

Copy link
Copy Markdown

Re-read the new head (4e4c508): both points are addressed - an unknown distance now falls back to the first block instead of letting an older one win, and a failing comparison names how far the baseline is behind. The added assertions cover both orders, the unknown-distance case and the old-baseline message.

LGTM from me. The new head needs a fresh CI approval; the approved run (45598235181) was for 3369021.

@raylitebull

Copy link
Copy Markdown
Member

Updated review on 4e4c508:

  • Returning candidates[0] when None in behind prevents transient API failures from letting an older baseline win, and appending the main block is N commit(s) behind main directly to the failing comparison messages makes stale baselines immediately actionable.
  • Diff audited and CI workflow approved (45600100113).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants