Spaces:
Running
Running
Add partner hosted receipt validation action (#51)
Browse files- TRY_IT.md +14 -0
- actions/validate-hosted-proof-receipt/action.yml +15 -0
- tests/test_receipt_action.py +43 -0
TRY_IT.md
CHANGED
|
@@ -104,6 +104,20 @@ Exit status `0` means the object matches exactly one current v1 shape; status
|
|
| 104 |
`1` means it does not. This validates structure only and does not turn a
|
| 105 |
synthetic example into run evidence or authenticate a real receipt.
|
| 106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
If it passes, returns a redacted failure or gives you confusing friction,
|
| 108 |
[send the public run](https://github.com/noqt/Lumi-Eggcracker/issues/new?template=hosted_probe_result.yml).
|
| 109 |
The short form asks for the workflow URL and what happened. That is useful
|
|
|
|
| 104 |
`1` means it does not. This validates structure only and does not turn a
|
| 105 |
synthetic example into run evidence or authenticate a real receipt.
|
| 106 |
|
| 107 |
+
A partner repository can call the same local validator as a pinned composite
|
| 108 |
+
action:
|
| 109 |
+
|
| 110 |
+
```yaml
|
| 111 |
+
- uses: noqt/Lumi-Eggcracker/actions/validate-hosted-proof-receipt@<40-character-commit-sha>
|
| 112 |
+
with:
|
| 113 |
+
receipt: receipt.json
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
Replace the placeholder with an immutable commit containing the action. The
|
| 117 |
+
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
|
actions/validate-hosted-proof-receipt/action.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Validate Lumi Eggcracker hosted-proof receipt
|
| 2 |
+
description: Validate one local receipt against the bounded public v1 schema without uploading it
|
| 3 |
+
inputs:
|
| 4 |
+
receipt:
|
| 5 |
+
description: Path to one local hosted-proof receipt JSON object
|
| 6 |
+
required: true
|
| 7 |
+
runs:
|
| 8 |
+
using: composite
|
| 9 |
+
steps:
|
| 10 |
+
- name: Validate v1 receipt locally
|
| 11 |
+
shell: bash --noprofile --norc -euo pipefail {0}
|
| 12 |
+
env:
|
| 13 |
+
RECEIPT_PATH: ${{ inputs.receipt }}
|
| 14 |
+
run: |
|
| 15 |
+
python3 "$GITHUB_ACTION_PATH/../../scripts/validate_hosted_proof_receipt.py" "$RECEIPT_PATH"
|
tests/test_receipt_action.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
ACTION = ROOT / "actions" / "validate-hosted-proof-receipt" / "action.yml"
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class HostedProofReceiptActionTests(unittest.TestCase):
|
| 13 |
+
def setUp(self) -> None:
|
| 14 |
+
self.metadata = yaml.safe_load(ACTION.read_text(encoding="utf-8"))
|
| 15 |
+
|
| 16 |
+
def test_action_exposes_only_one_required_local_receipt_input(self) -> None:
|
| 17 |
+
self.assertEqual(
|
| 18 |
+
{
|
| 19 |
+
"receipt": {
|
| 20 |
+
"description": "Path to one local hosted-proof receipt JSON object",
|
| 21 |
+
"required": True,
|
| 22 |
+
}
|
| 23 |
+
},
|
| 24 |
+
self.metadata["inputs"],
|
| 25 |
+
)
|
| 26 |
+
self.assertNotIn("outputs", self.metadata)
|
| 27 |
+
|
| 28 |
+
def test_action_passes_the_path_by_environment_to_the_local_validator(self) -> None:
|
| 29 |
+
self.assertEqual("composite", self.metadata["runs"]["using"])
|
| 30 |
+
self.assertEqual(1, len(self.metadata["runs"]["steps"]))
|
| 31 |
+
step = self.metadata["runs"]["steps"][0]
|
| 32 |
+
self.assertEqual("bash --noprofile --norc -euo pipefail {0}", step["shell"])
|
| 33 |
+
self.assertEqual({"RECEIPT_PATH": "${{ inputs.receipt }}"}, step["env"])
|
| 34 |
+
self.assertEqual(
|
| 35 |
+
'python3 "$GITHUB_ACTION_PATH/../../scripts/validate_hosted_proof_receipt.py" '
|
| 36 |
+
'"$RECEIPT_PATH"\n',
|
| 37 |
+
step["run"],
|
| 38 |
+
)
|
| 39 |
+
self.assertNotIn("inputs.receipt", step["run"])
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
if __name__ == "__main__":
|
| 43 |
+
unittest.main()
|