Spaces:
Running
Running
Add reusable hosted-proof receipt workflow (#54)
Browse filesRelease a read-only reusable caller path for structural v1 receipt validation. This does not authenticate a run or represent adoption.
Files changed (4)
26 unmodified lines27282930313226 unmodified linesPYTHONPATH: srcrun: python -m unittest discover -s tests -p test_hosted_proof.py -vtest-and-package:runs-on: ubuntu-24.04strategy:26 unmodified lines27282930313233343536373826 unmodified linesPYTHONPATH: srcrun: python -m unittest discover -s tests -p test_hosted_proof.py -vreceipt-action-consumer:name: receipt-action-consumeruses: ./.github/workflows/validate-hosted-proof-receipt.ymlwith:receipt: schemas/examples/hosted-proof-receipt-v1-success.jsontest-and-package:runs-on: ubuntu-24.04strategy:
1234567891011121314151617181920212223242526name: Validate Lumi Eggcracker hosted-proof receipt
on: workflow_call: inputs: receipt: description: Path to one local hosted-proof receipt JSON object required: true type: string
permissions: contents: read
jobs: validate: runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: persist-credentials: false
- name: Validate the local v1 receipt structure uses: noqt/Lumi-Eggcracker/actions/validate-hosted-proof-receipt@7cbd20d936e37531eb020d11ec3d4ddc9f1d8245 with: receipt: ${{ inputs.receipt }}117 unmodified lines118119120121122123117 unmodified linesshell command. The action uploads nothing and prints only the bounded validatorresult; it still validates structure rather than authenticating a run.If it passes, returns a redacted failure or gives you confusing friction,[send the public run](https://github.com/noqt/Lumi-Eggcracker/issues/new?template=hosted_probe_result.yml).The short form asks for the workflow URL and what happened. That is useful117 unmodified lines118119120121122123124125126127128129130131132133134135136137138139117 unmodified linesshell command. The action uploads nothing and prints only the bounded validatorresult; it still validates structure rather than authenticating a run.For a complete read-only job, a partner repository can instead call the reusableworkflow with the same local receipt path:```yamljobs:validate-eggcracker-receipt:uses: noqt/Lumi-Eggcracker/.github/workflows/validate-hosted-proof-receipt.yml@<40-character-commit-sha>with:receipt: receipt.json```Pin the workflow to an immutable commit containing it. The job checks out thecaller repository with persisted credentials disabled, then invokes the pinnedlocal validator action. It requests read-only contents permission, exposes nooutputs or secrets and uploads no receipt.If it passes, returns a redacted failure or gives you confusing friction,[send the public run](https://github.com/noqt/Lumi-Eggcracker/issues/new?template=hosted_probe_result.yml).The short form asks for the workflow URL and what happened. That is useful
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788from __future__ import annotations
import unittestfrom pathlib import Path
import yaml
ROOT = Path(__file__).resolve().parents[1]WORKFLOW = ROOT / ".github" / "workflows" / "validate-hosted-proof-receipt.yml"CI_WORKFLOW = ROOT / ".github" / "workflows" / "ci.yml"
class ReusableReceiptWorkflowTests(unittest.TestCase): def setUp(self) -> None: self.workflow = yaml.safe_load(WORKFLOW.read_text(encoding="utf-8"))
def test_workflow_exposes_only_one_required_string_input(self) -> None: self.assertEqual( { "workflow_call": { "inputs": { "receipt": { "description": ( "Path to one local hosted-proof receipt JSON object" ), "required": True, "type": "string", } } } }, self.workflow[True], ) self.assertNotIn("outputs", self.workflow[True]["workflow_call"]) self.assertNotIn("secrets", self.workflow[True]["workflow_call"])
def test_workflow_is_read_only_and_uses_pinned_actions(self) -> None: self.assertEqual({"contents": "read"}, self.workflow["permissions"]) self.assertEqual( { "runs-on": "ubuntu-24.04", "timeout-minutes": 5, "steps": [ { "uses": ( "actions/checkout@" "d23441a48e516b6c34aea4fa41551a30e30af803" ), "with": {"persist-credentials": False}, }, { "name": "Validate the local v1 receipt structure", "uses": ( "noqt/Lumi-Eggcracker/actions/" "validate-hosted-proof-receipt@" "7cbd20d936e37531eb020d11ec3d4ddc9f1d8245" ), "with": {"receipt": "${{ inputs.receipt }}"}, }, ], }, self.workflow["jobs"]["validate"], )
def test_ci_replays_the_reusable_caller_path(self) -> None: ci = yaml.safe_load(CI_WORKFLOW.read_text(encoding="utf-8")) self.assertEqual( { "name": "receipt-action-consumer", "uses": "./.github/workflows/validate-hosted-proof-receipt.yml", "with": { "receipt": ( "schemas/examples/hosted-proof-receipt-v1-success.json" ) }, }, ci["jobs"]["receipt-action-consumer"], )
def test_workflow_does_not_upload_or_interpolate_the_receipt_in_a_shell(self) -> None: text = WORKFLOW.read_text(encoding="utf-8") self.assertNotIn("upload-artifact", text) self.assertNotIn("run:", text) self.assertNotIn("secrets: inherit", text)
if __name__ == "__main__": unittest.main().github/workflows/ci.yml+6
.github/workflows/validate-hosted-proof-receipt.ymlAdded+26
TRY_IT.md+16
tests/test_reusable_receipt_workflow.pyAdded+88