Reorganization of SDCs #107
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 | |
| pull_request: | |
| branches: | |
| - main | |
| #on: | |
| # workflow_run: | |
| # workflows: [MAKE] | |
| # branches: [main] | |
| # types: | |
| # - completed | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| 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.owl | |
| echo '<?xml version="1.0" encoding="UTF-8"?> <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 | |
| cat 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" | |
| echo " reasoning" | |
| ## we have to separate the commands, because robot seems not to do reasoning completely on multiple inputs | |
| java -jar robot.jar --catalog catalog-v001.xml merge --input merged-pmdco.owl --input "$DATAFILE" remove --select imports --output merged2.ttl | |
| java -jar robot.jar reason --input merged2.ttl --reasoner hermit --axiom-generators "SubClass EquivalentClass DataPropertyCharacteristic EquivalentDataProperties SubDataProperty ClassAssertion PropertyAssertion EquivalentObjectProperty InverseObjectProperties SubObjectProperty ObjectPropertyRange ObjectPropertyDomain" --output shape-data-reasoned.ttl | |
| echo " testing" | |
| if [[ -f $SHAPEFILE ]]; then | |
| python3 -m pyshacl -s "$SHAPEFILE" shape-data-reasoned.ttl | |
| else | |
| # just applying autoshapes on example data | |
| echo " skippping, shapefile not found" | |
| fi | |
| 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.owl | sort -u | grep -Fvf - ids2.txt | grep -v "example.org" > 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:" | |
| cat missing.txt | |
| exit 1 | |
| fi | |
| fi | |
| fi | |
| done |