diff --git a/.github/workflows/validate-json-schema.yml b/.github/workflows/validate-json-schema.yml new file mode 100644 index 000000000..d3f9a185f --- /dev/null +++ b/.github/workflows/validate-json-schema.yml @@ -0,0 +1,16 @@ +name: Validate JSON Schema + +on: [push, pull_request] + +jobs: + validate-json: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Validate Toolset JSON files against schema + uses: cardinalby/schema-validator-action@v3 + with: + file: '**/toolset-*.json' + schema: 'schemas/toolset-schema.json' diff --git a/.vscode/settings.json b/.vscode/settings.json index f0ce6b6ac..98a58c65f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -21,5 +21,14 @@ ], "shellcheck.customArgs": [ "-x" - ] + ], + "json.schemas": [ + { + "fileMatch": [ + "**/toolset-*.json" + ], + "url": "./schemas/toolset-schema.json" + } +] + } diff --git a/schemas/toolset-schema.json b/schemas/toolset-schema.json new file mode 100644 index 000000000..79b1bd988 --- /dev/null +++ b/schemas/toolset-schema.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "patternProperties": { + "^.*$": { + "if": { + "type": "object", + "required": [ + "version" + ], + "properties": { + "version": { + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+.*$" + } + } + }, + "then": { + "required": [ + "pinnedReason" + ], + "properties": { + "pinnedDetails": { + "type": "object", + "properties": { + "reason": { + "type": "string" + }, + "link": { + "type": "string" + }, + "review-at": { + "type": "string", + "format": "date" + } + } + } + } + } + } + } +}