|
| 1 | +name: Validate dump |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + schema-version: |
| 6 | + required: true |
| 7 | + description: Schema version |
| 8 | + type: choice |
| 9 | + options: |
| 10 | + - v1 |
| 11 | + - v2 |
| 12 | + file-name: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + description: Name of dump file to validate. Must be .zip file. |
| 16 | + directory-name: |
| 17 | + type: string |
| 18 | + description: Name of parent directory containing file to validate. Needed only if different from branch name. |
| 19 | + |
| 20 | +jobs: |
| 21 | + validate-files: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + if: github.event.ref != 'refs/heads/main' |
| 24 | + steps: |
| 25 | + - name: checkout |
| 26 | + uses: actions/checkout@v2 |
| 27 | + with: |
| 28 | + ref: ${{ github.event.ref }} |
| 29 | + - name: Set up Python environment |
| 30 | + uses: actions/setup-python@v2 |
| 31 | + with: |
| 32 | + python-version: "3.8" |
| 33 | + - name: Checkout validation suite |
| 34 | + uses: actions/checkout@v2 |
| 35 | + with: |
| 36 | + repository: ror-community/validation-suite |
| 37 | + ref: schema-v2 |
| 38 | + path: validation-suite |
| 39 | + - name: Get directory name |
| 40 | + if: "${{ github.event.inputs.directory-name != '' }}" |
| 41 | + run: echo "WORKING_DIR=${{ github.event.inputs.directory-name }}" >> $GITHUB_ENV |
| 42 | + - name: Get branch name |
| 43 | + if: "${{ github.event.inputs.directory-name == '' }}" |
| 44 | + run: echo "WORKING_DIR=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV |
| 45 | + - name: Validate files |
| 46 | + id: validatedump |
| 47 | + run: | |
| 48 | + echo ${{ github.event.inputs.schema-version}} |
| 49 | + cd validation-suite |
| 50 | + python -m pip install --upgrade pip |
| 51 | + pip install -r requirements.txt |
| 52 | + curl https://raw.githubusercontent.com/ror-community/ror-schema/master/ror_schema.json -o ror_schema.json |
| 53 | + curl https://raw.githubusercontent.com/ror-community/ror-schema/master/ror_schema_v2_0.json -o ror_schema_v2_0.json |
| 54 | + if [[ ${{ github.event.inputs.schema-version }} == 'v1' ]]; then |
| 55 | + echo "validating v1" |
| 56 | + python run_validations.py -i ../${{ env.WORKING_DIR }}/${{ github.event.inputs.file-name}} -v 1 -s ror_schema.json |
| 57 | +
|
| 58 | + fi |
| 59 | + if [[ ${{ github.event.inputs.schema-version }} == 'v2' ]]; then |
| 60 | + echo "validating v2" |
| 61 | + python run_validations.py -i ../${{ env.WORKING_DIR }}/${{ github.event.inputs.file-name}} -v 2 -s ror_schema_v2_0.json |
| 62 | + fi |
| 63 | + - name: Notify Slack |
| 64 | + if: always() |
| 65 | + uses: edge/simple-slack-notify@master |
| 66 | + env: |
| 67 | + SLACK_WEBHOOK_URL: ${{ secrets.CURATOR_SLACK_WEBHOOK_URL }} |
| 68 | + with: |
| 69 | + channel: '#ror-curation-releases' |
| 70 | + color: 'good' |
| 71 | + text: 'Dump validation status ${{ steps.validatedump.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}' |
0 commit comments