Fix release publish recovery path#110
Conversation
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Review Summary by QodoImprove release publish recovery with attested crate temp directory
WalkthroughsDescription• Keep attested .crate download outside checkout for clean cargo package re-run • Add skip-existing flag to PyPI publish for idempotent recovery reruns • Extend release publish invariants to validate crate recovery properties • Add new check_publish_crate validation function for crate job requirements Diagramflowchart LR
A["Attested .crate artifact"] -->|"Download to runner.temp"| B["Clean checkout for cargo package"]
B -->|"Re-package with --locked"| C["Byte-identity verification"]
C -->|"Pre-publish check"| D["Publish to crates.io"]
D -->|"Post-publish verification"| E["Download from crates.io"]
E -->|"Hash comparison"| F["Verify match"]
G["PyPI publish"] -->|"skip-existing: true"| H["Idempotent recovery reruns"]
I["Invariants validation"] -->|"check_publish_crate"| J["Validate crate job structure"]
I -->|"check_publish_pypi"| K["Validate PyPI job structure"]
File Changes1. tests/release_publish_invariants.py
|
There was a problem hiding this comment.
Code Review
This pull request updates tests/release_publish_invariants.py to enforce invariants for publishing crates and PyPI packages, including ensuring PyPI uploads set skip-existing: true and introducing a new check_publish_crate function to validate the publish-crate job. Feedback was provided to improve the verification step check in check_publish_crate by tracking unique step names to prevent false positives from duplicate steps.
| verify_steps: list[dict[str, Any]] = [] | ||
| for index, raw_step in enumerate(steps): | ||
| step = mapping(raw_step, f"{path}: jobs.publish-crate.steps[{index}]") | ||
| if step.get("name") in verify_step_names: | ||
| verify_steps.append(step) | ||
| if len(verify_steps) != 2: | ||
| fail(f"{path}: publish-crate must have both attested .crate verification steps") |
There was a problem hiding this comment.
The current check only verifies that the total number of matched steps is 2. If one of the steps is duplicated and the other is missing, the check will still pass. To ensure both unique verification steps are present, we should track the unique names found and verify that both expected names are matched.
| verify_steps: list[dict[str, Any]] = [] | |
| for index, raw_step in enumerate(steps): | |
| step = mapping(raw_step, f"{path}: jobs.publish-crate.steps[{index}]") | |
| if step.get("name") in verify_step_names: | |
| verify_steps.append(step) | |
| if len(verify_steps) != 2: | |
| fail(f"{path}: publish-crate must have both attested .crate verification steps") | |
| verify_steps: list[dict[str, Any]] = [] | |
| found_names: set[str] = set() | |
| for index, raw_step in enumerate(steps): | |
| step = mapping(raw_step, f"{path}: jobs.publish-crate.steps[{index}]") | |
| name = step.get("name") | |
| if name in verify_step_names: | |
| verify_steps.append(step) | |
| found_names.add(name) | |
| if len(found_names) != 2: | |
| fail(f"{path}: publish-crate must have both attested .crate verification steps") |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
.cratedownload outside the checkout so the crates.io publish job can re-runcargo package --lockedon a clean worktreeskip-existing: truewhile retaining the post-publish hash verification against PyPI-served filesValidation
bash tests/release_publish_invariants.shbash tests/release_signed_release_invariants.shpython3 -m py_compile tests/release_publish_invariants.pygit diff --check