Validate files #58
Workflow file for this run
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: | |
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 | |
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: | | |
mkdir files | |
cp ./${{ env.WORKING_DIR }}/*.json files/ | |
cd validation-suite | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
ls ../files/ | |
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 -f ../${{ env.WORKING_DIR }}/relationships.csv -p ../files/ --no-geonames | |
else | |
python run_validations.py -i ../files -p ../files/ --no-geonames | |
fi | |
elif [[ ${{ github.event.inputs.with-relationship }} == false ]]; then | |
python run_validations.py -i ../files --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 -f ../${{ env.WORKING_DIR }}/relationships.csv -p ../files/ | |
else | |
python run_validations.py -i ../files -p ../files/ | |
fi | |
elif [[ ${{ github.event.inputs.with-relationship }} == false ]]; then | |
python run_validations.py -i ../files | |
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}. On branch: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}' |