mirror of
https://github.com/hacs/default.git
synced 2025-07-21 10:36:42 +00:00
Add JSON schema validation (#2539)
* Add JSON schema validation * fix version * move
This commit is contained in:
27
.github/workflows/lint.yml
vendored
27
.github/workflows/lint.yml
vendored
@ -22,6 +22,31 @@ jobs:
|
||||
- name: Validate
|
||||
run: jq --raw-output . appdaemon blacklist critical integration netdaemon plugin python_script removed template theme
|
||||
|
||||
jsonschema:
|
||||
name: JSON schema
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4.1.1
|
||||
|
||||
- name: Critical
|
||||
uses: cardinalby/schema-validator-action@3.1.1
|
||||
with:
|
||||
file: "critical"
|
||||
schema: "tools/jsonschema/critical.schema.json"
|
||||
|
||||
- name: Repositories
|
||||
uses: cardinalby/schema-validator-action@3.1.1
|
||||
with:
|
||||
file: "appdaemon|blacklist|integration|netdaemon|plugin|python_script|template|theme"
|
||||
schema: "tools/jsonschema/repositories.schema.json"
|
||||
|
||||
- name: Removed
|
||||
uses: cardinalby/schema-validator-action@3.1.1
|
||||
with:
|
||||
file: "removed"
|
||||
schema: "tools/jsonschema/removed.schema.json"
|
||||
|
||||
sorted:
|
||||
name: Sorted
|
||||
runs-on: ubuntu-latest
|
||||
@ -30,4 +55,4 @@ jobs:
|
||||
uses: actions/checkout@v4.1.1
|
||||
|
||||
- name: Check lists
|
||||
run: python3 scripts/is_sorted.py
|
||||
run: python3 scripts/is_sorted.py
|
||||
|
6
.github/workflows/upload-critical.yml
vendored
6
.github/workflows/upload-critical.yml
vendored
@ -20,6 +20,12 @@ jobs:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4.1.1
|
||||
|
||||
- name: Validate with JSON schema
|
||||
uses: cardinalby/schema-validator-action@3.1.1
|
||||
with:
|
||||
file: 'critical'
|
||||
schema: 'tools/jsonschema/critical.schema.json'
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5.0.0
|
||||
id: python
|
||||
|
6
.github/workflows/upload-removed.yml
vendored
6
.github/workflows/upload-removed.yml
vendored
@ -20,6 +20,12 @@ jobs:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4.1.1
|
||||
|
||||
- name: Validate with JSON schema
|
||||
uses: cardinalby/schema-validator-action@3.1.1
|
||||
with:
|
||||
file: 'removed'
|
||||
schema: 'tools/jsonschema/removed.schema.json'
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5.0.0
|
||||
id: python
|
||||
|
26
tools/jsonschema/critical.schema.json
Normal file
26
tools/jsonschema/critical.schema.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Schema for critical repositories",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"repository": {
|
||||
"type": "string",
|
||||
"pattern": "^[\\w\\.-]+\/[\\w\\.-]+$"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"link": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"repository",
|
||||
"reason",
|
||||
"link"
|
||||
]
|
||||
}
|
||||
}
|
27
tools/jsonschema/removed.schema.json
Normal file
27
tools/jsonschema/removed.schema.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Schema for removed repositories",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"link": {
|
||||
"type": "string"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"removal_type": {
|
||||
"type": "string"
|
||||
},
|
||||
"repository": {
|
||||
"type": "string",
|
||||
"pattern": "^[\\w\\.-]+\/[\\w\\.-]+$"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"removal_type",
|
||||
"repository"
|
||||
]
|
||||
}
|
||||
}
|
9
tools/jsonschema/repositories.schema.json
Normal file
9
tools/jsonschema/repositories.schema.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Shema for a repository list",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^[\\w\\.-]+\/[\\w\\.-]+$"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user