You've already forked library-registry
mirror of
https://github.com/arduino/library-registry.git
synced 2025-11-21 15:20:52 +03:00
Merge pull request #212 from per1234/no-submission-workflow-fail-new
Only fail "Manage PRs" workflow on unexpected error
This commit is contained in:
89
.github/workflows/manage-prs.yml
vendored
89
.github/workflows/manage-prs.yml
vendored
@@ -5,6 +5,7 @@ env:
|
|||||||
MAINTAINERS: |
|
MAINTAINERS: |
|
||||||
# GitHub user names to request reviews from in cases where PRs can't be managed automatically.
|
# GitHub user names to request reviews from in cases where PRs can't be managed automatically.
|
||||||
- per1234
|
- per1234
|
||||||
|
CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT: check-submissions-failed
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# pull_request_target trigger is used instead of pull_request so the token will have the write permissions needed to
|
# pull_request_target trigger is used instead of pull_request so the token will have the write permissions needed to
|
||||||
@@ -178,6 +179,8 @@ jobs:
|
|||||||
echo "JSON_REPORT_PATH=${{ runner.temp }}/report.json" >> "$GITHUB_ENV"
|
echo "JSON_REPORT_PATH=${{ runner.temp }}/report.json" >> "$GITHUB_ENV"
|
||||||
echo "TEXT_REPORT_PATH=${{ runner.temp }}/report.txt" >> "$GITHUB_ENV"
|
echo "TEXT_REPORT_PATH=${{ runner.temp }}/report.txt" >> "$GITHUB_ENV"
|
||||||
echo "ARDUINO_LINT_INSTALLATION_PATH=${{ runner.temp }}/arduino-lint" >> "$GITHUB_ENV"
|
echo "ARDUINO_LINT_INSTALLATION_PATH=${{ runner.temp }}/arduino-lint" >> "$GITHUB_ENV"
|
||||||
|
echo "PASS=true" >> "$GITHUB_ENV" # This variable stores the checks result
|
||||||
|
echo "FAIL_FLAG_PATH=${{ runner.temp }}/.check-submissions-failed" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Submission PRs can be handled without maintainer involvement
|
# Submission PRs can be handled without maintainer involvement
|
||||||
- name: Remove prior review requests
|
- name: Remove prior review requests
|
||||||
@@ -207,13 +210,12 @@ jobs:
|
|||||||
|
|
||||||
:x: **ERROR:** ${{ matrix.submission.error }}
|
:x: **ERROR:** ${{ matrix.submission.error }}
|
||||||
|
|
||||||
- name: Fail on error detected while parsing
|
- name: Set checks result to fail if error detected by submission parser
|
||||||
if: matrix.submission.error != ''
|
if: matrix.submission.error != ''
|
||||||
run: |
|
run: echo "PASS=false" >> "$GITHUB_ENV"
|
||||||
echo "::error::Error found with submission"
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
- name: Install Arduino Lint
|
- name: Install Arduino Lint
|
||||||
|
if: env.PASS == 'true'
|
||||||
run: |
|
run: |
|
||||||
mkdir --parents "${{ env.ARDUINO_LINT_INSTALLATION_PATH }}"
|
mkdir --parents "${{ env.ARDUINO_LINT_INSTALLATION_PATH }}"
|
||||||
curl \
|
curl \
|
||||||
@@ -225,6 +227,7 @@ jobs:
|
|||||||
|
|
||||||
# actions/checkout can't be used because it only supports GitHub repos, while libraries may use other Git hosts
|
# actions/checkout can't be used because it only supports GitHub repos, while libraries may use other Git hosts
|
||||||
- name: Clone submission
|
- name: Clone submission
|
||||||
|
if: env.PASS == 'true'
|
||||||
run: |
|
run: |
|
||||||
git clone \
|
git clone \
|
||||||
--branch ${{ matrix.submission.tag }} \
|
--branch ${{ matrix.submission.tag }} \
|
||||||
@@ -233,7 +236,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Lint submission
|
- name: Lint submission
|
||||||
id: arduino-lint
|
id: arduino-lint
|
||||||
continue-on-error: true # Continue the job so the report can be commented to the PR
|
if: env.PASS == 'true'
|
||||||
|
continue-on-error: true # Error on linter rule violations is expected
|
||||||
run: |
|
run: |
|
||||||
export ARDUINO_LINT_OFFICIAL="${{ matrix.submission.official }}"
|
export ARDUINO_LINT_OFFICIAL="${{ matrix.submission.official }}"
|
||||||
|
|
||||||
@@ -249,6 +253,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Read Arduino Lint reports
|
- name: Read Arduino Lint reports
|
||||||
id: read-lint-report
|
id: read-lint-report
|
||||||
|
if: env.PASS == 'true'
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=json-report::$(jq -c . "${{ env.JSON_REPORT_PATH }}")"
|
echo "::set-output name=json-report::$(jq -c . "${{ env.JSON_REPORT_PATH }}")"
|
||||||
|
|
||||||
@@ -261,7 +266,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Comment on Arduino Lint warning
|
- name: Comment on Arduino Lint warning
|
||||||
if: >
|
if: >
|
||||||
fromJson(steps.read-lint-report.outputs.json-report).summary.warningCount > 0
|
env.PASS == 'true'
|
||||||
|
&& fromJson(steps.read-lint-report.outputs.json-report).summary.warningCount > 0
|
||||||
&& fromJson(steps.read-lint-report.outputs.json-report).summary.errorCount == 0
|
&& fromJson(steps.read-lint-report.outputs.json-report).summary.errorCount == 0
|
||||||
uses: octokit/request-action@v2.x
|
uses: octokit/request-action@v2.x
|
||||||
env:
|
env:
|
||||||
@@ -280,7 +286,9 @@ jobs:
|
|||||||
```
|
```
|
||||||
|
|
||||||
- name: Comment on Arduino Lint error
|
- name: Comment on Arduino Lint error
|
||||||
if: fromJson(steps.read-lint-report.outputs.json-report).summary.errorCount > 0
|
if: >
|
||||||
|
env.PASS == 'true'
|
||||||
|
&& fromJson(steps.read-lint-report.outputs.json-report).summary.errorCount > 0
|
||||||
uses: octokit/request-action@v2.x
|
uses: octokit/request-action@v2.x
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -297,17 +305,45 @@ jobs:
|
|||||||
${{ steps.read-lint-report.outputs.text-report }}
|
${{ steps.read-lint-report.outputs.text-report }}
|
||||||
```
|
```
|
||||||
|
|
||||||
- name: Fail on Arduino Lint error
|
- name: Set checks result to fail if error detected by Arduino Lint
|
||||||
if: steps.arduino-lint.outcome == 'failure'
|
if: >
|
||||||
run: |
|
env.PASS == 'true'
|
||||||
echo "::error::Arduino Lint detected an error"
|
&& steps.arduino-lint.outcome == 'failure'
|
||||||
exit 1
|
run: echo "PASS=false" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Create failure flag file
|
||||||
|
if: env.PASS == 'false'
|
||||||
|
run: touch ${{ env.FAIL_FLAG_PATH }} # Arbitrary file to provide content for the flag artifact
|
||||||
|
|
||||||
|
# The value of a job matrix output is set by whichever job happened to run last, not of use for this application.
|
||||||
|
# So it's necessary to use an alternative means of indicating that at least one submission failed the checks.
|
||||||
|
- name: Upload failure flag artifact
|
||||||
|
if: env.PASS == 'false'
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
if-no-files-found: error
|
||||||
|
path: ${{ env.FAIL_FLAG_PATH }}
|
||||||
|
name: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT }}
|
||||||
|
|
||||||
|
check-submissions-result:
|
||||||
|
needs: check-submissions
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
pass: ${{ steps.failure-flag-exists.outcome == 'failure' }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check for existence of submission check failure flag artifact
|
||||||
|
id: failure-flag-exists
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
name: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT }}
|
||||||
|
|
||||||
check-submissions-fail:
|
check-submissions-fail:
|
||||||
needs:
|
needs:
|
||||||
- check-submissions
|
- check-submissions-result
|
||||||
# Only run if the check-submissions job failed
|
if: needs.check-submissions-result.outputs.pass == 'false'
|
||||||
if: failure() && needs.check-submissions.result == 'failure'
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -336,10 +372,14 @@ jobs:
|
|||||||
merge:
|
merge:
|
||||||
needs:
|
needs:
|
||||||
- parse
|
- parse
|
||||||
- check-submissions
|
- check-submissions-result
|
||||||
# Only merge submissions that passed all checks
|
# Only merge submissions that passed all checks
|
||||||
if: success() && needs.parse.outputs.type == 'submission'
|
if: >
|
||||||
|
needs.parse.outputs.type == 'submission'
|
||||||
|
&& needs.check-submissions-result.outputs.pass == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
pass: ${{ steps.merge.outcome == 'success' }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Approve pull request
|
- name: Approve pull request
|
||||||
@@ -354,6 +394,8 @@ jobs:
|
|||||||
event: APPROVE
|
event: APPROVE
|
||||||
|
|
||||||
- name: Merge pull request
|
- name: Merge pull request
|
||||||
|
id: merge
|
||||||
|
continue-on-error: true # Error on merge conflict is expected
|
||||||
uses: octokit/request-action@v2.x
|
uses: octokit/request-action@v2.x
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -365,11 +407,13 @@ jobs:
|
|||||||
merge_method: squash
|
merge_method: squash
|
||||||
|
|
||||||
- name: Checkout index source branch
|
- name: Checkout index source branch
|
||||||
|
if: steps.merge.outcome == 'success'
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
ref: production
|
ref: production
|
||||||
|
|
||||||
- name: Add index source file entry for submissions
|
- name: Add index source file entry for submissions
|
||||||
|
if: steps.merge.outcome == 'success'
|
||||||
run: |
|
run: |
|
||||||
INDEX_SOURCE_FILE_PATH="${{ github.workspace }}/registry.txt"
|
INDEX_SOURCE_FILE_PATH="${{ github.workspace }}/registry.txt"
|
||||||
git config --global user.email "bot@arduino.cc"
|
git config --global user.email "bot@arduino.cc"
|
||||||
@@ -385,6 +429,7 @@ jobs:
|
|||||||
git push
|
git push
|
||||||
|
|
||||||
- name: Comment that submission was accepted
|
- name: Comment that submission was accepted
|
||||||
|
if: steps.merge.outcome == 'success'
|
||||||
uses: octokit/request-action@v2.x
|
uses: octokit/request-action@v2.x
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -405,8 +450,8 @@ jobs:
|
|||||||
merge-fail:
|
merge-fail:
|
||||||
needs:
|
needs:
|
||||||
- merge
|
- merge
|
||||||
# Only run if the merge job failed
|
# Only run if the PR could not be merged
|
||||||
if: failure() && needs.merge.result == 'failure'
|
if: needs.merge.outputs.pass == 'false'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Comment on merge failure
|
- name: Comment on merge failure
|
||||||
@@ -478,8 +523,12 @@ jobs:
|
|||||||
|
|
||||||
unexpected-fail:
|
unexpected-fail:
|
||||||
needs:
|
needs:
|
||||||
|
# Run after all other jobs
|
||||||
|
- merge-fail
|
||||||
|
- check-submissions-fail
|
||||||
- label
|
- label
|
||||||
# Run if label or any of its job dependencies failed
|
- not-submission
|
||||||
|
# Run if any job failed. The workflow is configured so that jobs only fail when there is an unexpected error.
|
||||||
if: failure()
|
if: failure()
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user