Skip to content

Commit

Permalink
add another check that validates that the context for jsonld
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Huber <[email protected]>
  • Loading branch information
maxhbr authored and goneall committed Nov 7, 2023
1 parent 11e180c commit 3333fd8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .github/workflows/spec-parser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ jobs:
--out-dir /tmp/spec-parser.out \
../model
- name: validate that context is valid
run: |
python3 -m pip install rdflib
python3 ./.github/workflows/test_context.py /tmp/spec-parser.out/context.json
- uses: actions/upload-artifact@v3
with:
name: model.ttl
Expand Down Expand Up @@ -78,11 +83,14 @@ jobs:
run: |
git fetch
git checkout gh-pages
rm -rf /auto-generated/
cp /tmp/spec-parser.out/model.ttl .
cp /tmp/spec-parser.out/model.jsonld .
cp /tmp/spec-parser.out/context.json .
rm -rf /auto-generated/
cp -r /tmp/auto-generated/ .
if [ -n "$(git status -s -- "auto-generated/" "*.ttl" "*.jsonld" "*.json")" ]
then
git add model.ttl model.jsonld context.json auto-generated/
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/test_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: 2023 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0

import sys
from rdflib import Graph

def parseString(data: str) -> Graph:
return Graph().parse(data=data, format='json-ld')

def testLocalContext(context_file: str) -> Graph:
data = "{ \"@context\": [ \"" + context_file + "\" ], \"@graph\": [ ] }"
parseString(data)


if __name__ == '__main__':
# run testLocalContext with first argument as context file
testLocalContext(sys.argv[1])

0 comments on commit 3333fd8

Please sign in to comment.