Skip to content

Commit b83c27a

Browse files
Enforce ### Testing section in pull requests and check that the starter instructions were deleted/replaced (#37013)
* Add PR summary validation workflow and documentation. Added documentation to CONTRIBUTING.md and created a workflow that enforces a `### Testing` section. * Fix odd md formatting --------- Co-authored-by: Andrei Litvin <andreilitvin@google.com>
1 parent d3204f6 commit b83c27a

5 files changed

+160
-1
lines changed

.github/.wordlist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ js
757757
json
758758
JTAG
759759
Jupyter
760+
judgement
760761
jupyterlab
761762
KA
762763
kAdminister

.github/PULL_REQUEST_TEMPLATE.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
> If you do not have an issue number, please have a good description of
77
> the problem and the fix. Help the reviewer understand what to expect.
88
>
9+
> Add a `### Testing` section to your PR to describe how testing was done.
10+
> See <https://github.com/project-chip/connectedhomeip/blob/master/CONTRIBUTING.md#pull-requests>
11+
>
912
> Make sure you delete these instructions (to prove you have read them).
1013
>
1114
> !!!!!!!!!! Instructions end
12-

.github/workflows/cancel_workflows_for_pr.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ jobs:
4949
--require "Lint Code Base" \
5050
--require "ZAP" \
5151
--require "Run misspell" \
52+
--require "PR validity" \
5253
--max-pr-age-minutes 20

.github/workflows/pr-validation.yaml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: PR validity
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, edited]
6+
7+
jobs:
8+
check_testing_header:
9+
runs-on: ubuntu-latest
10+
steps:
11+
12+
- name: Check for `### Testing` section in PR
13+
id: check-testing
14+
continue-on-error: true
15+
run: |
16+
python -c 'import sys; pr_summary = """${{ github.event.pull_request.body }}"""; sys.exit(0 if "### Testing" in pr_summary else 1)'
17+
18+
- name: Check for PR starting instructions
19+
id: check-instructions
20+
continue-on-error: true
21+
run: |
22+
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)'
23+
24+
# NOTE: comments disabled for now as separate permissions are required
25+
# failing CI step may be sufficient to start (although it contains less information about why it failed)
26+
27+
# - name: Add comment (missing instructions)
28+
# if: steps.check-instructions.outcome == 'failure'
29+
# uses: actions/github-script@v6
30+
# with:
31+
# github-token: ${{ secrets.GITHUB_TOKEN }}
32+
# script: |
33+
# github.rest.issues.createComment({
34+
# issue_number: context.issue.number,
35+
# owner: context.repo.owner,
36+
# repo: context.repo.repo,
37+
# body: 'Please make sure to delete starter instructions from your PR summary and replace them with a descriptive summary.'
38+
# })
39+
40+
- name: Fail if PR instructions were not deleted
41+
if: steps.check-instructions.outcome == 'failure'
42+
run: |
43+
python -c 'import sys; print("PR instructions were not replaced"); sys.exit(1)'
44+
45+
# - name: Add comment (missing testing)
46+
# if: steps.check-testing.outcome == 'failure'
47+
# uses: actions/github-script@v6
48+
# with:
49+
# github-token: ${{ secrets.GITHUB_TOKEN }}
50+
# script: |
51+
# github.rest.issues.createComment({
52+
# issue_number: context.issue.number,
53+
# owner: context.repo.owner,
54+
# repo: context.repo.repo,
55+
# 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'
56+
# })
57+
58+
- name: Fail if `### Testing` section not in PR
59+
if: steps.check-testing.outcome == 'failure'
60+
run: |
61+
python -c 'import sys; print("Testing section missing (test failed)"); sys.exit(1)'
62+

CONTRIBUTING.md

+93
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,99 @@ This will trigger the continuous-integration checks. You can view the results in
160160
the respective services. Note that the integration checks will report failures
161161
on occasion.
162162

163+
#### Pull requests
164+
165+
Aim to make pull requests easy to read both when viewed in a list (title only)
166+
as well as clear in content within the description.
167+
168+
##### Title formatting
169+
170+
Describe the change as a one-line in some descriptive manner. Add sufficient
171+
context for a reader to understand what is improved. If platform-specific
172+
consider adding the platform as a prefix, like `[Android]` or any other tags may
173+
be useful for quick filtering like `[TC-ABC-1.2]` to tag test changes.
174+
175+
Examples of descriptive titles:
176+
177+
- `[Silabs] Fix compile of SiWx917 if LED and BUTTON are disabled`
178+
- `[Telink] Update build Dockerfile with new Zeprhy SHA: c05c4.....`
179+
- `General Commissioning Cluster: use AttributeAccessInterface/CommandHandlerInterface for processing`
180+
- `Scenes Management/CopyScene: set access as manage instead of default to match the spec`
181+
- `Fix build errors due to ChipDeviceEvent default constructor not being available`
182+
- `Fix crash during DNSSD processing due to malformed packet`
183+
- `[NRF] Fix crash due to stack overflow during logging for PW-RPC builds`
184+
- `[TC-ABC-2.3] added new python test case based on test plan`
185+
- `[TC-ABC] migrate tests from yaml to python`
186+
187+
Examples of titles that are vague (not clear what the change is, one would need
188+
to open the pull request for details or open additional issue in GitHub)
189+
190+
- `Work on issue 1234`
191+
- `Fix android JniTypeWrappers`
192+
- `Fix segfault in BLE`
193+
- `Fix TC-ABC-1.2`
194+
- `Update Readme`
195+
196+
##### Summary contents
197+
198+
Ensure that there is sufficient detail in issue summaries to make the content of
199+
the PR clear:
200+
201+
- a `TLDR` of the change content. This is a judgement call on details,
202+
generally you should include a what was changed and why. The change is
203+
trivial/short, this can be very short (i.e. "fixed typos" is perfectly
204+
acceptable, however if changing 100-1000s of line, the areas of changes
205+
should be explained)
206+
- If a crash/error is fixed, explain the root cause and if the fix is not
207+
obvious (again, judgement call), explain why the given approach was taken.
208+
- Help the reviewer out with any notable information (specific platform
209+
issues, extra thoughts or requests for feedback or gotchas on tricky code,
210+
followup work or PR dependencies)
211+
- TIP: use the syntax of `Fixes #....` to mark issues completed on PR merge or
212+
use `#...` to reference issues that are addressed.
213+
- TIP: prefer adding some brief description (especially about the content of
214+
the changes) instead of just referencing an issue (helps reviewers get
215+
context faster without extra clicks).
216+
217+
##### Testing section
218+
219+
All Pull Requests **MUST** contain a `#### Testing` section that describes how
220+
the pull request was tested. Ideally every test should have automated testing,
221+
however for platform specific changes or hardware-specific issues we may not be
222+
able to have such tests (e.g. we may not BLE or NFC capability in CI). As such,
223+
manual testing is acceptable, however the description has to be detailed
224+
intentionally to avoid a bias towards marking pull requests as "manually tested"
225+
out of convenience.
226+
227+
- Automated testing
228+
229+
**AWESOME**. You can say "unit tests added/updated" or "Integration tests
230+
updated to cover functionality" or "existing tests already cover this" (make
231+
sure they do. Integration tests often only cover happy paths).
232+
233+
Add any notes on not covered things. It is a judgement call on how much can
234+
be covered as 100% sounds great however not always possible.
235+
236+
- Manual testing
237+
238+
Describe why automated testing is impossible in the current CI environment
239+
or difficult to add. If adding later, reference the issue to add automation
240+
and a timeline for adding such automation.
241+
242+
Describe in **DETAIL** how manual testing was done: what environment, what
243+
builds were used (`build-example` names are ok such as
244+
`flashed qpg-qpg6105-light` and `used linux-x64-chip-tool-clang`). Describe
245+
commands ran (often chip-tool) and physical interaction and what was
246+
observed.
247+
248+
- Trivial/obvious change
249+
250+
In rare cases the change is trivial (e.g. fixing a typo in a `Readme.md`).
251+
Scripts still require a `#### Testing` section however you can be brief like
252+
`N/A` or `checked new URL opens`. Note that these cases are rare - e.g.
253+
fixing a typo in an ID still requires some description on how you checked
254+
that the new ID takes effect.
255+
163256
### Review Requirements
164257

165258
#### Documentation Best Practices

0 commit comments

Comments
 (0)