Skip to content

Commit

Permalink
json validate github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanhowell5195 committed Jun 1, 2024
1 parent b1eda54 commit b3c7037
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 0 deletions.
184 changes: 184 additions & 0 deletions .github/schema/fonts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"id": { "type": "string", "const": "minecraft-ten" },
"variants": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
"name": { "type": "string" },
"description": { "type": "string" },
"author": { "type": "string" },
"height": { "type": "integer" },
"border": { "type": "integer" },
"faces": {
"type": "array",
"items": {
"oneOf": [
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": { "type": "integer" }
},
{
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": { "type": "integer" }
}
]
}
},
"ends": {
"type": "array",
"items": {
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": { "type": "integer" }
}
},
"terminatorSpace": { "type": "boolean" },
"forcedTerminators": { "type": "boolean" },
"autoBorder": { "type": "boolean" },
"borderless": { "type": "boolean" },
"overlay": { "type": "boolean" },
"preview": { "type": "string" },
"example": {
"type": "array",
"items": { "type": "string" },
"minItems": 2,
"maxItems": 2
},
"flat": { "type": "boolean" }
},
"required": ["id"],
"additionalProperties": false
}
}
},
"required": ["id"],
"additionalProperties": true
},
{
"type": "object",
"properties": {
"id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
"name": { "type": "string" },
"description": { "type": "string" },
"author": { "type": "string" },
"height": { "type": "integer" },
"border": { "type": "integer" },
"faces": {
"type": "array",
"items": {
"oneOf": [
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": { "type": "integer" }
},
{
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": { "type": "integer" }
}
]
}
},
"ends": {
"type": "array",
"items": {
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": { "type": "integer" }
}
},
"terminatorSpace": { "type": "boolean" },
"forcedTerminators": { "type": "boolean" },
"autoBorder": { "type": "boolean" },
"borderless": { "type": "boolean" },
"overlay": { "type": "boolean" },
"preview": { "type": "string" },
"example": {
"type": "array",
"items": { "type": "string" },
"minItems": 2,
"maxItems": 2
},
"flat": { "type": "boolean" },
"variants": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
"name": { "type": "string" },
"description": { "type": "string" },
"author": { "type": "string" },
"height": { "type": "integer" },
"border": { "type": "integer" },
"faces": {
"type": "array",
"items": {
"oneOf": [
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": { "type": "integer" }
},
{
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": { "type": "integer" }
}
]
}
},
"ends": {
"type": "array",
"items": {
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": { "type": "integer" }
}
},
"terminatorSpace": { "type": "boolean" },
"forcedTerminators": { "type": "boolean" },
"autoBorder": { "type": "boolean" },
"borderless": { "type": "boolean" },
"overlay": { "type": "boolean" },
"preview": { "type": "string" },
"example": {
"type": "array",
"items": { "type": "string" },
"minItems": 2,
"maxItems": 2
},
"flat": { "type": "boolean" }
},
"required": ["id"],
"additionalProperties": false
}
}
},
"required": ["id", "author", "height", "border", "faces", "ends"],
"additionalProperties": false
}
]
}
}
49 changes: 49 additions & 0 deletions .github/schema/textures.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"textures": {
"type": "object",
"patternProperties": {
"^[a-z0-9_]+$": {
"type": "object",
"properties": {
"category": { "type": "string" },
"name": { "type": "string" },
"author": { "type": "string" },
"variants": {
"type": "object",
"patternProperties": {
"^[a-z0-9_]+$": {
"type": "object",
"properties": {
"name": { "type": "string" },
"author": { "type": "string" }
},
"additionalProperties": false
}
}
}
},
"required": ["author"],
"additionalProperties": false
}
}
},
"overlays": {
"type": "object",
"patternProperties": {
"^[a-z0-9_]+$": {
"type": "object",
"properties": {
"name": { "type": "string" },
"author": { "type": "string" }
},
"required": ["author"],
"additionalProperties": false
}
}
}
},
"additionalProperties": false
}
30 changes: 30 additions & 0 deletions .github/schema/tileables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"patternProperties": {
"^[a-z0-9_]+$": {
"type": "object",
"properties": {
"category": { "type": "string" },
"name": { "type": "string" },
"author": { "type": "string" },
"path": { "type": "string" },
"variants": {
"type": "object",
"patternProperties": {
"^[a-z0-9_]+$": {
"type": "object",
"properties": {
"name": { "type": "string" },
"author": { "type": "string" }
},
"additionalProperties": false
}
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
26 changes: 26 additions & 0 deletions .github/workflows/json_validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: JSON Validator
on: [push, pull_request]

jobs:
verify-json-validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Validate textures.json
uses: docker://orrosenblatt/validate-json-action:latest
env:
INPUT_SCHEMA: .github/schema/textures.json
INPUT_JSONS: fonts/*/textures.json

- name: Validate fonts.json
uses: docker://orrosenblatt/validate-json-action:latest
env:
INPUT_SCHEMA: .github/schema/fonts.json
INPUT_JSONS: fonts.json

- name: Validate tileables.json
uses: docker://orrosenblatt/validate-json-action:latest
env:
INPUT_SCHEMA: .github/schema/tileables.json
INPUT_JSONS: tileables.json

0 comments on commit b3c7037

Please sign in to comment.