From 4bdbec9e3d7f138a2e0f78b3d65d1c77e889acd7 Mon Sep 17 00:00:00 2001 From: Tommy Gatti Date: Mon, 18 Sep 2023 10:52:41 +1000 Subject: [PATCH 1/3] Added models schema (a basic object that contains properties that are all arrays of strings --- containers/models.schema.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 containers/models.schema.json diff --git a/containers/models.schema.json b/containers/models.schema.json new file mode 100644 index 0000000..759ab34 --- /dev/null +++ b/containers/models.schema.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Models", + "description": "A list of ACCESS-NRI Models that are supported", + "type": "object", + "patternProperties": { + "^.*$": { + "type": "array", + "items": { + "type": "string" + } + } + } +} \ No newline at end of file From f17bda08b61c4e1273b54d40da09b46eff1d9512 Mon Sep 17 00:00:00 2001 From: Tommy Gatti Date: Mon, 18 Sep 2023 10:54:13 +1000 Subject: [PATCH 2/3] Added compilers schema (a basic array of name-package-version objects) --- containers/compilers.schema.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 containers/compilers.schema.json diff --git a/containers/compilers.schema.json b/containers/compilers.schema.json new file mode 100644 index 0000000..3d8e198 --- /dev/null +++ b/containers/compilers.schema.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Compilers", + "description": "A list of compilers that are supported", + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "package": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ "name", "package", "version" ], + "additionalProperties": false + } +} \ No newline at end of file From 4a0922d8e925cd64f911595b9f1d5ecb69e05d1d Mon Sep 17 00:00:00 2001 From: Tommy Gatti Date: Mon, 18 Sep 2023 12:32:37 +1000 Subject: [PATCH 3/3] Added build-ci CI for JSON validation --- .github/workflows/json-lint.yml | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/json-lint.yml diff --git a/.github/workflows/json-lint.yml b/.github/workflows/json-lint.yml new file mode 100644 index 0000000..8318e45 --- /dev/null +++ b/.github/workflows/json-lint.yml @@ -0,0 +1,36 @@ +name: Validate JSON files +on: + pull_request: + paths: + - '**.json' +jobs: + setup-validate-json: + name: Setup Validate JSON + runs-on: ubuntu-latest + outputs: + json-to-validate: ${{ steps.get-json.outputs.json }} + steps: + - uses: actions/checkout@v3 + - name: Get all schema + id: get-json + # this command finds all the filenames with the '.schema.json' extension, removes that extension, then turns them into a json array + # an example of this transformation would be: 'compilers.schema.json models.schema.json' -> 'compilers models' -> '["compilers","models"]' + run: echo "json=$(find containers/ -type f -name '*.schema.json' | xargs basename -s .schema.json | jq -Rcn '[inputs]')" >> $GITHUB_OUTPUT + + validate-json: + name: Validate JSON + runs-on: ubuntu-latest + needs: + - setup-validate-json + strategy: + fail-fast: false + matrix: + file: ${{ fromJson(needs.setup-validate-json.outputs.json-to-validate) }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + with: + python-version: '3.10' + - name: Validate files + run: jsonschema -i containers/${{ matrix.file }}.json containers/${{ matrix.file }}.schema.json +