-
Notifications
You must be signed in to change notification settings - Fork 46
Update participant configuration json schema #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
464d5de
Update participant configuration json schema
VLukasBecker dd2343a
fixup! config: set JSON as default format for file logging (#386)
VLukasBecker 45aeedc
Update config files and add python and workflow file to validate conf…
VLukasBecker b6a8c57
fixup! Update config files and add python and workflow file to valida…
VLukasBecker 0f96954
fixup! Update config files and add python and workflow file to valida…
VLukasBecker f9fdb83
fixup! Update config files and add python and workflow file to valida…
VLukasBecker 9f4dfb1
fixup! Update config files and add python and workflow file to valida…
VLukasBecker ae8bc0d
fixup! Update config files and add python and workflow file to valida…
VLukasBecker ea854be
fixup! Update config files and add python and workflow file to valida…
VLukasBecker 513311a
fixup! Update config files and add python and workflow file to valida…
VLukasBecker ad574a2
fixup! Update config files and add python and workflow file to valida…
VLukasBecker 892f322
fixup! Update config files and add python and workflow file to valida…
VLukasBecker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: 'Validate Participant Configuration Examples' | ||
| on: | ||
| workflow_call: | ||
|
|
||
| workflow_dispatch: | ||
|
|
||
| push: | ||
| branches: [ 'main' ] | ||
|
|
||
| jobs: | ||
| validate-participant-configs: | ||
| name: Validate participant configuration examples against JSON schema | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| submodules: false | ||
| - name: Install Dependencies | ||
| run: | | ||
| python3 -m pip install --quiet jsonschema pyyaml | ||
| - name: Validate participant configuration examples | ||
| run: | | ||
| python3 ./SilKit/ci/validate_participant_configs.py | ||
| shell: bash | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,4 @@ Logging: | |
| - Level: Error | ||
| Type: Stdout | ||
| Middleware: | ||
| EnableDomainSockets: 'False' | ||
| EnableDomainSockets: false | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # SPDX-FileCopyrightText: 2026 Vector Informatik GmbH | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| """ | ||
| Validate SIL Kit participant configuration example files (JSON/YAML) against | ||
| SilKit/source/config/ParticipantConfiguration.schema.json. | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| import argparse | ||
| import json | ||
| import sys | ||
|
|
||
| import jsonschema | ||
| import yaml | ||
|
|
||
| sys.path.insert(0, str(Path(__file__).resolve().parent)) | ||
| from ci_utils import info, warn, die | ||
|
|
||
| SCRIPT_DIR = Path(__file__).resolve().parent | ||
| REPO_ROOT = SCRIPT_DIR.parents[1] | ||
| SCHEMA_PATH = REPO_ROOT / "SilKit" / "source" / "config" / "ParticipantConfiguration.schema.json" | ||
|
|
||
|
|
||
| def find_config_files(repo_root: Path): | ||
| config_dir = repo_root / "SilKit" / "source" / "config" | ||
|
|
||
| files = [] | ||
| files += sorted(p for p in config_dir.glob("*.json") if p != SCHEMA_PATH) | ||
| files += sorted(config_dir.glob("*.yaml")) | ||
| files += sorted((repo_root / "Demos").rglob("*.silkit.yaml")) | ||
| return files | ||
|
|
||
|
|
||
| def load_config(path: Path): | ||
| with path.open("r", encoding="utf-8") as f: | ||
| if path.suffix == ".json": | ||
| return json.load(f) | ||
| return yaml.safe_load(f) | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser( | ||
| description="Validate SIL Kit participant configuration example files against the JSON schema") | ||
| parser.add_argument( | ||
| "--root", type=Path, default=REPO_ROOT, | ||
| help="Repository root (defaults to the checkout containing this script)") | ||
| args = parser.parse_args() | ||
|
|
||
| schema_path = args.root / "SilKit" / "source" / "config" / "ParticipantConfiguration.schema.json" | ||
| with schema_path.open("r", encoding="utf-8") as f: | ||
| schema = json.load(f) | ||
|
|
||
| validator_cls = jsonschema.validators.validator_for(schema) | ||
| validator_cls.check_schema(schema) | ||
| validator = validator_cls(schema) | ||
|
|
||
| files = find_config_files(args.root) | ||
| if not files: | ||
| die(1, "No participant configuration example files found to validate!") | ||
|
|
||
| info("Validating {} participant configuration file(s) against {}", len(files), schema_path) | ||
|
|
||
| failed = 0 | ||
| for path in files: | ||
| try: | ||
| instance = load_config(path) | ||
| except Exception as ex: | ||
| warn("{}: failed to parse ({})", path, ex) | ||
| failed += 1 | ||
| continue | ||
|
|
||
| errors = sorted(validator.iter_errors(instance), key=lambda e: [str(p) for p in e.absolute_path]) | ||
| if errors: | ||
| failed += 1 | ||
| for error in errors: | ||
| location = "/".join(str(p) for p in error.absolute_path) or "<root>" | ||
| warn("{}: {}: {}", path, location, error.message) | ||
| else: | ||
| info("{}: OK", path) | ||
|
|
||
| if failed: | ||
| die(64, "{} of {} configuration file(s) failed schema validation!", failed, len(files)) | ||
|
|
||
| info("All {} participant configuration file(s) are valid!", len(files)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.