Skip to content

Hotfix: Schema, Example, and Context Fixes #41

Hotfix: Schema, Example, and Context Fixes

Hotfix: Schema, Example, and Context Fixes #41

name: Validate Shapes
on:
push:
branches:
- main
- shapes-and-schemas-subtask
pull_request:
branches:
- main
- shapes-and-schemas-subtask
jobs:
validate-shapes:
runs-on: ubuntu-latest
strategy:
matrix:
folders:
- catalog/message
- negotiation/message
- transfer/message
steps:
- uses: actions/checkout@v3
name: Checkout
- name: Install SHACL Validator
run: |
sudo pipx install pyshacl
- name: Validate Shapes
run: |
for folder in ${{ matrix.folders }}
do
for json_file in $folder/example/*.json
do
_base_filename=$(basename "$json_file" .json)
# Handle "_initial" files differently
if [[ "$_base_filename" =~ _initial$ ]]; then
_base_filename=${_base_filename%_initial} # Remove "_initial" suffix
fi
# Use dcat-shapes.ttl for catalog.json
if [[ "$json_file" == "catalog/message/example/catalog.json" ]]; then
shape_file="catalog/message/shape/dcat-shapes.ttl"
# Use contract-agreement-message-shape.ttl for specific file
elif [[ "$json_file" == "negotiation/message/example/contract.agreement.message.http.transfer.json" ]]; then
shape_file="negotiation/message/shape/contract-agreement-message-shape.ttl"
else
shape_file="$folder/shape/${_base_filename}-shape.ttl"
fi
if [[ -f "$shape_file" ]]; then
echo "Validating $json_file against $shape_file"
pyshacl -df json-ld -sf turtle -s $shape_file $json_file
else
echo "WARNING: Shape file not found for $json_file"
fi
done
done