Skip to content
---
# This workflow validates the current JSON documents against EGA's JSON schemas
# using EGA's API endpoint (http://biovalidator.ega.ebi.ac.uk/validate) of
# the tool Biovalidator (https://github.com/elixir-europe/biovalidator) and the
# up-to-date EGA JSON schemas
# (https://github.com/EbiEga/ega-metadata-schema/tree/main/schemas).
# The logic of this workflow is:
# - Details: EE-2575
# - Why: Allows us to check two things:
# 1. Whether the current "main" branch of Biovalidator can be deployed as
# a server instance.
# 2. Whether the modified schemas-&-documents (the ones in the branch of
# the PR) are compliant (i.e. would pass validation) against an up to
# date Biovalidator instance.
# - Would block the PR if failed? Requires interpretation depending on the
# step at which it failed.
# - How: (1) Clone current Biovalidator repository; (2) install dependencies
# and project; (3) deploy Biovalidator local server, specifying (-r/--ref)
# the schemas to be used during validation, which would be the ones within
# the branch; (4) execute script .github/scripts/request_validation.py
# specifying the localhost server and branch's JSON documents.
#
# For more information, check:
# https://github.com/EbiEga/ega-metadata-schema/tree/main/docs/gh_workflows
name: |
[REQUIRED] JSON docs validation - Local Biovalidator
(json_validation_deploying_biovalidator.yml)
on:
# Executes on any commit to a PR to the "main" branch
pull_request:
branches: [main]
jobs:
validate-json-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# Full git history
fetch-depth: 0
- name: Clone Biovalidator
# See https://github.com/elixir-europe/biovalidator#installation
# We want to test the "main" branch of the project
run: git clone https://github.com/elixir-europe/biovalidator.git
- name: Install Biovalidator
# We want to test with the latest Node.js version, but if not, we
# could make use of action: https://github.com/actions/setup-node
run: |
cd biovalidator
npm install
# We shouldn't need to audit the issues, but for now it is what it is
# npm audit fix
- name: Start Biovalidator server
# We want to specify the JSON schemas and documents with the new
# changes. Therefore we specify the schemas at deployment level (-r)
run: |
schemas_dir="./schemas"
node biovalidator/src/biovalidator -r "$schemas_dir/*.json" &
# We stop for a few seconds to give the server time
sleep 3
- uses: actions/setup-python@v4
with:
# We'll use the latest version of python from major 3 release
# This bit is needed for running the following python script
python-version: '3.x'
- name: Install dependencies
run: |
pip install --upgrade pip
requirements_f="./.github/scripts/requirements.txt"
if [ -f "$requirements_f" ]; then pip install -r "$requirements_f"; fi
- name: Validate JSON examples
# Validate all JSON documents against their corresponding schemas
# Check:
# github.com/EbiEga/ega-metadata-schema/tree/main/.github/scripts
run: |
json_ex_dir="./examples/json_validation_tests"
# The following URL points to the locally deployed server of
# Biovalidator
url="http://localhost:3020/validate"
python3 ./.github/scripts/request_validation.py "$json_ex_dir" "$url"