From e24246e30f817eb51fb914008e6186b2bddd6a64 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Wed, 16 Nov 2022 16:31:43 -0600 Subject: [PATCH 1/2] update workflows for org status changes --- .github/workflows/generate_relationships.yml | 6 +- .github/workflows/remove_relationships.yml | 65 ++++++++++++++++++++ .github/workflows/update_labels.yml | 7 +-- .github/workflows/validate.yml | 3 +- 4 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/remove_relationships.yml diff --git a/.github/workflows/generate_relationships.yml b/.github/workflows/generate_relationships.yml index 710bc0db1..05aa3661c 100644 --- a/.github/workflows/generate_relationships.yml +++ b/.github/workflows/generate_relationships.yml @@ -31,8 +31,8 @@ jobs: python -m pip install --upgrade pip pip install requests==2.23.0 pip install git+https://github.com/ror-community/update_address.git - curl https://raw.githubusercontent.com/ror-community/ror-api/dev/rorapi/management/commands/generaterelationships.py -o generaterelationships.py - python generaterelationships.py relationships.csv + curl https://raw.githubusercontent.com/ror-community/curation_ops/move-generate-rel/generate_relationships/generate_relationships.py -o generate_relationships.py + python generate_relationships.py relationships.csv - name: commit error file if: ${{ steps.genrelshp.outcome != 'success'}} working-directory: ${{ env.WORKING_DIR }} @@ -62,4 +62,4 @@ jobs: with: channel: '#ror-curation-releases' color: 'good' - text: 'Relationship generation status ${env.VALIDATION_STATUS} in ${env.GITHUB_REPOSITORY}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' + text: 'DEV relationship generation status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' diff --git a/.github/workflows/remove_relationships.yml b/.github/workflows/remove_relationships.yml new file mode 100644 index 000000000..3cad39ca7 --- /dev/null +++ b/.github/workflows/remove_relationships.yml @@ -0,0 +1,65 @@ +name: Remove relationships to inactive records +on: + workflow_dispatch: + inputs: + directory-name: + type: string + description: Name of parent directory containing new/updated records with inactive statuses. Needed only if different from branch name. + +jobs: + remove-relationships: + runs-on: ubuntu-latest + 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: 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: Remove relationships + id: remrelshp + working-directory: ${{ env.WORKING_DIR }} + run: | + python -m pip install --upgrade pip + pip install requests==2.23.0 + pip install git+https://github.com/ror-community/update_address.git + curl https://raw.githubusercontent.com/ror-community/curation_ops/move-generate-rel/remove_relationships/remove_relationships.py -o remove_relationships.py + python remove_relationships.py relationships.csv + - name: commit error file + if: ${{ steps.remrelshp.outcome != 'success'}} + working-directory: ${{ env.WORKING_DIR }} + run: | + echo "ERRORS found for some records:" + cat relationship_errors.log + - name: commit changed files + if: ${{ steps.remrelshp.outcome == 'success'}} + uses: stefanzweifel/git-auto-commit-action@v4 + with: + file_pattern: ${{ env.WORKING_DIR }}/**.json + commit_message: Apply relationship changes to files + - name: Set env variable for notification + if: always() + run: | + if [[ ${{ steps.remrelshp.outcome }} == 'success' ]]; then + echo "relationship_status=SUCCESS" >> $GITHUB_ENV + else + echo "relationship_status=FAILED" >> $GITHUB_ENV + fi + - name: Notify Slack + if: always() + uses: edge/simple-slack-notify@master + env: + SLACK_WEBHOOK_URL: ${{ secrets.CURATOR_SLACK_WEBHOOK_URL }} + VALIDATION_STATUS: ${{ env.relationship_status }} + with: + channel: '#ror-curation-releases' + color: 'good' + text: 'DEV relationship removal status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' diff --git a/.github/workflows/update_labels.yml b/.github/workflows/update_labels.yml index 371eed8f6..1c97c99c9 100644 --- a/.github/workflows/update_labels.yml +++ b/.github/workflows/update_labels.yml @@ -29,9 +29,9 @@ jobs: working-directory: ${{ env.WORKING_DIR }} run: | python -m pip install --upgrade pip - curl https://raw.githubusercontent.com/ror-community/curation_ops/main/update_related_records/requirements.txt -o requirements.txt + curl https://raw.githubusercontent.com/ror-community/curation_ops/move-generate-rel/update_related_records/requirements.txt -o requirements.txt pip install -r requirements.txt - curl https://raw.githubusercontent.com/ror-community/curation_ops/main/update_related_records/update_related.py -o update_related.py + curl https://raw.githubusercontent.com/ror-community/curation_ops/move-generate-rel/update_related_records/update_related.py -o update_related.py python update_related.py - name: commit changed files if: ${{ steps.updatelabels.outcome == 'success'}} @@ -56,5 +56,4 @@ jobs: with: channel: '#ror-curation-releases' color: 'good' - text: '${env.GITHUB_REPOSITORY}: Update labels in related records status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' - + text: 'DEV update labels in related records status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index ef5d0bee9..2c61e165c 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -27,6 +27,7 @@ jobs: with: repository: ror-community/validation-suite path: validation-suite + ref: dev - name: Get directory name if: "${{ github.event.inputs.directory-name != '' }}" run: echo "WORKING_DIR=${{ github.event.inputs.directory-name }}" >> $GITHUB_ENV @@ -59,4 +60,4 @@ jobs: with: channel: '#ror-curation-releases' color: 'good' - text: '${env.GITHUB_REPOSITORY}: 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}' + 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}' From 10308821c71b4719200c6d5708b2dbf9443383d4 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Wed, 16 Nov 2022 16:36:38 -0600 Subject: [PATCH 2/2] update slack msg text --- .github/workflows/generate_relationships.yml | 2 +- .github/workflows/remove_relationships.yml | 2 +- .github/workflows/update_labels.yml | 2 +- .github/workflows/validate.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/generate_relationships.yml b/.github/workflows/generate_relationships.yml index 05aa3661c..dd6634460 100644 --- a/.github/workflows/generate_relationships.yml +++ b/.github/workflows/generate_relationships.yml @@ -62,4 +62,4 @@ jobs: with: channel: '#ror-curation-releases' color: 'good' - text: 'DEV relationship generation status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' + text: 'Relationship generation status ${env.VALIDATION_STATUS} in ${env.GITHUB_REPOSITORY}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' diff --git a/.github/workflows/remove_relationships.yml b/.github/workflows/remove_relationships.yml index 3cad39ca7..324aa1e74 100644 --- a/.github/workflows/remove_relationships.yml +++ b/.github/workflows/remove_relationships.yml @@ -62,4 +62,4 @@ jobs: with: channel: '#ror-curation-releases' color: 'good' - text: 'DEV relationship removal status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' + text: 'Relationship removal status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' diff --git a/.github/workflows/update_labels.yml b/.github/workflows/update_labels.yml index 1c97c99c9..730769f6e 100644 --- a/.github/workflows/update_labels.yml +++ b/.github/workflows/update_labels.yml @@ -56,4 +56,4 @@ jobs: with: channel: '#ror-curation-releases' color: 'good' - text: 'DEV update labels in related records status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' + text: '${env.GITHUB_REPOSITORY}: Update labels in related records status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 2c61e165c..67ab19392 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -60,4 +60,4 @@ jobs: 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}' + text: '${env.GITHUB_REPOSITORY}: 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}'