Skip to content

Enforce ### Testing section in pull requests and check that the starter instructions were deleted/replaced #5

Enforce ### Testing section in pull requests and check that the starter instructions were deleted/replaced

Enforce ### Testing section in pull requests and check that the starter instructions were deleted/replaced #5

Workflow file for this run

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
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
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 testing)
if: steps.check-testing.outcome == 'failure'
run: |
python -c 'import sys; print("Testing section missing (test failed)"); sys.exit(1)"
- 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)"