diff --git a/docs/pre-pr-checks.md b/docs/pre-pr-checks.md index 32a38396c..046cd9f50 100644 --- a/docs/pre-pr-checks.md +++ b/docs/pre-pr-checks.md @@ -16,12 +16,12 @@ limitations under the License. --> # Before you ask for a merge -Eight commands, all host-side, none needing a device or a build. Every one of them answers a question that +Nine commands, all host-side, none needing a device or a build. Every one of them answers a question that `mergeable=true`, a green CI tick and a careful read of your own diff do not. Run them from the repository root on the branch you are about to hand over. -**`scripts/pre-pr-checks.sh` runs the first seven**, one line each (`--base ` for the registration check, `--list` to see the +**`scripts/pre-pr-checks.sh` runs the first eight**, one line each (`--base ` for the registration check, `--list` to see the commands; a check that cannot run says `skip` and why, and an unresolvable `--base` is a usage error rather than a skip). The eighth is an **author's check**, true or false exactly once — when you add a page — so it is not in the runner, and the section below says why. The table's order is the runner's order: cheapest and most common first, and the check that needs a revision @@ -36,6 +36,7 @@ below says why. The table's order is the runner's order: cheapest and most commo | `python3 tools/ci/tmp_path_check.py --check` | a new `/tmp` or `/dev/shm` path, where builds and dumps belong under `~/wt` or `~/.cache/scratch-*` | | `python3 tools/ci/submodule_pin_check.py --check` | a submodule's checkout is not the commit the tree pins | | `python3 tools/ci/registration_loss_check.py --check --base origin/main` | your branch would drop rows `main` has | +| `python3 tools/ci/registry_loss_check.py --base origin/main` | a reviewed class, a `coverage` counter or a test's mention of a class that the base has is gone at the merge, not only at the endpoint (engine#2385, #2391) | | `git grep -l -F "$(basename )" -- '*.md'` | nothing links to the page you just added — measured tonight: 45 docs, one with no inbound link, and it was the page whose whole subject is pre-merge checks | Two more, for the moments they are for: diff --git a/scripts/pre-pr-checks.sh b/scripts/pre-pr-checks.sh index 7d9e8f29a..836d20f58 100755 --- a/scripts/pre-pr-checks.sh +++ b/scripts/pre-pr-checks.sh @@ -65,6 +65,7 @@ checks=( "tools/ci/tmp_path_check.py --check" "tools/ci/submodule_pin_check.py --check" "tools/ci/registration_loss_check.py --check --base $base" + "tools/ci/registry_loss_check.py --base $base" ) # The page and this list drift apart, and it has happened twice in one night: the page said the runner "runs the first six" diff --git a/tests/registry_loss_check_test.py b/tests/registry_loss_check_test.py index 083d710fa..5d092aff1 100644 --- a/tests/registry_loss_check_test.py +++ b/tests/registry_loss_check_test.py @@ -122,6 +122,14 @@ def test_a_class_missing_only_because_the_branch_is_behind_is_not_a_loss(self): self.assertIn("behind the base", result.stdout) self.assertNotIn("FAIL", result.stdout) + def test_a_dirty_tree_is_named_because_the_check_reads_commits(self): + # It reads `git show HEAD:...`, so uncommitted work is invisible. A dirty tree must say so instead of + # reading as a clean result. + with open(os.path.join(self.repo, "registry/significant.json"), "w", encoding="utf-8") as handle: + json.dump({"classes": {}}, handle) + result = self.run_check(self.base, "HEAD") + self.assertIn("uncommitted path(s) are NOT included", result.stdout) + def test_a_ref_that_cannot_be_read_refuses_instead_of_passing(self): result = self.run_check(self.base, "no-such-ref") self.assertEqual(result.returncode, 2, result.stdout + result.stderr) diff --git a/tools/ci/registry_loss_check.py b/tools/ci/registry_loss_check.py index 51a7284da..8696ef421 100644 --- a/tools/ci/registry_loss_check.py +++ b/tools/ci/registry_loss_check.py @@ -212,6 +212,16 @@ def main(): if base_counts[name] and not head_counts[name]: lost_mentions.append(f"{name}: {base_counts[name]} mention(s) under tests/ on the base, 0 at the head") + # The check reads commits: `git show :`. Uncommitted work is invisible to it, so say so + # rather than letting a dirty tree read as a clean one (the shape this lane keeps finding). + if args.head == "HEAD": + dirty = git("status", "--porcelain") + # tracked modifications only: an untracked build directory is not a registry change + changed = [line for line in dirty.stdout.splitlines() if line.strip() and not line.startswith("??")] + if changed and not args.quiet: + print(f"registry_loss_check: HEAD is what was read; {len(changed)} uncommitted path(s) are NOT included " + f"- commit them and re-run to check the branch you are handing over") + if not args.quiet: print(f"registry_loss_check: base {args.base} has {len(base_classes)} class(es), head {args.head} has " f"{len(head_classes)}")