Update shacl.yaml #440
This file contains hidden or 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
| name: shacl validation | |
| on: | |
| push: | |
| branches: | |
| - main | |
| #on: | |
| # workflow_run: | |
| # workflows: [MAKE] | |
| # branches: [main] | |
| # types: | |
| # - completed | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| ref: main | |
| path: main | |
| - name: Validate against SHACL shapes | |
| run: | | |
| pip install pyshacl | |
| curl -L -o robot.jar "https://github.com/ontodev/robot/releases/latest/download/robot.jar" | |
| #java -jar robot.jar --version | |
| # merge the current EDIT version and all components into one ontology file | |
| java -jar robot.jar merge --catalog main/src/ontology/catalog-v001.xml --input main/src/ontology/pmdco-edit.owl --output merged-pmdco.ttl | |
| echo "<?xml version='1.0' encoding='UTF-8'?>\n<catalog xmlns='urn:oasis:names:tc:entity:xmlns:xml:catalog' prefer='public'><uri name='https://w3id.org/pmd/co' uri="merged-pmdco.owl' /></catalog>" > catalog-v001.xml | |
| for DIR in main/patterns/*/ | |
| do | |
| if [[ "$DIR" != "main/patterns/unused/" ]]; then | |
| if [[ "$DIR" != "main/patterns/autoshape/" ]]; then | |
| echo "processing: $DIR" | |
| SHAPEFILE="${DIR}shape.ttl" | |
| DATAFILE="${DIR}shape-data.ttl" | |
| echo "testing shape" | |
| java -jar robot.jar --catalog catalog-v001.xml merge --input merged-pmdco.ttl --input "$DATAFILE" remove --select imports reason --reasoner hermit --axiom-generators "SubClass EquivalentClass DataPropertyCharacteristic EquivalentDataProperties SubDataProperty ClassAssertion PropertyAssertion EquivalentObjectProperty InverseObjectProperties ObjectPropertyCharacteristic SubObjectProperty ObjectPropertyRange ObjectPropertyDomain" --output shape-data-reasoned.ttl | |
| python3 -m pyshacl -s "$SHAPEFILE" shape-data-reasoned.ttl | |
| echo "testing autoshapes" | |
| # test with autoshapes | |
| python3 -m pyshacl -s main/patterns/autoshape/auto-shapes-open.ttl shape-data-reasoned.ttl | |
| echo "testing missing IRIs" | |
| # test that all classes in the a-box are present in PMDco ontology | |
| java -jar robot.jar export --input "$DATAFILE" --header "IRI" --include "classes properties" --export ids.txt | |
| #echo "testing missing IRIs 2" | |
| tail -n +2 ids.txt > ids2.txt | |
| echo "iris in a-box" | |
| cat ids2.txt | |
| #echo "testing missing IRIs 3" | |
| grep -Fof ids2.txt merged-pmdco.ttl | sort -u | grep -Fvf - ids2.txt > missing.txt || : | |
| #echo "testing missing IRIs 4" | |
| echo "missing iris" | |
| cat missing.txt | |
| #echo "testing missing IRIs 5" | |
| if [ -s missing.txt ]; then | |
| echo "Found the listed IRIs in the a-box, but they are not present in PMDco:" | |
| exit 1 | |
| fi | |
| fi | |
| fi | |
| done |