Update references for capabilities to programs. #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate programs | |
| on: | |
| pull_request: | |
| paths: | |
| - "programs/**/pixi.toml" | |
| - "spec/program.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 programs | |
| run: | | |
| python - <<'EOF' | |
| import sys | |
| import tomllib | |
| import json | |
| import pathlib | |
| import jsonschema | |
| schema_path = pathlib.Path("spec/program.schema.json") | |
| schema = json.loads(schema_path.read_text()) | |
| manifests = sorted(pathlib.Path("programs").glob("*/pixi.toml")) | |
| if not manifests: | |
| print("No programs 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)} program manifest(s) are valid.") | |
| EOF |