From 866224d2df0bdb53ba9624d437eabfb7b60c897c Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sun, 12 May 2024 18:34:53 +0200 Subject: [PATCH] refactor jsonld validation --- .github/workflows/validate.yml | 44 ++++++++++------------------------ .pre-commit-config.yaml | 1 + Makefile | 20 ++++++++++++---- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index b8d0a53..4c43e3f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -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 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e779a1..e64f251 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/Makefile b/Makefile index c697cbe..6fc9b3f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,3 @@ -.PHONY: - - INPUT_DIR = $(inputs/tsv) ARTEMIS_TSV = $(wildcard inputs/tsv/*.tsv) @@ -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