diff --git a/.github/workflows/manage-prs.yml b/.github/workflows/manage-prs.yml index efa8f5ab..bd383d14 100644 --- a/.github/workflows/manage-prs.yml +++ b/.github/workflows/manage-prs.yml @@ -6,6 +6,7 @@ env: # GitHub user names to request reviews from in cases where PRs can't be managed automatically. - per1234 CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT: check-submissions-failed + ERROR_MESSAGE_PREFIX: ":x: **ERROR:** " on: # pull_request_target trigger is used instead of pull_request so the token will have the write permissions needed to @@ -92,6 +93,7 @@ jobs: outputs: type: ${{ steps.parse-request.outputs.type }} + error: ${{ steps.parse-request.outputs.error }} arduinoLintLibraryManagerSetting: ${{ steps.parse-request.outputs.arduinoLintLibraryManagerSetting }} submissions: ${{ steps.parse-request.outputs.submissions }} index-entry: ${{ steps.parse-request.outputs.index-entry }} @@ -132,6 +134,7 @@ jobs: # Due to limitations of the GitHub Actions workflow system, dedicated outputs must be created for use in # certain workflow fields. echo "::set-output name=type::$(echo "$REQUEST" | jq -r -c '.type')" + echo "::set-output name=error::$(echo "$REQUEST" | jq -r -c '.error')" echo "::set-output name=arduinoLintLibraryManagerSetting::$(echo "$REQUEST" | jq -r -c '.arduinoLintLibraryManagerSetting')" echo "::set-output name=submissions::$(echo "$REQUEST" | jq -c '.submissions')" echo "::set-output name=index-entry::$(echo "$REQUEST" | jq -r -c '.indexEntry')" @@ -155,6 +158,34 @@ jobs: labels: | - ${{ needs.parse.outputs.type }} + parse-fail: + needs: + - parse + if: needs.parse.outputs.error != '' + + runs-on: ubuntu-latest + steps: + - name: Comment on error detected while parsing PR + uses: octokit/request-action@v2.x + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments + owner: ${{ github.repository_owner }} + repo: ${{ github.event.repository.name }} + issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }} + body: | + | + Hi @${{ github.actor }} + A problem was found with your pull request: + + ${{ env.ERROR_MESSAGE_PREFIX }}${{ needs.parse.outputs.error }} + + Please resolve this error. The checks will automatically run again once that is done. + + More information: + https://github.com/${{ github.repository }}/blob/main/README.md#if-the-problem-is-with-the-pull-request + check-submissions: name: Check ${{ matrix.submission.submissionURL }} needs: @@ -205,7 +236,7 @@ jobs: | A problem was found with your submission ${{ matrix.submission.submissionURL }} - :x: **ERROR:** ${{ matrix.submission.error }} + ${{ env.ERROR_MESSAGE_PREFIX }}${{ matrix.submission.error }} - name: Set checks result to fail if error detected by submission parser if: matrix.submission.error != '' @@ -296,7 +327,7 @@ jobs: issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }} body: | | - :x: **ERROR:** [Arduino Lint](https://github.com/arduino/arduino-lint) found errors with ${{ matrix.submission.submissionURL }}: + ${{ env.ERROR_MESSAGE_PREFIX }}[Arduino Lint](https://github.com/arduino/arduino-lint) found errors with ${{ matrix.submission.submissionURL }}: ``` ${{ steps.read-lint-report.outputs.text-report }} @@ -462,44 +493,22 @@ jobs: issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }} body: | | - :x: **ERROR:** Your submission meets all requirements. However, the pull request could not be merged. + ${{ env.ERROR_MESSAGE_PREFIX }}Your submission meets all requirements. However, the pull request could not be merged. Please follow this guide to resolve a merge conflict: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github Once that is done, it will be merged automatically. - - name: Request a review in case assistance is required - if: contains(toJSON(env.MAINTAINERS), github.actor) != true # Don't attempt to request review from PR author. - uses: octokit/request-action@v2.x - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers - owner: ${{ github.repository_owner }} - repo: ${{ github.event.repository.name }} - pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }} - reviewers: ${{ env.MAINTAINERS }} - not-submission: needs: - parse - if: needs.parse.outputs.type != 'submission' # These request types can't be automatically approved. + # These request types can't be automatically approved. + if: > + needs.parse.outputs.type != 'submission' && + needs.parse.outputs.type != 'invalid' runs-on: ubuntu-latest - steps: - - name: Request pull request review - if: contains(toJSON(env.MAINTAINERS), github.actor) != true - uses: octokit/request-action@v2.x - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers - owner: ${{ github.repository_owner }} - repo: ${{ github.event.repository.name }} - pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }} - reviewers: ${{ env.MAINTAINERS }} - - name: Comment on required review uses: octokit/request-action@v2.x env: @@ -521,6 +530,7 @@ jobs: unexpected-fail: needs: # Run after all other jobs + - parse-fail - merge-fail - check-submissions-fail - label @@ -542,18 +552,6 @@ jobs: labels: | - "status: maintenance required" - - name: Request pull request review - if: contains(toJSON(env.MAINTAINERS), github.actor) != true - uses: octokit/request-action@v2.x - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers - owner: ${{ github.repository_owner }} - repo: ${{ github.event.repository.name }} - pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }} - reviewers: ${{ env.MAINTAINERS }} - - name: Comment on unexpected failure uses: octokit/request-action@v2.x env: @@ -581,3 +579,31 @@ jobs: :warning::warning::warning::warning: SLACK_COLOR: danger MSG_MINIMAL: true + + request-review: + needs: + - parse-fail + - merge-fail + - not-submission + - unexpected-fail + if: > + always() && + ( + needs.parse-fail.result != 'skipped' || + needs.merge-fail.result != 'skipped' || + needs.not-submission.result != 'skipped' || + needs.unexpected-fail.result != 'skipped' + ) + runs-on: ubuntu-latest + steps: + - name: Request pull request review from maintainer + if: contains(toJSON(env.MAINTAINERS), github.actor) != true # Don't attempt to request review from PR author. + uses: octokit/request-action@v2.x + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers + owner: ${{ github.repository_owner }} + repo: ${{ github.event.repository.name }} + pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }} + reviewers: ${{ env.MAINTAINERS }}