diff --git a/.github/workflows/report-maker.yml b/.github/workflows/report-maker.yml deleted file mode 100644 index 20038873..00000000 --- a/.github/workflows/report-maker.yml +++ /dev/null @@ -1,141 +0,0 @@ -# Candace Savonen March 2022 - -name: Run error checker - -on: - workflow_call: - inputs: - check_type: - required: true - type: string - error_min: - default: 0 - type: number - -jobs: - error-check: - runs-on: ubuntu-latest - container: - image: jhudsl/course_template:main - - steps: - - name: Checkout files - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Declare variables - id: declare - run: | - if ${{inputs.check_type == 'spelling'}} ;then - error_name='Spelling errors' - report_path='check_reports/spell_check_results.tsv' - elif ${{inputs.check_type == 'urls'}} ;then - error_name='Broken URLs' - report_path='check_reports/url_checks.csv' - elif ${{inputs.check_type == 'quiz_format'}} ;then - error_name='Quiz format errors' - report_path='check_reports/question_error_report.tsv' - fi - echo $error_name - echo $report_path - echo "::set-output name=error_name::$error_name" - echo "::set-output name=report_path::$report_path" - - - name: Configure git - run: | - git config --local user.email "itcrtrainingnetwork@gmail.com" - git config --local user.name "jhudsl-robot" - - branch_name='preview-${{ github.event.pull_request.number }}' - git fetch --all - git checkout $branch_name - git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories - shell: bash - -###################### Run the appropriate test ################################ - - - name: Count URL errors - if: ${{ inputs.check_type == 'urls' }} - run: | - chk_results=$(Rscript scripts/url-check.R) - chk_results="$((chk_results-1))" - echo $chk_results - - echo "chk_results=$chk_results" >> $GITHUB_ENV - - - name: Run spelling check - if: ${{ inputs.check_type == 'spelling' }} - run: | - chk_results=$(Rscript scripts/spell-check.R) - chk_results="$((chk_results-1))" - echo $chk_results - - echo "chk_results=$chk_results" >> $GITHUB_ENV - - - name: Run quiz check - if: ${{ inputs.check_type == 'quiz_format' }} - run: | - chk_results=$(Rscript scripts/quiz-check.R) - chk_results="$((chk_results-1))" - echo $chk_results - - echo "chk_results=$chk_results" >> $GITHUB_ENV - -############################# Handle commenting ################################ - - - name: Commit check errors - run: | - branch_name='preview-${{ github.event.pull_request.number }}' - git add --force ${{ steps.declare.outputs.report_path }} || echo "No changes to commit" - git commit -m 'Add ${{ steps.declare.outputs.error_name }} check file' || echo "No changes to commit" - git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours - git push --force origin $branch_name || echo "No changes to commit" - - - name: Build components of the spell check comment - id: build-components - env: - GH_PAT: ${{ secrets.GH_PAT }} - run: | - branch_name='preview-${{ github.event.pull_request.number }}' - error_url=https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/$branch_name/${{ steps.declare.outputs.report_path }} - echo ::set-output name=time::$(date +'%Y-%m-%d') - echo ::set-output name=commit_id::$GITHUB_SHA - echo ::set-output name=error_url::$error_url - - # Handle the commenting - - name: Find Comment - uses: peter-evans/find-comment@v1 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: ${{ steps.declare.outputs.error_name }} - - - name: There are errors! - if: ${{ env.chk_results >= env.error_min }} - uses: peter-evans/create-or-update-comment@v1 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - :warning: ${{ steps.declare.outputs.error_name }} :warning: - There are ${{ steps.declare.outputs.error_name }} that need to be addressed. [Read this guide for more info](https://github.com/jhudsl/OTTR_Template/wiki/Spell-check). - [Download the errors here.](${{ steps.build-components.outputs.error_url }}) - _Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ - edit-mode: replace - - - name: Check check results - fail if too many errors - if: ${{ env.chk_results >= env.error_min }} - run: exit 1 - - - name: No errors - if: ${{ env.chk_results < env.error_min }} - uses: peter-evans/create-or-update-comment@v1 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - No ${{ steps.declare.outputs.error_name }}! :tada: - _Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ - edit-mode: replace