Repository navigation
Preserve passing receipts across late check checkpoints #1415
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
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 |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| import stat | ||
| import subprocess | ||
| from collections.abc import Iterator | ||
| from collections.abc import Callable | ||
|
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: Merge the new Callable import into the existing collections.abc import The diff adds a second line, |
||
| from contextlib import contextmanager, suppress | ||
| from pathlib import Path | ||
| from select import select | ||
|
|
@@ -147,12 +148,15 @@ def read_local_state(wt: Path, name: str) -> str: | |
|
|
||
| def write_local_state( | ||
| wt: Path, name: str, text: str, *, private: bool = False, exclusive: bool = False, | ||
| expected_head: str | None = None, | ||
| expected_head: str | None = None, preserve: Callable[[], bool] | None = None, | ||
| ) -> str | None: | ||
| with _local_state_directory(wt, create=True, lock=private or expected_head is not None) as fd: | ||
| lock = private or expected_head is not None or preserve is not None | ||
| with _local_state_directory(wt, create=True, lock=lock) as fd: | ||
| if expected_head is not None and (current_head := head(wt)) != expected_head: | ||
| return current_head | ||
| _regular_state(wt, fd, name) | ||
| if preserve is not None and preserve(): | ||
| return None | ||
| if private: | ||
| os.fchmod(fd, 0o700) | ||
| temp = f".{name}-{uuid4().hex}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4814,3 +4814,26 @@ def test_pr_marks_legacy_same_head_check_unverified(wt, gh, capsys, refresh): | |
| draft = json.loads(gh.calls[-1]["--input"])["body"] | ||
| assert "unverified" not in draft | ||
| assert_contains(draft, f"Recorded for `{head[:12]}`\n- `echo ok`: exit 0", "Manual validation evidence.") | ||
|
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: Test silently depends on workflow.toml declaring at least two checks The 'commands differ' step saves |
||
|
|
||
|
|
||
| def test_late_checkpoint_preserves_completed_pass(wt, gh, capsys, head, monkeypatch): | ||
| def run_checks(cfg, path, *, progress, status, checkpoint, workflow): | ||
| results = tuple(CheckResult(c, 0, 0, "", input_key="key") for c in cfg.checks) | ||
| passed = CheckReport(head, False, results, cli.sandbox.settings_fingerprint(cfg)) | ||
| incomplete = CheckResult(cli.sandbox.INCOMPLETE_CHECK_COMMAND, 1, 0.0, "") | ||
| partial = replace(passed, results=(results[0], incomplete)) | ||
| checkpoint(partial) | ||
| assert cli._load_report(wt) == partial | ||
| cli._save_report(wt, passed) | ||
| checkpoint(partial) | ||
| assert cli._current_check_report(wt, cfg, head) == passed | ||
| cli._save_report(wt, replace(passed, results=results[:1])) | ||
| checkpoint(partial) | ||
| assert cli._load_report(wt) == partial | ||
| cli._save_report(wt, passed) | ||
| return replace(passed, results=(replace(results[0], exit_code=1),)) | ||
|
|
||
| monkeypatch.setattr(cli.sandbox, "run_checks", run_checks) | ||
| code, _, err = run(capsys, "check") | ||
| assert code == 1 and "(exit 1)" in err, err | ||
| assert cli._load_report(wt).results[0].exit_code == 1 | ||
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: Reflow the edited paragraph
The new sentence leaves
failures still replace passes. Runners cannot select stages or mint receipts. Stage admissionon one line that is much longer than the surrounding ~80-column wrap. Reflow the paragraph so it matches the rest of the file.