diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 5dd0e34..6ca0e29 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -19,4 +19,16 @@ jobs: uses: docker://avtodev/markdown-lint:v1 with: args: '**/*.md' - config: .markdownlint.yaml \ No newline at end of file + config: .markdownlint.yaml + validate-json: + name: Validate configuration files + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Validate gunpla configs + uses: cardinalby/schema-validator-action@v3 + with: + file: 'src/config/*.json' +# schema: 'src/config/gundam_led_config.schema.json' diff --git a/gundam_led_config.schema.json b/gundam_led_config.schema.json new file mode 100644 index 0000000..88467a1 --- /dev/null +++ b/gundam_led_config.schema.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "GundamLEDConfig", + "type": "object", + "required": ["name", "leds", "lightshow"], + "properties": { + "name": { + "type": "string", + "description": "The model name of the Gundam unit." + }, + "leds": { + "type": "array", + "items": { + "type": "object", + "required": ["name", "pin"], + "properties": { + "name": { "type": "string" }, + "pin": { "type": "integer", "minimum": 0, "maximum": 22 }, + "color": { "type": "string" }, + "disabled": { "type": "boolean", "default": false } + } + } + }, + "lightshow": { + "type": "array", + "items": { + "type": "object", + "required": ["name", "path", "method"], + "properties": { + "name": { "type": "string" }, + "path": { "type": "string" }, + "method": { "type": "string" } + } + } + } + } +} \ No newline at end of file diff --git a/src/config/generic_gundam.json b/src/config/generic_gundam.json index 43ec352..d986f02 100644 --- a/src/config/generic_gundam.json +++ b/src/config/generic_gundam.json @@ -1,4 +1,6 @@ { + "$schema": "gundam_led_config.schema.json", + "name": "gunpla", "leds": [ {"name": "head", "pin": 0, "color": "green"}, @@ -11,5 +13,7 @@ {"name": "weapon2", "pin": 7, "color": "red"}, {"name": "weapon2_camera", "pin": 8, "color": "green"}, {"name": "vernier", "pin": 10, "color": "blue"} + ], + "lightshow": [ ] } \ No newline at end of file diff --git a/src/config/nu_gundam.json b/src/config/nu_gundam.json index 44b6b4d..8b8093d 100644 --- a/src/config/nu_gundam.json +++ b/src/config/nu_gundam.json @@ -1,4 +1,5 @@ { + "$schema": "gundam_led_config.schema.json", "name": "RX-93 Nu Gundam", "leds": [ { @@ -41,12 +42,6 @@ "name": "fin_funnel_6", "pin": 7, "color": "white" - }, - { - "name": "fakething", - "pin": 45, - "color": "white", - "disabled": true } ], "lightshow": [ diff --git a/src/config/unicorn_banshee.json b/src/config/unicorn_banshee.json index d1a675c..b4e17d3 100644 --- a/src/config/unicorn_banshee.json +++ b/src/config/unicorn_banshee.json @@ -1,4 +1,5 @@ { + "$schema": "gundam_led_config.schema.json", "name": "RX-0 Unicorn Banshee", "leds": [ { @@ -67,11 +68,6 @@ "pin": 6, "color": "orange" }, - { - "name": "l_weapon", - "pin": 22, - "color": "orange" - }, { "name": "head", "pin": 7, @@ -79,7 +75,7 @@ }, { "name": "head_camera", - "pin": 23, + "pin": 22, "color": "green" } ],