-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (44 loc) · 2.11 KB
/
Copy pathcontract-registry-live.yml
File metadata and controls
50 lines (44 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Contract registry live drift
on:
workflow_dispatch:
schedule:
- cron: "17 5 * * 1"
permissions:
contents: read
jobs:
verify-v1-1:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Compare published v1.1.1 release with vendored contracts
env:
REGISTRY_BASE: https://coding-autopilot-system.github.io/cas-contracts/registry
PINNED_VERSION: 1.1.1
VENDORED_ROOT: src/GsdOrchestrator.Tests/Contracts/cas-contracts/v1.1.1
shell: python
run: |
import hashlib, json, os, pathlib, urllib.request
def canonical_bytes(data: bytes) -> bytes:
return data.replace(b"\r\n", b"\n")
def sha256_hex(data: bytes) -> str:
return hashlib.sha256(canonical_bytes(data)).hexdigest()
base = os.environ["REGISTRY_BASE"]
version = os.environ["PINNED_VERSION"]
root = pathlib.Path(os.environ["VENDORED_ROOT"])
with urllib.request.urlopen(f"{base}/index.json", timeout=20) as response:
index = json.load(response)
if version not in index.get("releases", []):
raise SystemExit(f"published registry is missing release {version}")
with urllib.request.urlopen(f"{base}/releases/v{version}/manifest.json", timeout=20) as response:
manifest = json.load(response)
for entry in manifest["schemas"]:
local = (root / entry["path"]).read_bytes()
if sha256_hex(local) != entry["sha256"]:
raise SystemExit(f"vendored digest drift: {entry['path']}")
with urllib.request.urlopen(f"{base}/releases/v{version}/{entry['path']}", timeout=20) as response:
published = response.read()
if sha256_hex(published) != entry["sha256"]:
raise SystemExit(f"published digest drift: {entry['path']}")
if canonical_bytes(published) != canonical_bytes(local):
raise SystemExit(f"published content drift: {entry['path']}")