Skip to content

Commit

Permalink
added translation file json schema and schema validation in workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyTails committed Nov 29, 2023
1 parent 6b08799 commit 1e31a84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build-system.requires = ["python_version >= 3.11"]
build-system.requires = ["jsonschema >= 4.20", "python_version >= 3.11"]
13 changes: 10 additions & 3 deletions .github/workflows/validate_toml.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
from glob import iglob
from tomllib import load, TOMLDecodeError
import tomllib
from jsonschema import validate
import json

if __name__ == "__main__":
for path in iglob("../../**/*.toml", recursive=True):
with open(path, 'rb') as file:
try:
print(f"Checking {file.name}...")
load(file)
except TOMLDecodeError as e:
data = tomllib.load(file)

if "translations" in path:
with open("../../schemas/translation.schema.json") as schema:
print(f"Checking translation schema for {file.name}...")
validate(data, json.load(schema))
except tomllib.TOMLDecodeError as e:
print(e)

0 comments on commit 1e31a84

Please sign in to comment.