diff --git a/.github/workflows/model-checks.yml b/.github/workflows/model-checks.yml index 04eb1c1..cf56c84 100644 --- a/.github/workflows/model-checks.yml +++ b/.github/workflows/model-checks.yml @@ -24,4 +24,4 @@ jobs: - name: Run checks run: | - make check + make check-models diff --git a/.github/workflows/validate-examples.yaml b/.github/workflows/validate-examples.yaml index 710f27e..beaf86c 100644 --- a/.github/workflows/validate-examples.yaml +++ b/.github/workflows/validate-examples.yaml @@ -1,4 +1,4 @@ -name: Validate examples +name: Validate examples and verify unmodified conversion on: push: @@ -24,4 +24,4 @@ jobs: - name: Validate run: | - make validate-examples + make check-validation diff --git a/Makefile b/Makefile index 9286fe6..0be1adc 100644 --- a/Makefile +++ b/Makefile @@ -46,11 +46,11 @@ build/mkdocs-site: build/linkml-docs src/extra-docs/*.md mkdocs build # add additional schemas to lint here -check: \ - check-data-access-schema \ - check-git-provenance-schema \ - check-ontology -check-%: src/linkml/%.yaml +check-models: \ + check-model-data-access-schema \ + check-model-git-provenance-schema \ + check-model-ontology +check-model-%: src/linkml/%.yaml @echo [Check $<] @echo "Run linter" @linkml-lint \ @@ -70,31 +70,52 @@ check-%: src/linkml/%.yaml @echo Generate OWL @${FAILIF_STDERR} gen-owl $< > /dev/null -# add additional schemas to validate examples for here. -# each one needs to provide valid examples at -# src/examples//* and invalid examples at -# src/counter-examples//*. -# -# In particular the valid examples should follow the -# naming schema -.yaml to be -# usable as documentation examples for `gen-doc` -validate-examples: \ - validate-examples-data-access-schema \ - validate-examples-git-provenance-schema -validate-examples-%: - $(MAKE) validate-valid-examples-$* validate-invalid-examples-$* -validate-valid-examples-%: src/linkml/%.yaml src/examples/% - linkml-validate -s $^/* -validate-invalid-examples-%: src/linkml/%.yaml src/counter-examples/% - # loop over all counter-examples, skip the schema file itself - echo "Verify EXPECTED validation failures" - @for ex in $^/*; do \ +check-validation: \ + check-validation-data-access-schema \ + convert-examples-data-access-schema \ + check-validation-git-provenance-schema \ + convert-examples-git-provenance-schema +check-validation-%: + $(MAKE) check-valid-validation-$* check-invalid-validation-$* +check-valid-validation-%: tests/%/validation src/linkml/%.yaml + @for ex in $ $${ex%.yaml}.$${outf}.tmp && \ + mv $${ex%.yaml}.$${outf}.tmp $${ex%.yaml}.$${outf} ; \ + done \ done + @git --no-pager diff -- $^ + @if [ -n "$$(git diff -- $^)" ]; then \ + echo -n 'ERROR: Unexpected modification of example output. ' ; \ + echo 'Inspect and commit changes shown above!' ; \ + exit 22 ; \ + fi + clean: rm -rf build rm -f *-stamp -.PHONY: clean check validate-examples +.PHONY: clean check-models check-examples convert-examples diff --git a/src/examples/data-access-schema/GitAnnexSpecialRemote-webdav.yaml b/src/examples/data-access-schema/GitAnnexSpecialRemote-webdav.yaml deleted file mode 100644 index 1824360..0000000 --- a/src/examples/data-access-schema/GitAnnexSpecialRemote-webdav.yaml +++ /dev/null @@ -1,7 +0,0 @@ -available_via: - - access_method: - metatype: dlco:GitAnnexSpecialRemote - special_remote_type: webdav - has_parameter: - - some - object_id: MD5E-s4--ba1f2511fc30423bdbb183fe33f3dd0f.txt diff --git a/src/examples/data-access-schema/ObjectAvailability-annexwebdav.json b/src/examples/data-access-schema/ObjectAvailability-annexwebdav.json new file mode 100644 index 0000000..f8efe1b --- /dev/null +++ b/src/examples/data-access-schema/ObjectAvailability-annexwebdav.json @@ -0,0 +1,11 @@ +{ + "access_method": { + "metatype": "dlco:GitAnnexSpecialRemote", + "special_remote_type": "webdav", + "has_parameter": [ + "some" + ] + }, + "object_id": "MD5E-s4--ba1f2511fc30423bdbb183fe33f3dd0f.txt", + "@type": "ObjectAvailability" +} diff --git a/src/examples/data-access-schema/ObjectAvailability-annexwebdav.yaml b/src/examples/data-access-schema/ObjectAvailability-annexwebdav.yaml new file mode 100644 index 0000000..26faf59 --- /dev/null +++ b/src/examples/data-access-schema/ObjectAvailability-annexwebdav.yaml @@ -0,0 +1,6 @@ +access_method: + metatype: dlco:GitAnnexSpecialRemote + special_remote_type: webdav + has_parameter: + - some +object_id: MD5E-s4--ba1f2511fc30423bdbb183fe33f3dd0f.txt diff --git a/src/examples/git-provenance-schema/Commit-simple.json b/src/examples/git-provenance-schema/Commit-simple.json new file mode 100644 index 0000000..6055b34 --- /dev/null +++ b/src/examples/git-provenance-schema/Commit-simple.json @@ -0,0 +1,9 @@ +{ + "id": "7726424f50c6e9a70ba31e8d44c5d86fc46170da", + "was_generated_by": { + "was_associated_with": { + "name": "Michael Hanke" + } + }, + "@type": "Commit" +} diff --git a/src/examples/git-provenance-schema/Commit-simple.yaml b/src/examples/git-provenance-schema/Commit-simple.yaml new file mode 100644 index 0000000..e92afcd --- /dev/null +++ b/src/examples/git-provenance-schema/Commit-simple.yaml @@ -0,0 +1,4 @@ +id: 7726424f50c6e9a70ba31e8d44c5d86fc46170da +was_generated_by: + was_associated_with: + name: Michael Hanke diff --git a/src/examples/git-provenance-schema/GitHistory-simple.yaml b/src/examples/git-provenance-schema/GitHistory-simple.yaml deleted file mode 100644 index 873c475..0000000 --- a/src/examples/git-provenance-schema/GitHistory-simple.yaml +++ /dev/null @@ -1,5 +0,0 @@ -commits: - 7726424f50c6e9a70ba31e8d44c5d86fc46170da: - was_generated_by: - was_associated_with: - name: Michael Hanke diff --git a/src/counter-examples/data-access-schema/GitAnnexSpecialRemote-missing_type.yaml b/tests/data-access-schema/validation/GitAnnexSpecialRemote-missing_type.yaml similarity index 100% rename from src/counter-examples/data-access-schema/GitAnnexSpecialRemote-missing_type.yaml rename to tests/data-access-schema/validation/GitAnnexSpecialRemote-missing_type.yaml diff --git a/tests/data-access-schema/validation/annexremote.valid.cfg.yaml b/tests/data-access-schema/validation/annexremote.valid.cfg.yaml new file mode 100644 index 0000000..2f4a565 --- /dev/null +++ b/tests/data-access-schema/validation/annexremote.valid.cfg.yaml @@ -0,0 +1,8 @@ +schema: src/linkml/data-access-schema.yaml +target_class: ObjectAvailability +data_sources: + - src/examples/data-access-schema/ObjectAvailability-annexwebdav.yaml +plugins: + JsonschemaValidationPlugin: + closed: true + RecommendedSlotsPlugin: diff --git a/tests/data-access-schema/validation/annexremote_missing_type.invalid.cfg.yaml b/tests/data-access-schema/validation/annexremote_missing_type.invalid.cfg.yaml new file mode 100644 index 0000000..e91fee9 --- /dev/null +++ b/tests/data-access-schema/validation/annexremote_missing_type.invalid.cfg.yaml @@ -0,0 +1,8 @@ +schema: src/linkml/data-access-schema.yaml +target_class: DataObject +data_sources: + - tests/data-access-schema/validation/GitAnnexSpecialRemote-missing_type.yaml +plugins: + JsonschemaValidationPlugin: + closed: true + RecommendedSlotsPlugin: diff --git a/tests/git-provenance-schema/validation/basic.valid.cfg.yaml b/tests/git-provenance-schema/validation/basic.valid.cfg.yaml new file mode 100644 index 0000000..91970ce --- /dev/null +++ b/tests/git-provenance-schema/validation/basic.valid.cfg.yaml @@ -0,0 +1,9 @@ +schema: src/linkml/git-provenance-schema.yaml +target_class: Commit +data_sources: + - src/examples/git-provenance-schema/Commit-simple.yaml +plugins: + JsonschemaValidationPlugin: + closed: true + include_range_class_descendants: true + RecommendedSlotsPlugin: