Skip to content

Commit c331183

Browse files
author
Nathan Gillett
committed
Read signing golden fixtures from spec checkout
Signed-off-by: Nathan Gillett <nathan@intentproof.io>
1 parent b0bc499 commit c331183

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16+
- name: Checkout spec repository
17+
uses: actions/checkout@v4
18+
with:
19+
repository: IntentProof/intentproof-spec
20+
ref: main
21+
path: intentproof-spec
22+
1623
- uses: actions/setup-python@v5
1724
with:
1825
python-version: '3.11'
@@ -22,4 +29,11 @@ jobs:
2229
pip install -e ".[dev]"
2330
2431
- name: Run tests with coverage
32+
env:
33+
INTENTPROOF_SPEC_DIR: intentproof-spec
2534
run: bash ./scripts/run-coverage-gate.sh
35+
36+
- name: Verify sdk-signing fixtures synced with spec
37+
env:
38+
INTENTPROOF_SPEC_DIR: intentproof-spec
39+
run: bash ./scripts/check-sdk-signing-fixtures-sync.sh
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
# Fail when mirrored SDK signing fixtures drift from intentproof-spec.
3+
set -euo pipefail
4+
5+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6+
LOCAL="${ROOT}/tests/fixtures"
7+
CANONICAL="${INTENTPROOF_SPEC_DIR:?INTENTPROOF_SPEC_DIR must point at intentproof-spec}/golden/sdk-signing"
8+
9+
if [[ ! -d "$CANONICAL" ]]; then
10+
echo "canonical sdk-signing fixtures not found at ${CANONICAL}" >&2
11+
exit 1
12+
fi
13+
14+
shopt -s nullglob
15+
files=("${CANONICAL}"/signing_*)
16+
if [[ ${#files[@]} -eq 0 ]]; then
17+
echo "no signing fixtures under ${CANONICAL}" >&2
18+
exit 1
19+
fi
20+
21+
fail=0
22+
for canonical in "${files[@]}"; do
23+
base="$(basename "$canonical")"
24+
local_path="${LOCAL}/${base}"
25+
if [[ ! -f "$local_path" ]]; then
26+
continue
27+
fi
28+
if ! cmp -s "$canonical" "$local_path"; then
29+
echo "sdk-signing fixture drift: ${base} differs from spec golden/sdk-signing" >&2
30+
fail=1
31+
fi
32+
done
33+
34+
if [[ "$fail" -ne 0 ]]; then
35+
exit 1
36+
fi
37+
38+
echo "PASS: sdk-signing fixture mirrors match spec golden."

tests/test_sdk.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import base64
66
import json
7+
import os
78
import tempfile
89
import threading
910
from pathlib import Path
@@ -287,8 +288,15 @@ def fake_post(url: str, event: dict) -> None:
287288
assert len(posted) == 1
288289

289290

291+
def _signing_fixture_dir() -> Path:
292+
spec_dir = os.environ.get("INTENTPROOF_SPEC_DIR", "").strip()
293+
if spec_dir:
294+
return Path(spec_dir) / "golden" / "sdk-signing"
295+
return Path(__file__).parent / "fixtures"
296+
297+
290298
def test_signing_golden_bytes() -> None:
291-
fixture_dir = Path(__file__).parent / "fixtures"
299+
fixture_dir = _signing_fixture_dir()
292300
unsigned = json.loads(
293301
(fixture_dir / "signing_unsigned_event.json").read_text(encoding="utf-8")
294302
)

0 commit comments

Comments
 (0)