-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
011d224
commit 733e1e3
Showing
9 changed files
with
237 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# XML & JSON Linters + fuse.py builds | ||
|
||
name: Build simulacrum | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 demjson3 jsonschema | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi | ||
- name: Lint Python with flake8 | ||
# check if bloodhound, fuse & qa are ok | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
# TODO: - name: Lint mrvn XML with xmllint | ||
# # mrvn folder; generated by snake-biscuits/bsp_tool_examples/fgd2ent.py via bloodhound.py | ||
# run: | | ||
# # for .xml filename in mrvn subfolder | ||
# xmllint filename | ||
# TODO: - name: Lint pilot JSON with jsonlint (python demjson3) | ||
# run: | | ||
# # for .json filename in pilot subfolder | ||
# # AND for .json filename in choiceType sub-subfolders | ||
# jsonlint filename | ||
# TODO: validate schema (tests/test_quality.py for local testing?) | ||
- name: Test with pytest | ||
run: | | ||
pytest -vv | ||
# TODO: Lint simulactum .ent | ||
# TODO: Export simulacrum artifact | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
jsonschema | ||
pytest | ||
xmlschema |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"title": "MRVN-radiant Entity Definition", | ||
"description": "an entity defintion to be amended in a .ent file", | ||
"type": "object", | ||
"properties": { | ||
"Contributors": { | ||
"description": "List of people that contributed to this definition", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
}, | ||
"Block": { | ||
"description": "Entity block (mrvn/game/<Block>.xml) this definition overrides", | ||
"type": "string", | ||
"pattern": "ENTITIES(_(env|fx|script|spawn|snd))?" | ||
}, | ||
"Entity": { | ||
"description": "Entity classname & json filename (TODO: editorclass)", | ||
"type": "string", | ||
"pattern": "[a-z]*(_[a-z])*" | ||
}, | ||
"Type": { | ||
"description": "Entity type (group for brush entities)", | ||
"type": "string", | ||
"pattern": "point|group" | ||
}, | ||
"Description": { | ||
"description": "One-line descrition", | ||
"type": "string" | ||
}, | ||
"Keys": { | ||
"description": "List of entity keys", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"keyname": { | ||
"description": "INDEX: Name of key (as it appears in bsp entity data) to override", | ||
"type": "string" | ||
}, | ||
"type": { | ||
"description": "MRVN-radiant type to use (affects editor preview & interface widget)", | ||
"type": "string" | ||
}, | ||
"name": { | ||
"description": "Key name displayed in MRVN-radiant", | ||
"type": "string" | ||
}, | ||
"default": { | ||
"description": "Default value", | ||
"type": "string" | ||
}, | ||
"description": { | ||
"description": "Description of key use & default behaviour", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ "keyname" ] | ||
}, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
}, | ||
"SpawnFlags": { | ||
"description": "List of entity keys", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"bit": { | ||
"description": "INDEX: bit to override", | ||
"value": "integer" | ||
}, | ||
"name": { | ||
"description": "Spawnflag name displayed in MRVN-radiant", | ||
"type": "string" | ||
}, | ||
"default": { | ||
"description": "Default value", | ||
"type": "string" | ||
}, | ||
"description": { | ||
"description": "Description of spawnflag use & default behaviour", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ "bit" ] | ||
} | ||
}, | ||
"Notes": { | ||
"description": "Detailed general description & notes", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
}, | ||
"required": [ "Contributors", "Block", "Entity" ] | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import fnmatch | ||
import json | ||
import os | ||
|
||
import jsonschema | ||
import pytest | ||
|
||
|
||
games = tuple(filter(os.path.isdir, os.listdir("mrvn"))) | ||
|
||
entity_schema = json.load("schema/entity.json") | ||
entity_json = [os.path.join("pilot", g, j) for g in games | ||
for j in fnmatch.filter(os.listdir(f"pilot/{g}"), "*.json")] | ||
|
||
choiceType_schema = json.load("schema/choiceType.json") | ||
choiceType_json = list() | ||
for game_dir in games: | ||
search_dir = os.path.join("pilot", game_dir, "choiceTypes") | ||
if not os.path.exists(search_dir): | ||
continue | ||
for choiceType in fnmatch.filter(os.listdir(search_dir), "*.json"): | ||
choiceType_json.append() | ||
|
||
|
||
@pytest.mark.parametrize("json_filename", entity_json) | ||
def validate_entity(json_filename: str): | ||
entity = json.load(json_filename) | ||
jsonschema.validate(entity, schema=entity_schema) | ||
# TODO: dynamic type checking | ||
# -- list of valid key types for radiant | ||
# -- add choiceType lists from .xml & .json | ||
|
||
|
||
@pytest.mark.parametrize("json_filename", choiceType_json) | ||
def validate_choiceType(json_filename: str): | ||
choiceType = json.load(json_filename) | ||
jsonschema.validate(choiceType, schema=choiceType_schema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import fnmatch | ||
import os | ||
|
||
import pytest | ||
import xmlschema | ||
|
||
|
||
ent_schema = xmlschema.XMLSchema("schema/entity_definitions.xsd") | ||
|
||
games = tuple(filter(os.path.isdir, os.listdir("mrvn"))) | ||
|
||
mrvn_xml = [os.path.join("mrvn", g, x) for g in games | ||
for x in fnmatch.filter(os.listdir(f"mrvn/{g}"), "*.xml")] | ||
|
||
simulacrum_ent = [os.path.join("simulacrum", g, e) for g in games | ||
for e in fnmatch.filter(os.listdir(f"simulacrum/{g}"), "*.ent")] | ||
|
||
|
||
@pytest.mark.parametrize("xml_filename", (*mrvn_xml, *simulacrum_ent)) | ||
def validate(xml_filename: str): | ||
raise NotImplementedError() |