JSON Schemas v1.0.0 #92
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# 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: It allows us to know if the changes introduced in the branch are | |
# compliant with the default (main branch) schemas. | |
# - Would block the PR if failed? No, it's just informative. | |
# - How: execute script .github/scripts/request_validation.py specifying the | |
# EGA's API server endpoint and this new branch's JSON documents. | |
# | |
# For more information, check: | |
# https://github.com/EbiEga/ega-metadata-schema/tree/main/docs/gh_workflows | |
name: | | |
[OPTIONAL] JSON docs validation - | |
EGA API (json_validation_against_EGA_API.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 | |
- 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: Cache pip | |
uses: actions/cache@v4 | |
with: | |
# On subsequent runs, if the cache key matches (i.e., operating system and the hash of the requirements.txt file), | |
# the dependencies are restored from the cache instead of being downloaded and installed again. | |
path: ~/.cache/pip | |
# combines the OS type and a hash of the requirements.txt file: the cache is specific to the dependencies listed | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
# If there is no cache for this key, we create it at the end of the run, even if there was an error mid-way | |
save-always: true | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
requirements_f="./.github/scripts/requirements.txt" | |
if [ -f "$requirements_f" ]; then pip install -r "$requirements_f" --prefer-binary --verbose; 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 EGA's server of Biovalidator | |
url="http://biovalidator.ega.ebi.ac.uk/validate" | |
python3 ./.github/scripts/request_validation.py "$json_ex_dir" "$url" |