Skip to content

Commit

Permalink
refactor jsonld validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed May 12, 2024
1 parent 8e8a8f4 commit 866224d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 36 deletions.
44 changes: 12 additions & 32 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,27 @@ name: validate jsonld
on:
push:
branches:
- master
- main
- dev
pull_request:
branches: '*'

jobs:
build:
runs-on: ubuntu-latest

validate:
if: github.repository_owner == 'INCF'

# Steps represent a sequence of tasks that will be executed as part of the job
runs-on: ubuntu-latest
steps:
- name: Setup Node
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "12.x"

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

# Checks that our JSON are valid
- name: Check for syntax errors
run: |
npm install -g jsonlint
grep -r "@context" schemas | cut -d: -f1 | xargs -I fname jsonlint -q fname
# Checks that the schemas are valid
- name: Set up Python
node-version: 20.x
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install reproschema requests_cache
- name: Test with pyshacl
python-version: 3.12
- name: Install dependencies
run: |
reproschema -l DEBUG validate schemas/artemis/protocols
reproschema -l DEBUG validate schemas/artemis/activities
reproschema -l DEBUG validate schemas/artemis/artemis_schema.jsonld
python -m pip install --upgrade pip setuptools
pip install reproschema
- name: validate
run: make validate
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ repos:
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-json
- id: check-added-large-files

- repo: https://github.com/psf/black
Expand Down
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.PHONY:


INPUT_DIR = $(inputs/tsv)

ARTEMIS_TSV = $(wildcard inputs/tsv/*.tsv)
Expand All @@ -16,6 +13,21 @@ download:
convert: download
python convert_table/src/convert.py


clean_artemis:
rm -rf $(ARTEMIS_TSV)

validate: validate_syntax validate_schema

package.json:
npm install `cat npm-requirements.txt`

# Validate jsonld
validate_syntax: package.json
grep -r "@context" response_options | cut -d: -f1 | xargs -I fname jsonlint -q fname
grep -r "@context" schemas | cut -d: -f1 | xargs -I fname jsonlint -q fname

# you will need to install reproschema-py to run this one ( pip install reproschema )
validate_schema:
reproschema -l DEBUG validate artemis_schema/schemas/artemis/activities
reproschema -l DEBUG validate artemis_schema/schemas/artemis/protocols
reproschema -l DEBUG validate artemis_schema/schemas/artemis/artemis_schema.jsonld

0 comments on commit 866224d

Please sign in to comment.