From 4b4db9cc402c3a37067eadd8b38114ecd424c992 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Tue, 29 Jul 2025 16:14:55 +0200 Subject: [PATCH 1/5] basic tool for validating schemas against meta schemas --- test_schemas.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 test_schemas.py diff --git a/test_schemas.py b/test_schemas.py new file mode 100755 index 00000000..e1474139 --- /dev/null +++ b/test_schemas.py @@ -0,0 +1,21 @@ +#!/usr/bin/env -S uv run --script +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "jsonschema", +# ] +# /// + +import pathlib +import json + +from jsonschema.validators import validator_for + +prefix = pathlib.Path(__file__).parent.resolve() / "stackinator/schema" + +if __name__ == "__main__": + for schema_filepath in prefix.iterdir(): + print(f"checking {schema_filepath}") + schema = json.load(open(schema_filepath)) + validator = validator_for(schema) + validator.check_schema(schema) From b0de44a9e6e9d9efe6d2254e8bfb1b4792826614 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Tue, 29 Jul 2025 17:04:23 +0200 Subject: [PATCH 2/5] add it to CI: just a placeholder, not sure I have the rights --- .github/workflows/main.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 8bd38da5..45b3b678 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -10,6 +10,9 @@ jobs: - name: Install uv run: | curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Validate Schemas + run: | + ./test_schemas.py - name: Generic Unittests run: | ./test_stackinator.py From 50fc057d4186489db8dc3d9c6d060374dcdb346a Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Thu, 31 Jul 2025 08:39:30 +0200 Subject: [PATCH 3/5] switch to check-jsonschema --- .github/workflows/main.yaml | 11 +++++++---- test_schemas.py | 21 --------------------- 2 files changed, 7 insertions(+), 25 deletions(-) delete mode 100755 test_schemas.py diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 45b3b678..d5674877 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -7,12 +7,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Install uv - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install Tools + uses: threeal/pipx-install-action@v1.0.0 + with: + packages: >- + uv + check-jsonschema - name: Validate Schemas run: | - ./test_schemas.py + find stackinator/schema -type f -name "*.json" -print -exec check-jsonschema --check-metaschema {} \; - name: Generic Unittests run: | ./test_stackinator.py diff --git a/test_schemas.py b/test_schemas.py deleted file mode 100755 index e1474139..00000000 --- a/test_schemas.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env -S uv run --script -# /// script -# requires-python = ">=3.12" -# dependencies = [ -# "jsonschema", -# ] -# /// - -import pathlib -import json - -from jsonschema.validators import validator_for - -prefix = pathlib.Path(__file__).parent.resolve() / "stackinator/schema" - -if __name__ == "__main__": - for schema_filepath in prefix.iterdir(): - print(f"checking {schema_filepath}") - schema = json.load(open(schema_filepath)) - validator = validator_for(schema) - validator.check_schema(schema) From dad2cdf8a8c733fdc7ff354b49079b3d78d0bb1d Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Thu, 31 Jul 2025 09:00:38 +0200 Subject: [PATCH 4/5] make it fail when at least one schema is not valid --- .github/workflows/main.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d5674877..9dd10390 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -15,7 +15,13 @@ jobs: check-jsonschema - name: Validate Schemas run: | - find stackinator/schema -type f -name "*.json" -print -exec check-jsonschema --check-metaschema {} \; + errors=0 + for schema in `find stackinator/schema -type f -name "*.json"`; do + echo $schema + check-jsonschema --check-metaschema $schema + errors=$(($errors + $?)) + done + exit $errors - name: Generic Unittests run: | ./test_stackinator.py From 0a10a1ff9ab96299fe90b11e20e72a0fcccad527 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Mon, 11 Aug 2025 16:33:57 +0200 Subject: [PATCH 5/5] no need to use pipx, just use uvx --- .github/workflows/main.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 9dd10390..002e57bd 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -7,18 +7,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Install Tools - uses: threeal/pipx-install-action@v1.0.0 - with: - packages: >- - uv - check-jsonschema + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh - name: Validate Schemas run: | errors=0 for schema in `find stackinator/schema -type f -name "*.json"`; do echo $schema - check-jsonschema --check-metaschema $schema + uvx check-jsonschema --check-metaschema $schema errors=$(($errors + $?)) done exit $errors