From 101f9c85242212c24a1053164bd80aea8387fe95 Mon Sep 17 00:00:00 2001 From: Logan V Date: Thu, 26 Sep 2024 14:39:47 +0000 Subject: [PATCH] Replace travis --- .github/workflows/validate-schema.yml | 17 +++++++++ .travis.yml | 12 ------ schema.json | 55 ++++++++++++++++++++------- 3 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/validate-schema.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/validate-schema.yml b/.github/workflows/validate-schema.yml new file mode 100644 index 0000000..b5c268e --- /dev/null +++ b/.github/workflows/validate-schema.yml @@ -0,0 +1,17 @@ +on: [push] +jobs: + validate-targets: + name: Validate smokeping targets + runs-on: ubuntu-24.04 + steps: + - name: checkout self/this + uses: actions/checkout@v4 + with: + fetch-depth: 0 + path: self + - name: Install jsonschema + run: | + sudo apt-get install -y python3-jsonschema + - name: validate json + run: | + find targets -type f -print0 | xargs -0 -n1 jsonschema schema.json -i \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 773693e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -dist: bionic -addons: - apt: - packages: - - python3-jsonschema - -script: - - find targets -type f -print0 | xargs -0 -n1 jsonschema schema.json -i - -notifications: - email: false diff --git a/schema.json b/schema.json index 0ba831a..0310263 100644 --- a/schema.json +++ b/schema.json @@ -2,21 +2,48 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "array", "items": { - "type": "object", - "required": [ - "name", - "hostname" - ], - "properties": { - "name": { - "type": "string", - "pattern": "^[-_0-9a-zA-Z]+$" + "anyOf": [ + { "$ref": "#/$defs/target" }, + { "$ref": "#/$defs/group" } + ] + }, + "$defs": { + "target": { + "type": "object", + "required": [ + "name", + "hostname" + ], + "properties": { + "name": { + "type": "string", + "pattern": "^[-_0-9a-zA-Z]+$" + }, + "probe": { "type": "string" }, + "menu": { "type": "string" }, + "title": { "type": "string" }, + "hostname": { "type": "string" } }, - "probe": { "type": "string" }, - "menu": { "type": "string" }, - "title": { "type": "string" }, - "hostname": { "type": "string" } + "additionalProperties": false }, - "additionalProperties": false + "group": { + "type": "object", + "required": [ + "name", + "targets" + ], + "properties": { + "name": { + "type": "string", + "pattern": "^[-_0-9a-zA-Z]+$" + }, + "menu": { "type": "string" }, + "targets": { + "type": "array", + "items": { "$ref": "#/$defs/target" } + } + }, + "additionalProperties": false + } } }