Enforce ### Testing
section in pull requests and check that the starter instructions were deleted/replaced
#9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR validity | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
check_testing_header: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check for Testing Header | |
id: check-testing | |
continue-on-error: true | |
run: | | |
python -c 'import sys; pr_summary = """${{ github.event.pull_request.body }}"""; sys.exit(0 if "### Testing" in pr_summary else 1)' | |
- name: Check for Instructions Deletion | |
id: check-instructions | |
continue-on-error: true | |
run: | | |
python -c 'import sys; pr_summary = """${{ github.event.pull_request.body }}"""; sys.exit(1 if "Make sure you delete these instructions" in pr_summary else 0)' | |
- name: Add comment (missing instructions) | |
if: steps.check-instructions.outcome == 'failure' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Please make sure to delete starter instructions from your PR summary and replace them with a descriptive summary.' | |
}) | |
- name: Fail if instructions check failed | |
if: steps.check-testing.outcome == 'failure' | |
run: | | |
python -c 'import sys; print("PR instructions were not replaced"); sys.exit(1)' | |
- name: Add comment (missing testing) | |
if: steps.check-testing.outcome == 'failure' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Please add a `### Testing` section to your PR summary describing the testing performed. See https://github.com/project-chip/connectedhomeip/blob/master/CONTRIBUTING.md#pull-requests' | |
}) | |
- name: Fail if testing section check failed | |
if: steps.check-testing.outcome == 'failure' | |
run: | | |
python -c 'import sys; print("Testing section missing (test failed)"); sys.exit(1)' | |