Skip to content

Commit 99ce27f

Browse files
authored
Merge branch 'main' into feat/verified-decision-price-series
2 parents ac20c8d + 238f250 commit 99ce27f

4 files changed

Lines changed: 42 additions & 4 deletions

File tree

.github/workflows/update-qpk-pin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ on:
1313
- "scripts/check_qpk_pin_consistency.py"
1414
- "scripts/open_downstream_qpk_pin_prs.py"
1515
- "scripts/merge_verified_strategy_qpk_pin_prs.py"
16+
- "scripts/report_consumer_qpk_pin_prs.py"
1617
- "tests/test_qpk_pin_consistency.py"
1718
- "tests/test_merge_verified_strategy_qpk_pin_prs.py"
19+
- "tests/test_report_consumer_qpk_pin_prs.py"
1820
- "tests/test_update_qpk_pin_workflow.py"
1921
- "docs/**"
2022
- "**.md"

scripts/report_consumer_qpk_pin_prs.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,29 @@ def generated_prs(repo: RepoSpec, *, env: dict[str, str]) -> list[dict[str, Any]
4444
"--limit",
4545
"100",
4646
"--json",
47-
"author,baseRefName,headRefName,isCrossRepository,isDraft,number,title,updatedAt,url",
47+
"author,baseRefName,headRefName,isCrossRepository,isDraft,number,statusCheckRollup,title,updatedAt,url",
4848
],
4949
env=env,
5050
)
5151
return json.loads(result.stdout)
5252

5353

54+
def ci_status(pr: dict[str, Any]) -> str:
55+
"""Return a display-only CI state; never use it to mutate consumer PRs."""
56+
57+
checks = pr.get("statusCheckRollup")
58+
if not isinstance(checks, list) or not checks:
59+
return "MISSING"
60+
if any(not isinstance(check, dict) or check.get("status") != "COMPLETED" for check in checks):
61+
return "PENDING"
62+
conclusions = {str(check.get("conclusion") or "").upper() for check in checks}
63+
if conclusions == {"SUCCESS"}:
64+
return "GREEN"
65+
if conclusions & {"FAILURE", "TIMED_OUT", "CANCELLED", "ACTION_REQUIRED", "STARTUP_FAILURE"}:
66+
return "FAILED"
67+
return "NON_GREEN"
68+
69+
5470
def classify_generated_prs(
5571
prs: Iterable[dict[str, Any]],
5672
*,
@@ -71,7 +87,9 @@ def classify_generated_prs(
7187

7288

7389
def render_row(repo: RepoSpec, current: list[dict[str, Any]], stale: list[dict[str, Any]]) -> str:
74-
current_refs = ", ".join(f"[#{item['number']}]({item['url']})" for item in current) or "—"
90+
current_refs = ", ".join(
91+
f"[#{item['number']}]({item['url']}) · {ci_status(item)}" for item in current
92+
) or "—"
7593
stale_refs = ", ".join(f"[#{item['number']}]({item['url']})" for item in stale) or "—"
7694
return f"| {repo.name} | {current_refs} | {stale_refs} |"
7795

@@ -93,7 +111,7 @@ def main() -> int:
93111
print()
94112
print("Consumer repositories are report-only: they are never auto-merged or auto-closed.")
95113
print()
96-
print("| Repository | Current generated PR | Recognizable stale generated PRs |")
114+
print("| Repository | Current generated PR (CI) | Recognizable stale generated PRs |")
97115
print("| --- | --- | --- |")
98116
for repo in CONSUMER_REPOS:
99117
current, stale = classify_generated_prs(

tests/test_report_consumer_qpk_pin_prs.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from scripts.report_consumer_qpk_pin_prs import classify_generated_prs, render_row
3+
from scripts.report_consumer_qpk_pin_prs import ci_status, classify_generated_prs, render_row
44
from scripts.open_downstream_qpk_pin_prs import RepoSpec
55

66

@@ -17,6 +17,7 @@ def _pr(*, branch: str, number: int = 1) -> dict[str, object]:
1717
"number": number,
1818
"title": "chore(deps): align QPK pin to 8378e939d932",
1919
"url": f"https://example.test/pr/{number}",
20+
"statusCheckRollup": [],
2021
}
2122

2223

@@ -45,3 +46,18 @@ def test_render_row_includes_links_without_mutation_instruction() -> None:
4546
assert "LongBridgePlatform" in row
4647
assert "[#10](https://example.test/pr/10)" in row
4748
assert "[#9](https://example.test/pr/9)" in row
49+
assert "MISSING" in row
50+
51+
52+
def test_ci_status_distinguishes_green_pending_failed_and_non_green() -> None:
53+
pr = _pr(branch="auto/qpk-pin-sync-8378e939d932-longbridgeplatform")
54+
55+
assert ci_status(pr) == "MISSING"
56+
pr["statusCheckRollup"] = [{"status": "IN_PROGRESS", "conclusion": ""}]
57+
assert ci_status(pr) == "PENDING"
58+
pr["statusCheckRollup"] = [{"status": "COMPLETED", "conclusion": "SUCCESS"}]
59+
assert ci_status(pr) == "GREEN"
60+
pr["statusCheckRollup"] = [{"status": "COMPLETED", "conclusion": "FAILURE"}]
61+
assert ci_status(pr) == "FAILED"
62+
pr["statusCheckRollup"] = [{"status": "COMPLETED", "conclusion": "SKIPPED"}]
63+
assert ci_status(pr) == "NON_GREEN"

tests/test_update_qpk_pin_workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,10 @@ def test_dependency_success_reaches_only_guarded_pr_step(tmp_path: Path) -> None
238238
assert ' - ".github/workflows/update-qpk-pin.yml"' in workflow
239239
assert ' - "scripts/open_downstream_qpk_pin_prs.py"' in workflow
240240
assert ' - "scripts/merge_verified_strategy_qpk_pin_prs.py"' in workflow
241+
assert ' - "scripts/report_consumer_qpk_pin_prs.py"' in workflow
241242
assert ' - "tests/test_qpk_pin_consistency.py"' in workflow
242243
assert ' - "tests/test_merge_verified_strategy_qpk_pin_prs.py"' in workflow
244+
assert ' - "tests/test_report_consumer_qpk_pin_prs.py"' in workflow
243245
assert ' - "tests/test_update_qpk_pin_workflow.py"' in workflow
244246
assert "workflow_dispatch:" not in workflow
245247

0 commit comments

Comments
 (0)