Validate files #202
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
name: Validate files | |
on: | |
workflow_dispatch: | |
inputs: | |
schema-version: | |
required: true | |
description: Schema version | |
type: choice | |
options: | |
- v1 | |
- v2 | |
with-relationship: | |
type: boolean | |
description: Check box to validate with relationships | |
skip-geonames: | |
type: boolean | |
description: Check box to skip Geonames validation | |
directory-name: | |
type: string | |
description: Name of parent directory containing records to validate. Needed only if different from branch name. | |
jobs: | |
validate-files: | |
runs-on: ubuntu-latest | |
if: github.event.ref != 'refs/heads/main' | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.ref }} | |
- name: Set up Python environment | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
- name: Checkout validation suite | |
uses: actions/checkout@v2 | |
with: | |
repository: ror-community/validation-suite | |
ref: schema-v2 | |
path: validation-suite | |
- name: Get directory name | |
if: "${{ github.event.inputs.directory-name != '' }}" | |
run: echo "WORKING_DIR=${{ github.event.inputs.directory-name }}" >> $GITHUB_ENV | |
- name: Get branch name | |
if: "${{ github.event.inputs.directory-name == '' }}" | |
run: echo "WORKING_DIR=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
- name: Validate files | |
id: validatefiles | |
run: | | |
echo ${{ github.event.inputs.schema-version}} | |
mkdir files | |
cp ./${{ env.WORKING_DIR }}/*/*.json files/ | |
cd validation-suite | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
curl https://raw.githubusercontent.com/ror-community/ror-schema/schema-v2/ror_schema.json -o ror_schema.json | |
curl https://raw.githubusercontent.com/ror-community/ror-schema/schema-v2/ror_schema_v2_0.json -o ror_schema_v2_0.json | |
ls ../files/ | |
if [[ ${{ github.event.inputs.schema-version }} == 'v1' ]]; then | |
echo "validating v1" | |
if [[ ${{ github.event.inputs.skip-geonames }} == true ]]; then | |
if [[ ${{ github.event.inputs.with-relationship }} == true ]]; then | |
if [[ -f "../${{ env.WORKING_DIR }}/relationships.csv" ]]; then | |
python run_validations.py -i ../files -v 1 -s ror_schema.json -f ../${{ env.WORKING_DIR }}/relationships.csv -p ../files/ --no-geonames | |
else | |
python run_validations.py -i ../files -v 1 -s ror_schema.json -p ../files/ --no-geonames | |
fi | |
elif [[ ${{ github.event.inputs.with-relationship }} == false ]]; then | |
python run_validations.py -i ../files -v 1 -s ror_schema.json --no-geonames | |
fi | |
else | |
if [[ ${{ github.event.inputs.with-relationship }} == true ]]; then | |
if [[ -f "../${{ env.WORKING_DIR }}/relationships.csv" ]]; then | |
python run_validations.py -i ../files -v 1 -s ror_schema.json -f ../${{ env.WORKING_DIR }}/relationships.csv -p ../files/ | |
else | |
python run_validations.py -i ../files -v 1 -s ror_schema.json -p ../files/ | |
fi | |
elif [[ ${{ github.event.inputs.with-relationship }} == false ]]; then | |
python run_validations.py -i ../files -v 1 -s ror_schema.json | |
fi | |
fi | |
fi | |
if [[ ${{ github.event.inputs.schema-version }} == 'v2' ]]; then | |
echo "validating v2" | |
if [[ ${{ github.event.inputs.skip-geonames }} == true ]]; then | |
if [[ ${{ github.event.inputs.with-relationship }} == true ]]; then | |
if [[ -f "../${{ env.WORKING_DIR }}/relationships.csv" ]]; then | |
python run_validations.py -i ../files -v 2 -s ror_schema_v2_0.json -f ../${{ env.WORKING_DIR }}/relationships.csv -p ../files/ --no-geonames | |
else | |
python run_validations.py -i ../files -v 2 -s ror_schema_v2_0.json -p ../files/ --no-geonames | |
fi | |
elif [[ ${{ github.event.inputs.with-relationship }} == false ]]; then | |
python run_validations.py -i ../files -v 2 -s ror_schema_v2_0.json --no-geonames | |
fi | |
else | |
if [[ ${{ github.event.inputs.with-relationship }} == true ]]; then | |
if [[ -f "../${{ env.WORKING_DIR }}/relationships.csv" ]]; then | |
python run_validations.py -i ../files -v 2 -s ror_schema_v2_0.json -f ../${{ env.WORKING_DIR }}/relationships.csv -p ../files/ | |
else | |
python run_validations.py -i ../files -v 2 -s ror_schema_v2_0.json -p ../files/ | |
fi | |
elif [[ ${{ github.event.inputs.with-relationship }} == false ]]; then | |
python run_validations.py -i ../files -v 2 -s ror_schema_v2_0.json | |
fi | |
fi | |
fi | |
- name: Notify Slack | |
if: always() | |
uses: edge/simple-slack-notify@master | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.CURATOR_SLACK_WEBHOOK_URL }} | |
with: | |
channel: '#ror-curation-releases' | |
color: 'good' | |
text: 'Validation status ${{ steps.validatefiles.outcome }} in ${env.GITHUB_REPOSITORY}. Using version ${{ github.event.inputs.schema-version }}. On branch: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}' |