diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..240eed7 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,27 @@ +name: Test Schemas + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python runtime + uses: actions/setup-python@v4 + with: + python-version: 3.10.2 + + - name: Build and test + run: | + pip install -r requirements.txt + make clean + make build diff --git a/docs/guides/general-structure.md b/docs/guides/general-structure.md index fc35425..560b8a7 100644 --- a/docs/guides/general-structure.md +++ b/docs/guides/general-structure.md @@ -44,7 +44,7 @@ From here, the most relevant files and folders are: [Google Takeout]: https://takeout.google.com/settings/takeout -[Raw Location History Data]: raw_location.md -[Semantic Location History Data]: semantic_location.md +[Raw Location History Data]: raw-location.md +[Semantic Location History Data]: semantic-location.md [Records.json]: ../reference/records.md [Settings.json]: ../reference/settings.md diff --git a/docs/guides/raw-location.md b/docs/guides/raw-location.md index 22730a0..6076b67 100644 --- a/docs/guides/raw-location.md +++ b/docs/guides/raw-location.md @@ -39,7 +39,7 @@ From this, the most essential fields are: For more information on the other possible fields see the full [format definition][Location Record]. -[General Structure]: general_structure.md +[General Structure]: general-structure.md [Location Record]: ../reference/records.md#location-record [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 [UTC]: https://en.wikipedia.org/wiki/Coordinated_Universal_Time diff --git a/requirements.txt b/requirements.txt index fc6883b..57ef8df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,16 @@ attrs==21.4.0 -certifi==2022.12.7 +certifi==2023.7.22 charset-normalizer==2.0.12 click==8.1.2 colorama==0.4.6 commonmark==0.9.1 ghp-import==2.0.2 gitdb==4.0.9 -GitPython==3.1.31 +GitPython==3.1.41 hypothesis==6.45.0 idna==3.4 importlib-metadata==4.11.3 -Jinja2==3.0.3 +Jinja2==3.1.3 json-source-map==1.0.1 Markdown==3.3.6 MarkupSafe==2.1.1 @@ -35,6 +35,6 @@ smmap==5.0.0 sortedcontainers==2.4.0 tabulate==0.8.9 termcolor==1.1.0 -urllib3==1.26.15 +urllib3==1.26.18 watchdog==2.1.7 zipp==3.8.0 diff --git a/tools/jsonschema_to_md/__main__.py b/tools/jsonschema_to_md/__main__.py index 94d8d0a..ae0126a 100644 --- a/tools/jsonschema_to_md/__main__.py +++ b/tools/jsonschema_to_md/__main__.py @@ -38,9 +38,12 @@ def main(): JSONSchemaRenderer(logger=None).render_md(inp, out, title=title) except (JSONSchemaError, ValidationError) as e: logger.error(e) + return 1 except Exception as e: logger.exception(e) - + return 1 + else: + return 0 if __name__ == "__main__": - main() + raise SystemExit(main()) diff --git a/tools/jsonschema_to_md/schema_to_md.py b/tools/jsonschema_to_md/schema_to_md.py index a9604f0..55d9085 100644 --- a/tools/jsonschema_to_md/schema_to_md.py +++ b/tools/jsonschema_to_md/schema_to_md.py @@ -32,9 +32,7 @@ def __init__(self, logger=None): logging.basicConfig(level=logging.NOTSET, format="%(message)s", datefmt="[%X]") self.logger = logging.getLogger(__name__) - def _validate_schema(self, schema): - required_fields = ["type", "title", "description"] - + def _validate_schema(self, schema, required_fields=["type", "title", "description"]): for field in required_fields: if getattr(schema, field) is None: raise ValidationError(field, schema) @@ -42,10 +40,11 @@ def _validate_schema(self, schema): if schema.type == "array": if not schema.item_schema: raise ValidationError("items", schema) - - for field in required_fields: - if getattr(schema.item_schema, field) is None: - raise ValidationError(field, schema.item_schema) + + if schema.item_schema.type == "object": + self._validate_schema(schema.item_schema) + else: + self._validate_schema(schema.item_schema, required_fields=["type"]) def _example_text(self, example, simple=False): def json_text(d, simple):