Repository navigation
Show reusable local checks in status #1423
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
f40e445
462bb6b
c885706
f41fe72
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 |
|---|---|---|
|
|
@@ -1692,10 +1692,14 @@ def cmd_status(args: argparse.Namespace) -> int: | |
| print(f"branch: {branch}") | ||
| print(f"head: {head}") | ||
| print(f"base: {config.base_branch}") | ||
| print(f"dirty: {'yes' if worktree.is_dirty(wt) else 'no'}") | ||
| dirty = worktree.is_dirty(wt) | ||
| print(f"dirty: {'yes' if dirty else 'no'}") | ||
| checked = not dirty and _current_check_report(wt, config, head) is not None | ||
| print(f"local checks: {'passed' if checked else 'no reusable pass'}", flush=True) | ||
|
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. suggestion: New label breaks the aligned status columns Every other status line pads its label to a 10-character column ( |
||
| pr = github.pr_for_branch(config.repo, branch) | ||
| if pr is None: | ||
| print("pr: none (commit changes and pass `loopzero check` before `loopzero pr`)") | ||
| hint = "run `loopzero pr`" if checked else "commit changes and pass `loopzero check` before `loopzero pr`" | ||
| print(f"pr: none ({hint})") | ||
| return 0 | ||
| print(f"pr: #{pr.number} {pr.url} ({'draft' if pr.is_draft else 'ready'}, {pr.state})") | ||
| reviews = _pr_reviews(config.repo, pr.number) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3668,12 +3668,48 @@ def test_status_full(wt: Path, gh: FakeGh, capsys, git_calls) -> None: | |
| code, out, _ = run(capsys, "status") | ||
| assert_git_cost(git_calls, 7, 1) | ||
| assert code == 0 and "dirty: yes" in out | ||
| assert "local checks: passed" not in out | ||
| assert f"pr: #7 {URL} (draft, OPEN)" in out | ||
| assert f"review: primary on {head[:12]} (approved)" in out | ||
| assert "ready: no" in out and " - required check 'checks' is pending" in out | ||
| assert sum(1 for c in gh.calls if c["argv"][:2] == ["api", reviews_key()[4:]]) == 1 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("receipt", ["pass", "missing", "partial", "failed", "stale", "fingerprint"]) | ||
|
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. suggestion: Clean-tree dirty receipt is not covered in the no-PR test The acceptance criteria include rejecting dirty worktrees and dirty receipts. |
||
| def test_status_no_pr_reports_receipt_before_lookup(wt, gh, capsys, monkeypatch, head, receipt): | ||
| if receipt != "missing": | ||
| arm_readiness(gh, head, wt, local_exit=int(receipt == "failed")) | ||
| path = wt / ".loopzero" / "checks.json" | ||
| report = json.loads(path.read_text()) | ||
| if receipt == "partial": | ||
| report["results"].pop() | ||
| elif receipt == "stale": | ||
| report["head"] = "0" * 40 | ||
| elif receipt == "fingerprint": | ||
| report["settings_sha256"] = "0" * 64 | ||
| path.write_text(json.dumps(report)) | ||
|
|
||
| def lookup(*_): | ||
| local = capsys.readouterr().out | ||
| assert "local checks:" in local | ||
| assert ("local checks: passed" in local) == (receipt == "pass") | ||
|
|
||
| monkeypatch.setattr(github, "pr_for_branch", lookup) | ||
| code, out, _ = run(capsys, "status") | ||
| assert code == 0 | ||
| hint = "run `loopzero pr`" if receipt == "pass" else "pass `loopzero check`" | ||
| assert hint in out | ||
|
|
||
|
|
||
| def test_status_shows_local_pass_with_pending_ci(wt, gh, capsys, head): | ||
| arm_approved_pr_with_check_result(gh, head, wt, "pending") | ||
|
|
||
| code, out, _ = run(capsys, "status") | ||
|
|
||
| assert code == 0 and "local checks: passed" in out | ||
| assert "ready: no" in out and "required check 'checks' is pending" in out | ||
|
|
||
|
|
||
| @pytest.mark.parametrize(("signum", "status"), [ | ||
| (signal.SIGTERM, -signal.SIGTERM), | ||
| (signal.SIGINT, 130), | ||
|
|
@@ -3703,7 +3739,7 @@ def announce(process, *args, **kwargs): | |
| child = None | ||
| try: | ||
| # Read until the supervisor enters communicate on the offline gh child. | ||
| for _ in range(6): | ||
| for _ in range(7): | ||
| assert select([process.stdout], [], [], 5)[0] | ||
| line = process.stdout.readline().strip() | ||
| if line.isdigit(): | ||
|
|
||
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.
suggestion: Receipt is verified twice when a PR exists
When a PR exists,
cmd_statuschecks the receipt once through_current_check_reportto print the status line. Then_readiness(cli.py:286-287) loads the same receipt again and recomputessandbox.settings_fingerprint. If a check runner is configured, that also re-hashes the runner executable. The two results should agree, but the work is duplicated, and the line and the readiness reason could drift if either path changes later. Smallest fix: compute_load_reportplus_check_report_problemonce in status and pass the result to_readinessthrough an optional parameter. Alternatively, accept the extra cost, since status is not a hot path.