From e2b0e04ab5217b0d3c6c3aaa4d272dc092deaf54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20R=C3=B6rtgen?= Date: Wed, 20 Mar 2024 12:17:09 +0100 Subject: [PATCH] 29 shacl (#40) * Test GitHub Action #29 * Test validation of ttl file #29 * Test validation for warnings and errors #29 * Split warning and error validation #29 * Use append redirect operator #29 * Name Jobs for better readability #29 * Try out warning message #29 * Change back to failing instead of warning message #29 See https://github.com/dini-ag-kim/hochschulfaechersystematik/pull/40#issuecomment-2009253275 --- .github/workflows/main.yaml | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/main.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..c07ff21 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,49 @@ +name: Validate TTL Files + +on: [push] + +jobs: + validate-for-warnings: + name: Check for Warnings + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check for Warnings + run: | + curl -s https://raw.githubusercontent.com/skohub-io/shapes/main/scripts/checkForWarning.rq >> checkForWarning.rq + find . -type f -name '*.ttl' | while read file; do + # Adjust the file path to remove the './' part + adjusted_file_path=$(echo "$file" | sed 's|^./||') + echo "Processing $adjusted_file_path with Docker..." + docker run --rm -v "$(pwd)/$adjusted_file_path:/rdf/test.ttl" skohub/jena:4.6.1 shacl validate --shapes https://raw.githubusercontent.com/skohub-io/shapes/main/skohub.shacl.ttl --data /rdf/test.ttl >> result.ttl + validation_result="$(docker run --rm --mount type=bind,source=./checkForWarning.rq,target=/rdf/checkForViolation.rq --mount type=bind,source=./result.ttl,target=/rdf/result.ttl skohub/jena:4.6.1 arq --data /rdf/result.ttl --query /rdf/checkForViolation.rq)" + echo $validation_result + lines=$(echo "$validation_result" | wc -l ) + # Correct validation has 4 lines of output + [[ ${lines} -eq 4 ]] || exit 1 + done + + validate-for-errors: + name: Check for Errors + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check for Errors + run: | + curl -s https://raw.githubusercontent.com/skohub-io/shapes/main/scripts/checkForViolation.rq >> checkForViolation.rq + find . -type f -name '*.ttl' | while read file; do + # Adjust the file path to remove the './' part + adjusted_file_path=$(echo "$file" | sed 's|^./||') + echo "Processing $adjusted_file_path with Docker..." + docker run --rm -v "$(pwd)/$adjusted_file_path:/rdf/test.ttl" skohub/jena:4.6.1 shacl validate --shapes https://raw.githubusercontent.com/skohub-io/shapes/main/skohub.shacl.ttl --data /rdf/test.ttl >> result.ttl + validation_result="$(docker run --rm --mount type=bind,source=./checkForViolation.rq,target=/rdf/checkForViolation.rq --mount type=bind,source=./result.ttl,target=/rdf/result.ttl skohub/jena:4.6.1 arq --data /rdf/result.ttl --query /rdf/checkForViolation.rq)" + echo $validation_result + lines=$(echo "$validation_result" | wc -l ) + # Correct validation has 4 lines of output + [[ ${lines} -eq 4 ]] || exit 1 + done +