-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (49 loc) · 1.71 KB
/
validate.yml
File metadata and controls
59 lines (49 loc) · 1.71 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
51
52
53
54
55
56
57
58
59
name: Validate Capabilities
on:
pull_request:
paths:
- "capabilities/**/pixi.toml"
- "spec/capability.schema.json"
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install jsonschema
run: pip install jsonschema==4.*
- name: Validate capabilities
run: |
python - <<'EOF'
import sys
import tomllib
import json
import pathlib
import jsonschema
schema_path = pathlib.Path("spec/capability.schema.json")
schema = json.loads(schema_path.read_text())
manifests = sorted(pathlib.Path("capabilities").glob("*/pixi.toml"))
if not manifests:
print("No capabilities found to validate.")
sys.exit(0)
errors = []
for manifest in manifests:
print(f"Validating {manifest} ...", end=" ")
data = tomllib.loads(manifest.read_text())
try:
jsonschema.validate(instance=data, schema=schema)
print("OK")
except jsonschema.ValidationError as e:
print("FAILED")
errors.append(f"{manifest}: {e.message} (path: {' -> '.join(str(p) for p in e.absolute_path)})")
if errors:
print("\nValidation errors:")
for err in errors:
print(f" - {err}")
sys.exit(1)
print(f"\nAll {len(manifests)} capability manifest(s) are valid.")
EOF