From 035f9108aac2e0a836acb1af7f1668c4093bc63b Mon Sep 17 00:00:00 2001 From: Maxime <52084503+Max-3-7@users.noreply.github.com> Date: Sat, 27 Jan 2024 10:12:44 +0100 Subject: [PATCH] CI to validate json files (#40) * Create schema.json * add workflow * update workflow * fix typo --- .github/workflows/validate-json.yml | 29 +++++++++++++++++++++++++++++ schema_epochs.json | 14 ++++++++++++++ schema_rewards.json | 16 ++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 .github/workflows/validate-json.yml create mode 100644 schema_epochs.json create mode 100644 schema_rewards.json diff --git a/.github/workflows/validate-json.yml b/.github/workflows/validate-json.yml new file mode 100644 index 0000000..0d7bb0d --- /dev/null +++ b/.github/workflows/validate-json.yml @@ -0,0 +1,29 @@ +name: Validate JSON + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + validate: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + + - name: Install AJV CLI + run: npm install -g ajv-cli + + - name: Validate rewards.json + run: ajv validate -s schema_rewards.json -d './rewards.json' --strict=false + + - name: Validate epochs.json + run: ajv validate -s schema_epochs.json -d './epochs.json' --strict=false diff --git a/schema_epochs.json b/schema_epochs.json new file mode 100644 index 0000000..4749d19 --- /dev/null +++ b/schema_epochs.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "array", + "items": { + "type": "object", + "properties": { + "epoch": { "type": "integer", "minimum": 1 }, + "start": { "type": "string", "format": "date-time" }, + "end": { "type": "string", "format": "date-time" } + }, + "required": ["epoch", "start", "end"], + "additionalProperties": false + } +} diff --git a/schema_rewards.json b/schema_rewards.json new file mode 100644 index 0000000..912e9a6 --- /dev/null +++ b/schema_rewards.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "array", + "items": { + "type": "object", + "properties": { + "epoch": { "type": "number" }, + "chain": { "type": "string", "enum": ["Avax", "Arbitrum", "BNB"] }, + "poolId": { "type": "string", "pattern": "^\\S*$" }, + "rewardPerDay": { "type": "number" }, + "rewardToken": { "type": "string", "pattern": "^\\S*$" } + }, + "required": ["epoch", "chain", "poolId", "rewardPerDay", "rewardToken"], + "additionalProperties": false + } +}