Repository navigation
ci: a reply can't leave a defect the review found for the release quality pass without a maintainer's say #2661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ee022b2
492e401
0186424
ab284ad
54d05b8
59a6c1c
6cf9a12
72c71ff
aee6a17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,200 @@ | ||||||||||
| """Fails a pull request that leaves a defect for the release quality pass. | ||||||||||
|
|
||||||||||
| A review point may wait for the release quality pass when the reply to it ends with | ||||||||||
| `<!-- quality-sweep -->`, but only a quality point may (AGENTS.md, "Review comments"). The Claude | ||||||||||
| review (claude-code-review.yml, posting as github-actions) ends each inline finding with its | ||||||||||
| category, a last line `Category: bug` and so on, so the reviewer classifies a finding and the | ||||||||||
| author doesn't. This check refuses a deferral reply in a thread that the reviewer opened with a | ||||||||||
| `bug`, `security` or `agents-md` finding, or whose opening comment someone else has since edited. | ||||||||||
|
|
||||||||||
| Threads opened by anyone else (CodeRabbit, people) or by a review from before categories carry no | ||||||||||
| category and are let through: a reviewer there can answer the reply. They are listed in a notice. | ||||||||||
| An edited review finding is refused whatever category it now shows, since the edit may have | ||||||||||
| removed or changed it; the override below settles a harmless edit. | ||||||||||
|
|
||||||||||
| `performance` is left out on purpose: a faster path may wait. A performance finding that is also a | ||||||||||
| crash path or breaks "Size for real data" carries `bug` or `agents-md`, the more serious category. | ||||||||||
|
|
||||||||||
| Both markers err towards refusing. The deferral marker counts wherever it sits in a reply, as the | ||||||||||
| release quality pass collects it, so a reply that only mentions it is refused too: reword it. The | ||||||||||
| override counts only when it ends its reply, so a mention doesn't approve. | ||||||||||
|
|
||||||||||
| A maintainer overrides the check for a finding, misclassified or accepted as it is, by replying in | ||||||||||
| its thread with `<!-- deferral-approved -->`. A maintainer here is the repository's owner, a member | ||||||||||
| of its organization or a collaborator, as GitHub labels the reply. The author may be that maintainer: the | ||||||||||
| override is a deliberate, recorded decision, not a second opinion. | ||||||||||
|
|
||||||||||
| CI runs this on each push and again in the merge queue, which sees replies posted after the last | ||||||||||
| push. It needs GH_TOKEN (read access to pull requests), GITHUB_REPOSITORY, and PR_NUMBER or, in the | ||||||||||
| merge queue, MERGE_GROUP_REF. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| import json | ||||||||||
| import os | ||||||||||
| import re | ||||||||||
| import subprocess | ||||||||||
| import sys | ||||||||||
|
|
||||||||||
| DEFER = "<!-- quality-sweep -->" | ||||||||||
| APPROVE = "<!-- deferral-approved -->" | ||||||||||
| # Visible text on a line of its own: the review's inline-comment tool strips hidden comments. | ||||||||||
| # Markdown emphasis and code marks around the label or the value, and capitals, are let through. | ||||||||||
| CATEGORY = re.compile(r"^[*_`]*Category[*_`]*:[*_` \t]*([A-Za-z-]+)[*_`]*\.?[ \t\r]*$", re.M) | ||||||||||
| MUST_FIX = {"bug", "security", "agents-md"} | ||||||||||
| MAY_WAIT = {"performance", "quality"} | ||||||||||
| REVIEWER = "github-actions" | ||||||||||
| MAINTAINERS = {"OWNER", "MEMBER", "COLLABORATOR"} | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ReDoS in the marker pattern. Each hidden comment should end at its first
Suggested change
Please add a regression test with a long run of hidden comments and a trailing character. Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reproduced: 24 hidden comments and a trailing character took 2.3 s with the old pattern, doubling per comment. Fixed in 54d05b8 without a nested pattern: the text after the last marker has its hidden comments removed and must then be blank. Regression test with 5,000 hidden comments and a trailing character.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GitHub's Confidence: medium. It depends on how the repository invites collaborators, which I can't see from the diff. Category: security
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No change. The docs and the script's header say who may override: the owner, an organization member or a collaborator, as GitHub labels the reply. This is a process guard that leaves a visible reply in the thread, not an access control, so it doesn't look up write permission. |
||||||||||
| QUEUE_REF = re.compile(r"/pr-(\d+)-[0-9a-f]{40}$") | ||||||||||
|
|
||||||||||
| THREADS = """ | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The category line fails open. The pattern is case-sensitive and needs the exact text on its own line. A line such as Tolerate markdown around the label and lowercase the value ( Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 54d05b8: emphasis and code marks around the label or value are accepted and the value is lowercased, with a test for four spellings. A review finding with no recognisable category stays a notice, not a refusal: every review thread written before this change has none, and refusing them would hold the open pull requests. |
||||||||||
| query($owner: String!, $name: String!, $number: Int!, $endCursor: String) { | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Either add it, or record in the PR that performance is deliberately excluded and why:
Suggested change
Category: agents-md
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deliberately excluded, and now recorded in the script's header and the pull request description. A faster path is work the release quality pass handles. A performance finding that is also a crash path or breaks "Size for real data" carries |
||||||||||
| repository(owner: $owner, name: $name) { | ||||||||||
| pullRequest(number: $number) { | ||||||||||
| reviewThreads(first: 50, after: $endCursor) { | ||||||||||
| pageInfo { hasNextPage endCursor } | ||||||||||
| nodes { id path line originalLine comments(first: 100) { %s } } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| """ | ||||||||||
| COMMENTS = """pageInfo { hasNextPage endCursor } | ||||||||||
| nodes { url body authorAssociation lastEditedAt author { login __typename } editor { login } }""" | ||||||||||
| MORE_COMMENTS = """ | ||||||||||
| query($id: ID!, $endCursor: String) { | ||||||||||
| node(id: $id) { ... on PullRequestReviewThread { comments(first: 100, after: $endCursor) { %s } } } | ||||||||||
| } | ||||||||||
| """ | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def is_reviewer(comment): | ||||||||||
| """Whether a comment was posted by the Claude review workflow's bot account.""" | ||||||||||
| author = comment.get("author") or {} | ||||||||||
| return author.get("login") == REVIEWER and author.get("__typename") == "Bot" | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def category(opening): | ||||||||||
| """The category a reviewer finding gives itself: the most serious of its markers, or None.""" | ||||||||||
| if not is_reviewer(opening): | ||||||||||
| return None | ||||||||||
| found = [c.lower() for c in CATEGORY.findall(opening.get("body") or "")] | ||||||||||
| found = [c for c in found if c in MUST_FIX | MAY_WAIT] # an unknown word is no category | ||||||||||
| serious = [c for c in found if c in MUST_FIX] | ||||||||||
| return (serious or found or [None])[0] | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def edited_by_someone_else(opening): | ||||||||||
| """Whether a human or other account edited the reviewer's comment, which may have changed its category.""" | ||||||||||
| if not opening.get("lastEditedAt"): | ||||||||||
| return False | ||||||||||
| return ((opening.get("editor") or {}).get("login")) != REVIEWER | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def approved(replies): | ||||||||||
| """Whether a maintainer overrode the check for the thread's deferral.""" | ||||||||||
| for reply in replies: | ||||||||||
| author = reply.get("author") or {} | ||||||||||
| if ( | ||||||||||
| (reply.get("body") or "").rstrip().endswith(APPROVE) | ||||||||||
| and author.get("__typename") != "Bot" | ||||||||||
| and reply.get("authorAssociation") in MAINTAINERS | ||||||||||
| ): | ||||||||||
| return True | ||||||||||
| return False | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def check(threads): | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check reads review threads only, so a deferral made elsewhere escapes it. The reviewer's summary is a PR comment (the workflow publishes the final message as one) and lists the same findings under Bugs and Security, with no inline thread and no category line. A reply to it, or any other PR comment carrying ``, is never seen by this check. The rule is only as strong as the sweep's search: if the release pass collects markers from issue comments as well as thread replies, a bug can be deferred with no refusal. Either the check should also scan issue comments (the summary is authored by Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of scope by design, now stated in the description under "What this doesn't do": the check reads review threads only. A marker in a top-level comment has no finding or category to judge it by; the release quality pass still collects it, and reviewers can see it. |
||||||||||
| """Sorts the threads that hold a deferral reply into (refused, unclassified) lists of messages.""" | ||||||||||
| refused, unclassified = [], [] | ||||||||||
| for thread in threads: | ||||||||||
| comments = thread.get("comments") or [] | ||||||||||
| if not comments: | ||||||||||
| continue | ||||||||||
| opening, replies = comments[0], comments[1:] | ||||||||||
| deferral = next((r for r in replies if DEFER in (r.get("body") or "")), None) | ||||||||||
| if deferral is None: | ||||||||||
| continue | ||||||||||
| where = f"{thread.get('path')}:{thread.get('line') or thread.get('originalLine') or '?'}" | ||||||||||
| if not is_reviewer(opening): | ||||||||||
| unclassified.append(f"{where} ({(opening.get('author') or {}).get('login', 'ghost')}): {deferral.get('url')}") | ||||||||||
| continue | ||||||||||
| kind = category(opening) | ||||||||||
| if edited_by_someone_else(opening): | ||||||||||
| reason = "its finding was edited after the review posted it" | ||||||||||
| elif kind in MUST_FIX: | ||||||||||
| reason = f"the reviewer classed it as {kind}" | ||||||||||
| else: | ||||||||||
| if kind is None: | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A category the check doesn't know passes with no notice.
Suggested change
( Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 72c71ff: a category word the check doesn't know counts as no category, so the deferral is listed in a notice. Test added with |
||||||||||
| unclassified.append(f"{where} (review without a category): {deferral.get('url')}") | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The edit check runs before the no-category case, so it refuses threads the docstring says pass. The module docstring says threads from reviews before categories "are let through" with a notice. This line comes first, though: a human edit to an uncategorised review comment (a typo fix, say) makes Checking for an uncategorised finding first would match the docstring. If an edit to a categorised finding could have changed its category, keep the edit check for that case. Test both paths: an edited uncategorised review should give a notice, not a refusal. Category: bug
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The order is intended; the docstring was wrong and is corrected in 54d05b8. Checking for no category first would let an edit that deletes the category line turn a refused finding into a noticed one. An edited finding is refused whatever it now shows, and the maintainer's override settles a typo fix. Test added for an edited finding with no category. |
||||||||||
| continue | ||||||||||
| if not approved(replies): | ||||||||||
| refused.append(f"{where}: left for the release quality pass, but {reason}. {deferral.get('url')}") | ||||||||||
| return refused, unclassified | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def graphql(query, **variables): | ||||||||||
| """Runs one GraphQL query through the gh CLI and returns its data.""" | ||||||||||
| args = ["gh", "api", "graphql", "-f", f"query={query}"] | ||||||||||
| for key, value in variables.items(): | ||||||||||
| args += ["-F" if isinstance(value, int) else "-f", f"{key}={value}"] | ||||||||||
| out = subprocess.run(args, check=True, stdout=subprocess.PIPE, text=True, timeout=120).stdout | ||||||||||
| return json.loads(out)["data"] | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def fetch(repo, number): | ||||||||||
| """The pull request's review threads, every comment of each in order.""" | ||||||||||
| owner, name = repo.split("/", 1) | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applied in 54d05b8. |
||||||||||
| threads, cursor = [], None | ||||||||||
| while True: | ||||||||||
| extra = {"endCursor": cursor} if cursor else {} | ||||||||||
| pr = graphql(THREADS % COMMENTS, owner=owner, name=name, number=number, **extra)["repository"]["pullRequest"] | ||||||||||
| page = pr["reviewThreads"] | ||||||||||
| for node in page["nodes"]: | ||||||||||
| comments, more = node["comments"]["nodes"], node["comments"]["pageInfo"] | ||||||||||
| while more["hasNextPage"]: | ||||||||||
| rest = graphql(MORE_COMMENTS % COMMENTS, id=node["id"], endCursor=more["endCursor"])["node"]["comments"] | ||||||||||
| comments, more = comments + rest["nodes"], rest["pageInfo"] | ||||||||||
| threads.append({**node, "comments": comments}) | ||||||||||
| if not page["pageInfo"]["hasNextPage"]: | ||||||||||
| return threads | ||||||||||
| cursor = page["pageInfo"]["endCursor"] | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def pr_number(): | ||||||||||
| """The pull request to check, from PR_NUMBER or the merge queue's branch name.""" | ||||||||||
| if os.environ.get("PR_NUMBER"): | ||||||||||
| return int(os.environ["PR_NUMBER"]) | ||||||||||
| match = QUEUE_REF.search(os.environ.get("MERGE_GROUP_REF", "")) | ||||||||||
| if match is None: | ||||||||||
| raise SystemExit("::error::No PR_NUMBER, and MERGE_GROUP_REF names no pull request.") | ||||||||||
| return int(match.group(1)) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def escape(text): | ||||||||||
| """Text for a workflow command line: a path with a newline must not start a command of its own.""" | ||||||||||
| return text.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A") | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def main(): | ||||||||||
| """Checks the pull request and exits 1 if it defers a finding that must be fixed.""" | ||||||||||
| number = pr_number() | ||||||||||
| refused, unclassified = check(fetch(os.environ["GITHUB_REPOSITORY"], number)) | ||||||||||
| for line in unclassified: | ||||||||||
| print(f"::notice::Deferred without a review category, not checked: {escape(line)}") | ||||||||||
| for line in refused: | ||||||||||
| print(f"::error::{escape(line)}") | ||||||||||
| if refused: | ||||||||||
| print( | ||||||||||
| f"#{number} leaves {len(refused)} finding(s) that must be fixed for the release quality pass. " | ||||||||||
| "Fix each in the pull request and take the marker out of the reply; for a defect too large " | ||||||||||
| "for it, link a filed issue in the reply instead of the marker. To let one wait all the same, " | ||||||||||
| "a maintainer replies in its thread with <!-- deferral-approved -->. " | ||||||||||
| "Then run the checks again (re-run the job, or queue the pull request again)." | ||||||||||
| ) | ||||||||||
| return 1 | ||||||||||
| print(f"#{number}: no deferral to the release quality pass is on a finding that must be fixed.") | ||||||||||
| return 0 | ||||||||||
|
|
||||||||||
|
|
||||||||||
| if __name__ == "__main__": | ||||||||||
| sys.exit(main()) | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| """Checks for review-deferrals.py on review threads recorded from pull requests, cut down to the fields it reads.""" | ||
|
|
||
| import importlib.util | ||
| from pathlib import Path | ||
| import unittest | ||
| import unittest.mock | ||
|
|
||
| SPEC = importlib.util.spec_from_file_location("review_deferrals", Path(__file__).with_name("review-deferrals.py")) | ||
| MODULE = importlib.util.module_from_spec(SPEC) | ||
| SPEC.loader.exec_module(MODULE) | ||
|
|
||
| AUTHOR = "contributor" | ||
| REVIEWER = {"login": "github-actions", "__typename": "Bot"} | ||
| CODERABBIT = {"login": "coderabbitai", "__typename": "Bot"} | ||
|
|
||
|
|
||
| def comment(author, body, association="CONTRIBUTOR", editor=None): | ||
| return { | ||
| "url": f"https://github.com/o/r/pull/1#discussion_r{abs(hash(body)) % 10**9}", | ||
| "body": body, | ||
| "authorAssociation": association, | ||
| "lastEditedAt": "2026-11-16T03:39:59Z" if editor else None, | ||
| "author": author, | ||
| "editor": {"login": editor} if editor else None, | ||
| } | ||
|
|
||
|
|
||
| def thread(*comments, path="crates/data/src/dbf.rs"): | ||
| return {"path": path, "line": 120, "comments": list(comments)} | ||
|
|
||
|
|
||
| def finding(text, kind=None, editor=None): | ||
| marker = f"\n\nCategory: {kind}" if kind else "" | ||
| return comment(REVIEWER, text + marker, editor=editor) | ||
|
|
||
|
|
||
| def reply(text, author=AUTHOR, association="MEMBER"): | ||
| return comment({"login": author, "__typename": "User"}, text, association) | ||
|
|
||
|
|
||
| DEFER = reply("The reader skipping deleted records predates this PR; left for the release quality pass. <!-- quality-sweep -->") | ||
| BUG = "**Bug:** a deleted record shifts every later row's attributes by one." | ||
|
|
||
|
|
||
| class ReviewDeferrals(unittest.TestCase): | ||
| def check(self, *threads): | ||
| return MODULE.check(list(threads)) | ||
|
|
||
| def test_a_deferred_bug_is_refused(self): | ||
| refused, unclassified = self.check(thread(finding(BUG, "bug"), DEFER)) | ||
| self.assertEqual(len(refused), 1) | ||
| self.assertIn("classed it as bug", refused[0]) | ||
| self.assertEqual(unclassified, []) | ||
|
|
||
| def test_a_deferred_quality_point_passes(self): | ||
| quality = finding("**Quality:** appending `dbf` keeps the fuzz corpus's extension indexes.", "quality") | ||
| self.assertEqual(self.check(thread(quality, DEFER)), ([], [])) | ||
|
|
||
| def test_an_undeferred_bug_is_not_this_checks_business(self): | ||
| answer = reply("Fixed in d3eda9c78.") | ||
| self.assertEqual(self.check(thread(finding(BUG, "bug"), answer)), ([], [])) | ||
|
|
||
| def test_a_grouped_comment_takes_its_most_serious_category(self): | ||
| both = finding(BUG + "\nCategory: quality", "agents-md") | ||
| refused, _ = self.check(thread(both, DEFER)) | ||
| self.assertIn("classed it as agents-md", refused[0]) | ||
|
|
||
| def test_only_a_maintainer_overrides_the_check(self): | ||
| rule = finding("**Never silent:** the deleted-record notice has no test.", "agents-md") | ||
| by_contributor = reply("Misclassified. <!-- deferral-approved -->", association="CONTRIBUTOR") | ||
| by_bot = comment(CODERABBIT, "<!-- deferral-approved -->", "MEMBER") | ||
| by_maintainer_author = reply("An extra test for working code. <!-- deferral-approved -->") | ||
| mention = reply("I won't reply `<!-- deferral-approved -->` to this one.") | ||
| self.assertEqual(len(self.check(thread(rule, DEFER, by_contributor, by_bot, mention))[0]), 1) | ||
| self.assertEqual(self.check(thread(rule, DEFER, by_maintainer_author)), ([], [])) | ||
|
|
||
| def test_an_edited_finding_counts_as_must_fix(self): | ||
| edited = finding(BUG, "quality", editor=AUTHOR) | ||
| refused, _ = self.check(thread(edited, DEFER)) | ||
| self.assertIn("edited after the review posted it", refused[0]) | ||
|
|
||
| def test_threads_without_a_category_pass_with_a_notice(self): | ||
| rabbit = thread(comment(CODERABBIT, "_Potential issue_ | **Major** Record the uppercase DBF sidecar."), DEFER) | ||
| person = thread(reply("Should this clamp?", author="maintainer"), DEFER) | ||
| old_review = thread(finding("**Bug risk (low):** every non-I/O record error is counted."), DEFER) | ||
| unknown = thread(finding(BUG, "bugs"), DEFER) | ||
| refused, unclassified = self.check(rabbit, person, old_review, unknown) | ||
| self.assertEqual(refused, []) | ||
| self.assertEqual(len(unclassified), 4) | ||
|
|
||
| def test_the_marker_counts_wherever_it_sits_as_the_sweep_collects_it(self): | ||
| trailing = reply("Left for the release quality pass. <!-- quality-sweep --> Will do after the merge.") | ||
| tracked = reply("Left for the release quality pass. <!-- quality-sweep -->\n<!-- followup:inline:42 -->\n") | ||
| for deferral in (trailing, tracked): | ||
| self.assertEqual(len(self.check(thread(finding(BUG, "bug"), deferral))[0]), 1) | ||
|
|
||
| def test_a_category_line_may_be_emphasised_or_capitalised(self): | ||
| for line in ("**Category:** bug", "Category: `bug`", "Category: Bug", "_Category_: BUG", "Category: bug.", "Category: bug\r"): | ||
| refused, _ = self.check(thread(comment(REVIEWER, BUG + "\n\n" + line), DEFER)) | ||
| self.assertEqual(len(refused), 1, line) | ||
|
|
||
| def test_an_edited_finding_without_a_category_is_refused_too(self): | ||
| refused, unclassified = self.check(thread(finding(BUG, editor=AUTHOR), DEFER)) | ||
| self.assertEqual((len(refused), unclassified), (1, [])) | ||
|
|
||
| def test_a_category_is_a_line_of_its_own(self): | ||
| prose = finding("The Category: bug label in the legend is cut short.\n\nCategory: quality") | ||
| self.assertEqual(self.check(thread(prose, DEFER)), ([], [])) | ||
|
|
||
| def test_a_marker_in_the_opening_comment_is_not_a_deferral(self): | ||
| self.assertEqual(self.check(thread(finding(BUG + " <!-- quality-sweep -->", "bug"))), ([], [])) | ||
|
|
||
| def test_the_merge_queue_branch_names_the_pull_request(self): | ||
| ref = "refs/heads/gh-readonly-queue/main/pr-2655-76a6cd2823b4431c363e30a8023c7f69bccae938" | ||
| with unittest.mock.patch.dict(MODULE.os.environ, {"PR_NUMBER": "", "MERGE_GROUP_REF": ref}): | ||
| self.assertEqual(MODULE.pr_number(), 2655) | ||
|
|
||
| def test_fetch_reads_every_page_of_threads_and_comments(self): | ||
| def page(nodes, cursor=None): | ||
| return {"pageInfo": {"hasNextPage": cursor is not None, "endCursor": cursor}, "nodes": nodes} | ||
|
|
||
| first, second, third = finding(BUG, "bug"), reply("a"), DEFER | ||
| answers = iter([ | ||
| {"repository": {"pullRequest": {"reviewThreads": page( | ||
| [{"id": "T1", "path": "a.rs", "line": 1, "comments": page([first], "c1")}], "t1")}}}, | ||
| {"node": {"comments": page([second], "c2")}}, | ||
| {"node": {"comments": page([third])}}, | ||
| {"repository": {"pullRequest": {"reviewThreads": page( | ||
| [{"id": "T2", "path": "b.rs", "line": 2, "comments": page([])}])}}}, | ||
| ]) | ||
| with unittest.mock.patch.object(MODULE, "graphql", lambda *a, **k: next(answers)): | ||
| threads = MODULE.fetch("o/r", 1) | ||
| self.assertEqual([t["id"] for t in threads], ["T1", "T2"]) | ||
| self.assertEqual(threads[0]["comments"], [first, second, third]) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,7 +177,7 @@ jobs: | |
| echo "run=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| if grep -qE '^(Cargo\.lock|(.*/)?Cargo\.toml|deny\.toml|about\.toml|xtask/src/(main|notices)\.rs|(.*/)?THIRD-PARTY-LICENSES\.txt|\.github/scripts/(check-cargo-sources|test_[^/]+)\.py|\.github/workflows/ci\.yml|crates/map/src/color/(scientific|matplotlib)\.rs|crates/tiles/src/(symbols|style)\.rs|crates/data/src/(raster/crs|esripbf)\.rs)$|^(third-party/|\.cargo/)' <<<"$changed"; then | ||
| if grep -qE '^(Cargo\.lock|(.*/)?Cargo\.toml|deny\.toml|about\.toml|xtask/src/(main|notices)\.rs|(.*/)?THIRD-PARTY-LICENSES\.txt|\.github/scripts/(check-cargo-sources|review-deferrals|test_[^/]+)\.py|\.github/workflows/ci\.yml|crates/map/src/color/(scientific|matplotlib)\.rs|crates/tiles/src/(symbols|style)\.rs|crates/data/src/(raster/crs|esripbf)\.rs)$|^(third-party/|\.cargo/)' <<<"$changed"; then | ||
| echo "run=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "No dependency, licence or notice files changed; skipping." | ||
|
|
@@ -292,6 +292,27 @@ jobs: | |
| - name: Count direct row uses | ||
| run: cargo run --locked -q -p xtask -- rows | ||
|
|
||
| # A review point left for the release quality pass must be a quality point | ||
| # (.github/scripts/review-deferrals.py). The merge queue's run sees replies posted after the last | ||
| # push. It runs the checkout with a read-only token and no secrets, like every job here. | ||
| deferrals: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The licences job's unit-test step (around Confidence: high (regex read directly from the file). Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in aee6a17: |
||
| name: Review deferrals | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | ||
| with: | ||
| persist-credentials: false | ||
| - name: No defect left for the release quality pass | ||
| if: github.event_name == 'pull_request' || github.event_name == 'merge_group' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| MERGE_GROUP_REF: ${{ github.event.merge_group.head_ref }} | ||
| run: python3 .github/scripts/review-deferrals.py | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On a Confidence: medium. Whether it matters depends on how much the team relies on this check against its own edits. Category: security
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No change. Every job in |
||
|
|
||
| # The packages whose tests this run needs, for `test` (.github/scripts/test-selection.sh). Only | ||
| # tests are narrowed: lint, the wasm build, licences and the schema check run whole every time. | ||
| select: | ||
|
|
@@ -395,7 +416,7 @@ jobs: | |
| # unless their conditions below hold (the same as on the jobs), and every other job always runs. | ||
| tests_pass: | ||
| name: Tests pass | ||
| needs: [lint, wasm, ios, android, licenses, schema, rows, plan, select, test] | ||
| needs: [lint, wasm, ios, android, licenses, schema, rows, deferrals, plan, select, test] | ||
| if: ${{ always() }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "same definition" claim doesn't hold for the repo's other consumer. This docstring and the PR description say the release pass collects the marker wherever it sits, and that the check uses that same definition. But
.github/workflows/claude-autofix.yml(the jq program around line 249) treats a thread as deferred only when the last writer reply ends with\s*$. Either autofix misreads a mid-reply marker, or the sweep is end-anchored and this check over-refuses. Confirm the sweep's search and align the two, and say which one this docstring describes.Category: quality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change. The header describes the release quality pass, which collects the marker anywhere, and the check matches that. Autofix's narrower reading only decides which threads autofix leaves alone; the description now notes the difference.