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.
.github/workflows/ci.yml
CHANGED
|
@@ -27,6 +27,12 @@ jobs:
|
|
| 27 |
PYTHONPATH: src
|
| 28 |
run: python -m unittest discover -s tests -p test_hosted_proof.py -v
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
test-and-package:
|
| 31 |
runs-on: ubuntu-24.04
|
| 32 |
strategy:
|
|
|
|
| 27 |
PYTHONPATH: src
|
| 28 |
run: python -m unittest discover -s tests -p test_hosted_proof.py -v
|
| 29 |
|
| 30 |
+
receipt-action-consumer:
|
| 31 |
+
name: receipt-action-consumer
|
| 32 |
+
uses: ./.github/workflows/validate-hosted-proof-receipt.yml
|
| 33 |
+
with:
|
| 34 |
+
receipt: schemas/examples/hosted-proof-receipt-v1-success.json
|
| 35 |
+
|
| 36 |
test-and-package:
|
| 37 |
runs-on: ubuntu-24.04
|
| 38 |
strategy:
|
.github/workflows/validate-hosted-proof-receipt.yml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Validate Lumi Eggcracker hosted-proof receipt
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_call:
|
| 5 |
+
inputs:
|
| 6 |
+
receipt:
|
| 7 |
+
description: Path to one local hosted-proof receipt JSON object
|
| 8 |
+
required: true
|
| 9 |
+
type: string
|
| 10 |
+
|
| 11 |
+
permissions:
|
| 12 |
+
contents: read
|
| 13 |
+
|
| 14 |
+
jobs:
|
| 15 |
+
validate:
|
| 16 |
+
runs-on: ubuntu-24.04
|
| 17 |
+
timeout-minutes: 5
|
| 18 |
+
steps:
|
| 19 |
+
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
|
| 20 |
+
with:
|
| 21 |
+
persist-credentials: false
|
| 22 |
+
|
| 23 |
+
- name: Validate the local v1 receipt structure
|
| 24 |
+
uses: noqt/Lumi-Eggcracker/actions/validate-hosted-proof-receipt@7cbd20d936e37531eb020d11ec3d4ddc9f1d8245
|
| 25 |
+
with:
|
| 26 |
+
receipt: ${{ inputs.receipt }}
|
TRY_IT.md
CHANGED
|
@@ -118,6 +118,22 @@ receipt path is passed as an environment value rather than interpolated into a
|
|
| 118 |
shell command. The action uploads nothing and prints only the bounded validator
|
| 119 |
result; it still validates structure rather than authenticating a run.
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
If it passes, returns a redacted failure or gives you confusing friction,
|
| 122 |
[send the public run](https://github.com/noqt/Lumi-Eggcracker/issues/new?template=hosted_probe_result.yml).
|
| 123 |
The short form asks for the workflow URL and what happened. That is useful
|
|
|
|
| 118 |
shell command. The action uploads nothing and prints only the bounded validator
|
| 119 |
result; it still validates structure rather than authenticating a run.
|
| 120 |
|
| 121 |
+
For a complete read-only job, a partner repository can instead call the reusable
|
| 122 |
+
workflow with the same local receipt path:
|
| 123 |
+
|
| 124 |
+
```yaml
|
| 125 |
+
jobs:
|
| 126 |
+
validate-eggcracker-receipt:
|
| 127 |
+
uses: noqt/Lumi-Eggcracker/.github/workflows/validate-hosted-proof-receipt.yml@<40-character-commit-sha>
|
| 128 |
+
with:
|
| 129 |
+
receipt: receipt.json
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
Pin the workflow to an immutable commit containing it. The job checks out the
|
| 133 |
+
caller repository with persisted credentials disabled, then invokes the pinned
|
| 134 |
+
local validator action. It requests read-only contents permission, exposes no
|
| 135 |
+
outputs or secrets and uploads no receipt.
|
| 136 |
+
|
| 137 |
If it passes, returns a redacted failure or gives you confusing friction,
|
| 138 |
[send the public run](https://github.com/noqt/Lumi-Eggcracker/issues/new?template=hosted_probe_result.yml).
|
| 139 |
The short form asks for the workflow URL and what happened. That is useful
|
tests/test_reusable_receipt_workflow.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import unittest
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
import yaml
|
| 7 |
+
|
| 8 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 9 |
+
WORKFLOW = ROOT / ".github" / "workflows" / "validate-hosted-proof-receipt.yml"
|
| 10 |
+
CI_WORKFLOW = ROOT / ".github" / "workflows" / "ci.yml"
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class ReusableReceiptWorkflowTests(unittest.TestCase):
|
| 14 |
+
def setUp(self) -> None:
|
| 15 |
+
self.workflow = yaml.safe_load(WORKFLOW.read_text(encoding="utf-8"))
|
| 16 |
+
|
| 17 |
+
def test_workflow_exposes_only_one_required_string_input(self) -> None:
|
| 18 |
+
self.assertEqual(
|
| 19 |
+
{
|
| 20 |
+
"workflow_call": {
|
| 21 |
+
"inputs": {
|
| 22 |
+
"receipt": {
|
| 23 |
+
"description": (
|
| 24 |
+
"Path to one local hosted-proof receipt JSON object"
|
| 25 |
+
),
|
| 26 |
+
"required": True,
|
| 27 |
+
"type": "string",
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
},
|
| 32 |
+
self.workflow[True],
|
| 33 |
+
)
|
| 34 |
+
self.assertNotIn("outputs", self.workflow[True]["workflow_call"])
|
| 35 |
+
self.assertNotIn("secrets", self.workflow[True]["workflow_call"])
|
| 36 |
+
|
| 37 |
+
def test_workflow_is_read_only_and_uses_pinned_actions(self) -> None:
|
| 38 |
+
self.assertEqual({"contents": "read"}, self.workflow["permissions"])
|
| 39 |
+
self.assertEqual(
|
| 40 |
+
{
|
| 41 |
+
"runs-on": "ubuntu-24.04",
|
| 42 |
+
"timeout-minutes": 5,
|
| 43 |
+
"steps": [
|
| 44 |
+
{
|
| 45 |
+
"uses": (
|
| 46 |
+
"actions/checkout@"
|
| 47 |
+
"d23441a48e516b6c34aea4fa41551a30e30af803"
|
| 48 |
+
),
|
| 49 |
+
"with": {"persist-credentials": False},
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"name": "Validate the local v1 receipt structure",
|
| 53 |
+
"uses": (
|
| 54 |
+
"noqt/Lumi-Eggcracker/actions/"
|
| 55 |
+
"validate-hosted-proof-receipt@"
|
| 56 |
+
"7cbd20d936e37531eb020d11ec3d4ddc9f1d8245"
|
| 57 |
+
),
|
| 58 |
+
"with": {"receipt": "${{ inputs.receipt }}"},
|
| 59 |
+
},
|
| 60 |
+
],
|
| 61 |
+
},
|
| 62 |
+
self.workflow["jobs"]["validate"],
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
def test_ci_replays_the_reusable_caller_path(self) -> None:
|
| 66 |
+
ci = yaml.safe_load(CI_WORKFLOW.read_text(encoding="utf-8"))
|
| 67 |
+
self.assertEqual(
|
| 68 |
+
{
|
| 69 |
+
"name": "receipt-action-consumer",
|
| 70 |
+
"uses": "./.github/workflows/validate-hosted-proof-receipt.yml",
|
| 71 |
+
"with": {
|
| 72 |
+
"receipt": (
|
| 73 |
+
"schemas/examples/hosted-proof-receipt-v1-success.json"
|
| 74 |
+
)
|
| 75 |
+
},
|
| 76 |
+
},
|
| 77 |
+
ci["jobs"]["receipt-action-consumer"],
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
def test_workflow_does_not_upload_or_interpolate_the_receipt_in_a_shell(self) -> None:
|
| 81 |
+
text = WORKFLOW.read_text(encoding="utf-8")
|
| 82 |
+
self.assertNotIn("upload-artifact", text)
|
| 83 |
+
self.assertNotIn("run:", text)
|
| 84 |
+
self.assertNotIn("secrets: inherit", text)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
if __name__ == "__main__":
|
| 88 |
+
unittest.main()
|