1.. _contributor-expectations: 2 3Contributor Expectations 4######################## 5 6The Zephyr project encourages :ref:`contributors <contributor>` to submit 7changes as smaller pull requests. Smaller pull requests (PRs) have the following 8benefits: 9 10- Reviewed more quickly and reviewed more thoroughly. It's easier for reviewers 11 to set aside a few minutes to review smaller changes several times than it is 12 to allocate large blocks of time to review a large PR. 13 14- Less wasted work if reviewers or maintainers reject the direction of the 15 change. 16 17- Easier to rebase and merge. Smaller PRs are less likely to conflict with other 18 changes in the tree. 19 20- Easier to revert if the PR breaks functionality. 21 22.. note:: 23 This page does not apply to draft PRs which can have any size, any number of 24 commits and any combination of smaller PRs for testing and preview purposes. 25 Draft PRs have no review expectation and PRs created as drafts from the start 26 do not notify anyone by default. 27 28 29Defining Smaller PRs 30******************** 31 32- Smaller PRs should encompass one self-contained logical change. 33 34- When adding a new large feature or API, the PR should address only one part of 35 the feature. In this case create an :ref:`RFC proposal <rfcs>` to describe the 36 additional parts of the feature for reviewers. 37 38- PRs should include tests or samples under the following conditions: 39 40 - Adding new features or functionality. 41 42 - Modifying a feature, especially for API behavior contract changes. 43 44 - Fixing a hardware agnostic bug. The test should fail without the bug fixed 45 and pass with the fix applied. 46 47- PRs must update any documentation affected by a functional code change. 48 49- If introducing a new API, the PR must include an example usage of the API. 50 This provides context to the reviewer and prevents submitting PRs with unused 51 APIs. 52 53 54Multiple Commits on a Single PR 55******************************* 56 57Contributors are further encouraged to break up PRs into multiple commits. Keep 58in mind each commit in the PR must still build cleanly and pass all the CI 59tests. 60 61For example, when introducing an extension to an API, contributors can break up 62the PR into multiple commits targeting these specific changes: 63 64#. Introduce the new APIs, including shared devicetree bindings 65#. Update driver implementation X, with driver specific devicetree bindings 66#. Update driver implementation Y 67#. Add tests for the new API 68#. Add a sample using the API 69#. Update the documentation 70 71Large Changes 72************* 73 74Large changes to the Zephyr project must submit an :ref:`RFC proposal <rfcs>` 75describing the full scope of change and future work. The RFC proposal provides 76the required context to reviewers, but allows for smaller, incremental, PRs to 77get reviewed and merged into the project. The RFC should also define the minimum 78viable implementation. 79 80Changes which require an RFC proposal include: 81 82- Submitting a new feature. 83- Submitting a new API. 84- :ref:`treewide-changes`. 85- Other large changes that can benefit from the RFC proposal process. 86 87Maintainers have the discretion to request that contributors create an RFC for 88PRs that are too large or complicated. 89 90PR Requirements 91*************** 92 93- Each commit in the PR must provide a commit message following the 94 :ref:`commit-guidelines`. 95 96- The PR description must include a summary of the changes and their rationales. 97 98- All files in the PR must comply with :ref:`Licensing 99 Requirements<licensing_requirements>`. 100 101- Follow the Zephyr :ref:`coding_style` and :ref:`coding_guidelines`. 102 103- PRs must pass all CI checks. This is a requirement to merge the PR. 104 Contributors may mark a PR as draft and explicitly request reviewers to 105 provide early feedback, even with failing CI checks. 106 107- When breaking a PR into multiple commits, each commit must build cleanly. The 108 CI system does not enforce this policy, so it is the PR author's 109 responsibility to verify. 110 111- When major new functionality is added, tests for the new functionality shall 112 be added to the automated test suite. All API functions should have test cases 113 and there should be tests for the behavior contracts of the API. Maintainers 114 and reviewers have the discretion to determine if the provided tests are 115 sufficient. The examples below demonstrate best practices on how to test APIs 116 effectively. 117 118 - :zephyr_file:`Kernel timer tests <tests/kernel/timer/timer_behavior>` 119 provide around 85% test coverage for the 120 :zephyr_file:`kernel timer <kernel/timer.c>`, measured by lines of code. 121 - Emulators for off-chip peripherals are an effective way to test driver 122 APIs. The :zephyr_file:`fuel gauge tests <tests/drivers/fuel_gauge/sbs_gauge>` 123 use the :zephyr_file:`smart battery emulator <drivers/fuel_gauge/sbs_gauge/emul_sbs_gauge.c>`, 124 providing test coverage for the 125 :zephyr_file:`fuel gauge API <include/zephyr/drivers/fuel_gauge.h>` 126 and the :zephyr_file:`smart battery driver <drivers/fuel_gauge/sbs_gauge/sbs_gauge.c>`. 127 - Code coverage reports for the Zephyr project are available on `Codecov`_. 128 129- Incompatible changes to APIs must also update the release notes for the 130 next release detailing the change. APIs marked as experimental are excluded 131 from this requirement. 132 133- Changes to APIs must increment the API version number according to the API 134 version rules. 135 136- PRs must also satisfy all :ref:`merge_criteria` before a member of the release 137 engineering team merges the PR into the zephyr tree. 138 139Maintainers may request that contributors break up a PR into smaller PRs and may 140request that they create an :ref:`RFC proposal <rfcs>`. 141 142.. _`Codecov`: https://app.codecov.io/gh/zephyrproject-rtos/zephyr 143 144Workflow Suggestions That Help Reviewers 145======================================== 146 147- Unless they applied the reviewer's recommendation exactly, authors must not 148 resolve and hide comments, they must let the initial reviewer do it. The 149 Zephyr project does not require all comments to be resolved before merge. 150 Leaving some completed discussions open can sometimes be useful to understand 151 the greater picture. 152 153- Respond to comments using the "Start Review" and "Add Review" green buttons in 154 the "Files changed" view. This allows responding to multiple comments and 155 publishing the responses in bulk. This reduces the number of emails sent to 156 reviewers. 157 158- As GitHub does not implement |git range-diff|_, try to minimize rebases in the 159 middle of a review. If a rebase is required, push this as a separate update 160 with no other changes since the last push of the PR. When pushing a rebase 161 only, add a comment to the PR indicating which commit is the rebase. 162 163.. |git range-diff| replace:: ``git range-diff`` 164.. _`git range-diff`: https://git-scm.com/docs/git-range-diff 165 166Getting PRs Reviewed 167==================== 168 169The Zephyr community is a diverse group of individuals, with different levels of 170commitment and priorities. As such, reviewers and maintainers may not get to a 171PR right away. 172 173The `Zephyr Dev Meeting`_ performs a triage of PRs missing reviewer approval, 174following this process: 175 176#. Identify and update PRs missing an Assignee. 177#. Identify PRs without any comments or reviews, ping the PR Assignee to start a 178 review or assign to a different maintainer. 179#. For PRs that have otherwise stalled, the Zephyr Dev Meeting pings the 180 Assignee and any reviewers that have left comments on the PR. 181 182Contributors may request PRs to be reviewed outside of the Zephyr Dev Meeting 183triage process as follows: 184 185- After 1 week of inactivity, ping the Assignee or reviewers on the PR by adding 186 a comment to the PR. 187 188- After 2 weeks of inactivity, post a message on the `#pr-help`_ channel on 189 Discord linking to the PR. 190 191- After 2 weeks of inactivity, add the `dev-review`_ label to the PR. This 192 explicitly adds the PR to the agenda for the next `Zephyr Dev Meeting`_ 193 independent of the triage process. Not all contributors have the required 194 privileges to add labels to PRs, in this case the contributor should request 195 help on Discord or send an email to the `Zephyr devel mailing list`_. 196 197Note that for new PRs, contributors should generally wait for at least one 198Zephyr Dev Meeting before making a request themselves. 199 200.. _Zephyr devel mailing list: https://lists.zephyrproject.org/g/devel 201 202 203.. _pr_technical_escalation: 204 205PR Technical Escalation 206======================= 207 208In cases where a contributor objects to change requests from reviewers, Zephyr 209defines the following escalation process for resolving technical disagreements. 210 211Before escalation of technical disagreements, follow the steps below: 212 213- Resolve in the PR among assignee, maintainers and reviewer. 214 215 - Assignee to act as moderator if applicable. 216 217- Optionally resolve in the next `Zephyr Dev Meeting`_ meeting with more 218 Maintainers and project stakeholders. 219 220 - The involved parties and the Assignee to be present when the issue is 221 discussed. 222 223- If no progress is made, the assignee (maintainer) has the right to dismiss 224 stale, unrelated or irrelevant change requests by reviewers giving the 225 reviewers a minimum of 1 business day to respond and revisit their initial 226 change requests or start the escalation process. 227 228 The assignee has the responsibility to document the reasoning for dismissing 229 any reviews in the PR and should notify the reviewer about their review being 230 dismissed. 231 232 To give the reviewers time to respond and escalate, the assignee is 233 expected to block the PR from being merged either by not 234 approving the PR or by setting the *DNM* label. 235 236Escalation can be triggered by any party participating in the review 237process (assignee, reviewers or the original author of the change) following 238the steps below: 239 240- Escalate to the `Architecture Working Group`_ by adding the `Architecture 241 Review` label on the PR. Beside the weekly meeting where such escalations are 242 processed, the `Architecture Working Group`_ shall facilitate an offline 243 review of the escalation if requested, especially if any of the parties can't 244 attend the meeting. 245 246- If all avenues of resolution and escalation have failed, assignees can escalate 247 to the TSC and get a binding resolution in the TSC by adding the *TSC* label 248 on the PR. 249 250- The Assignee is expected to ensure the resolution of the escalation and the 251 outcome is documented in the related pull request or issues on Github. 252 253.. _#pr-help: https://discord.com/channels/720317445772017664/997527108844798012 254 255.. _dev-review: https://github.com/zephyrproject-rtos/zephyr/labels/dev-review 256 257.. _Zephyr Dev Meeting: https://github.com/zephyrproject-rtos/zephyr/wiki/Zephyr-Committee-and-Working-Groups#zephyr-dev-meeting 258 259.. _Architecture Project: https://github.com/zephyrproject-rtos/zephyr/projects/18 260 261.. _Architecture Working Group: https://github.com/zephyrproject-rtos/zephyr/wiki/Architecture-Working-Group 262 263 264.. _reviewer-expectations: 265 266Reviewer Expectations 267********************* 268 269- Be respectful when commenting on PRs. Refer to the Zephyr `Code of Conduct`_ 270 for more details. 271 272- The Zephyr Project recognizes that reviewers and maintainers have limited 273 bandwidth. As a reviewer, prioritize review requests in the following order: 274 275 #. PRs related to items in the `Zephyr Release Plan`_ or those targeting 276 the next release during the stabilization period (after RC1). 277 #. PRs where the reviewer has requested blocking changes. 278 #. PRs assigned to the reviewer as the area maintainer. 279 #. All other PRs. 280 281- Reviewers shall strive to advance the PR to a mergeable state with their 282 feedback and engagement with the PR author. 283 284- Try to provide feedback on the entire PR in one shot. This provides the 285 contributor an opportunity to address all comments in the next PR update. 286 287- Partial reviews are permitted, but the reviewer must add a comment indicating 288 what portion of the PR they reviewed. Examples of useful partial reviews 289 include: 290 291 - Domain specific reviews (e.g. Devicetree). 292 - Code style changes that impact the readability of the PR. 293 - Reviewing commits separately when the requested changes cascade into the 294 later commits. 295 296- Avoid increasing scope of the PR by requesting new features, especially when 297 there is a corresponding :ref:`RFC <rfcs>` associated with the PR. Instead, 298 reviewers should add suggestions as a comment to the :ref:`RFC <rfcs>`. This 299 also encourages more collaboration as it is easier for multiple contributors 300 to work on a feature once the minimum implementation has merged. 301 302- When using the "Request Changes" option, mark trivial, non-functional, 303 requests as "Non-blocking" in the comment. Reviewers should approve PRs once 304 only non-blocking changes remain. The PR author has discretion as to whether 305 they address all non-blocking comments. PR authors should acknowledge every 306 review comment in some way, even if it's just with an emoticon. 307 308- Reviewers shall be *clear* and *concise* what changes they are requesting when the 309 "Request Changes" option is used. Requested changes shall be in the scope of 310 the PR in question and following the contribution and style guidelines of the 311 project. 312 313- Reviewers shall not close a PR due to technical or structural disagreement. 314 If requested changes cannot be resolved within the review process, the 315 :ref:`pr_technical_escalation` path shall be used for any potential resolution 316 path, which may include closing the PR. 317 318.. _Code of Conduct: https://github.com/zephyrproject-rtos/zephyr/blob/main/CODE_OF_CONDUCT.md 319 320.. _Zephyr Release Plan: https://github.com/orgs/zephyrproject-rtos/projects/13 321