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
90.. _pr_requirements:
91
92PR Requirements
93***************
94
95- Each commit in the PR must provide a commit message following the
96  :ref:`commit-guidelines`.
97
98- No fixup or merge commits are allowed, see :ref:`Contribution workflow` for
99  more information.
100
101- The PR description must include a summary of the changes and their rationales.
102
103- All files in the PR must comply with :ref:`Licensing
104  Requirements<licensing_requirements>`.
105
106- The code must follow the Zephyr :ref:`coding_style` and :ref:`coding_guidelines`.
107
108- The PR must pass all CI checks, as described in :ref:`merge_criteria`.
109  Contributors may mark a PR as draft and explicitly request reviewers to
110  provide early feedback, even with failing CI checks.
111
112- Commits in a pull request should represent clear, logical units of change that are easy to review
113  and maintain bisectability. The following guidelines expand on this principle:
114
115  1. Distinct, Logical Units of Change
116
117     Each commit should correspond to a self-contained, meaningful change. For example, adding a
118     feature, fixing a bug, or refactoring existing code should be separate commits. Avoid mixing
119     different types of changes (e.g., feature implementation and unrelated refactoring) in the same
120     commit.
121
122  2. Retain Bisectability
123
124     Every commit in the pull request must build successfully and pass all relevant tests. This
125     ensures that git bisect can be used effectively to identify the specific commit that introduced
126     a bug or issue.
127
128  3. Squash Intermediary or Non-Final Development History
129
130     During development, commits may include intermediary changes (e.g., partial implementations,
131     temporary files, or debugging code). These should be squashed or rewritten before submitting the
132     pull request. Remove non-final artifacts, such as:
133
134     * Temporary renaming of files that are later renamed again.
135     * Code that was rewritten or significantly changed in later commits.
136
137  4. Ensure Clean History Before Submission
138
139     Use interactive rebasing (git rebase -i) to clean up the commit history before submitting the
140     pull request. This helps in:
141
142     * Squashing small, incomplete commits into a single cohesive commit.
143     * Ensuring that each commit remains bisectable.
144     * Maintaining proper attribution of authorship while improving clarity.
145
146  5. Renaming and Code Rewrites
147
148     If files or code are renamed or rewritten in later commits during development, squash or rewrite
149     earlier commits to reflect the final structure. This ensures that:
150
151     * The history remains clean and easy to follow.
152     * Bisectability is preserved by eliminating redundant renaming or partial rewrites.
153
154  6. Attribution of Authorship
155
156     While cleaning up the commit history, ensure that authorship attribution remains accurate.
157
158  7. Readable and Reviewable History
159
160     The final commit history should be easy to understand for future maintainers. Logical units of
161     change should be grouped into commits that tell a clear, coherent story of the work done.
162
163- When major new functionality is added, tests for the new functionality shall
164  be added to the automated test suite. All API functions should have test cases
165  and there should be tests for the behavior contracts of the API. Maintainers
166  and reviewers have the discretion to determine if the provided tests are
167  sufficient. The examples below demonstrate best practices on how to test APIs
168  effectively.
169
170    - :zephyr_file:`Kernel timer tests <tests/kernel/timer/timer_behavior>`
171      provide around 85% test coverage for the
172      :zephyr_file:`kernel timer <kernel/timer.c>`, measured by lines of code.
173    - Emulators for off-chip peripherals are an effective way to test driver
174      APIs. The :zephyr_file:`fuel gauge tests <tests/drivers/fuel_gauge/sbs_gauge>`
175      use the :zephyr_file:`smart battery emulator <drivers/fuel_gauge/sbs_gauge/emul_sbs_gauge.c>`,
176      providing test coverage for the
177      :zephyr_file:`fuel gauge API <include/zephyr/drivers/fuel_gauge.h>`
178      and the :zephyr_file:`smart battery driver <drivers/fuel_gauge/sbs_gauge/sbs_gauge.c>`.
179    - Code coverage reports for the Zephyr project are available on `Codecov`_.
180
181- Incompatible changes to APIs must also update the release notes for the
182  next release detailing the change.  APIs marked as experimental are excluded
183  from this requirement.
184
185- Changes to APIs must increment the API version number according to the API
186  version rules.
187
188- Documentation must be added and/or updated to reflect the changes in the code
189  introduced by the PR. The documentation changes must use the proper
190  terminology as present in the existing pages, and must be written in American
191  English. If you include images as part of the documentation, those must follow
192  the rules in :ref:`doc_images`. Please refer to :ref:`doc_guidelines` for
193  additional information.
194
195- PRs must also satisfy all :ref:`merge_criteria` before a member of the release
196  engineering team merges the PR into the zephyr tree.
197
198Maintainers may request that contributors break up a PR into smaller PRs and may
199request that they create an :ref:`RFC proposal <rfcs>`.
200
201.. _`Codecov`: https://app.codecov.io/gh/zephyrproject-rtos/zephyr
202
203Workflow Suggestions That Help Reviewers
204========================================
205
206- Unless they applied the reviewer's recommendation exactly, authors must not
207  resolve and hide comments, they must let the initial reviewer do it. The
208  Zephyr project does not require all comments to be resolved before merge.
209  Leaving some completed discussions open can sometimes be useful to understand
210  the greater picture.
211
212- Respond to comments using the "Start Review" and "Add Review" green buttons in
213  the "Files changed" view. This allows responding to multiple comments and
214  publishing the responses in bulk. This reduces the number of emails sent to
215  reviewers.
216
217- As GitHub does not implement |git range-diff|_, try to minimize rebases in the
218  middle of a review. If a rebase is required, push this as a separate update
219  with no other changes since the last push of the PR. When pushing a rebase
220  only, add a comment to the PR indicating which commit is the rebase.
221
222.. |git range-diff| replace:: ``git range-diff``
223.. _`git range-diff`: https://git-scm.com/docs/git-range-diff
224
225Getting PRs Reviewed
226====================
227
228The Zephyr community is a diverse group of individuals, with different levels of
229commitment and priorities. As such, reviewers and maintainers may not get to a
230PR right away.
231
232The `Zephyr Dev Meeting`_ performs a triage of PRs missing reviewer approval,
233following this process:
234
235#. Identify and update PRs missing an Assignee.
236#. Identify PRs without any comments or reviews, ping the PR Assignee to start a
237   review or assign to a different maintainer.
238#. For PRs that have otherwise stalled, the Zephyr Dev Meeting pings the
239   Assignee and any reviewers that have left comments on the PR.
240
241Contributors may request PRs to be reviewed outside of the Zephyr Dev Meeting
242triage process as follows:
243
244- After 1 week of inactivity, ping the Assignee or reviewers on the PR by adding
245  a comment to the PR.
246
247- After 2 weeks of inactivity, post a message on the `#pr-help`_ channel on
248  Discord linking to the PR.
249
250- After 2 weeks of inactivity, add the `dev-review`_ label to the PR. This
251  explicitly adds the PR to the agenda for the next `Zephyr Dev Meeting`_
252  independent of the triage process. Not all contributors have the required
253  privileges to add labels to PRs, in this case the contributor should request
254  help on Discord or send an email to the `Zephyr devel mailing list`_.
255
256Note that for new PRs, contributors should generally wait for at least one
257Zephyr Dev Meeting before making a request themselves.
258
259.. _Zephyr devel mailing list: https://lists.zephyrproject.org/g/devel
260
261
262.. _pr_technical_escalation:
263
264PR Technical Escalation
265=======================
266
267In cases where a contributor objects to change requests from reviewers, Zephyr
268defines the following escalation process for resolving technical disagreements.
269
270Before escalation of technical disagreements, follow the steps below:
271
272- Resolve in the PR among assignee, maintainers and reviewer.
273
274  - Assignee to act as moderator if applicable.
275
276- Optionally resolve in the next `Zephyr Dev Meeting`_  meeting with more
277  Maintainers and project stakeholders.
278
279  - The involved parties and the Assignee to be present when the  issue is
280    discussed.
281
282- If no progress is made, the assignee (maintainer) has the right to dismiss
283  stale, unrelated or irrelevant change requests by reviewers giving the
284  reviewers a minimum of 1 business day to respond and revisit their initial
285  change requests or start the escalation process.
286
287  The assignee has the responsibility to document the reasoning for dismissing
288  any reviews in the PR and should notify the reviewer about their review being
289  dismissed.
290
291  To give the reviewers time to respond and escalate, the assignee is
292  expected to block the PR from being merged either by not
293  approving the PR or by setting the *DNM* label.
294
295Escalation can be triggered by any party participating in the review
296process (assignee, reviewers or the original author of the change) following
297the steps below:
298
299- Escalate to the `Architecture Working Group`_ by adding the `Architecture
300  Review` label on the PR. Beside the weekly meeting where such escalations are
301  processed, the `Architecture Working Group`_  shall facilitate an offline
302  review of the escalation if requested, especially if any of the parties can't
303  attend the meeting.
304
305- If all avenues of resolution and escalation have failed, assignees can escalate
306  to the TSC and get a binding resolution in the TSC by adding the *TSC* label
307  on the PR.
308
309- The Assignee is expected to ensure the resolution of the escalation and the
310  outcome is documented in the related pull request or issues on Github.
311
312.. _#pr-help: https://discord.com/channels/720317445772017664/997527108844798012
313
314.. _dev-review: https://github.com/zephyrproject-rtos/zephyr/labels/dev-review
315
316.. _Zephyr Dev Meeting: https://github.com/zephyrproject-rtos/zephyr/wiki/Zephyr-Committee-and-Working-Groups#zephyr-dev-meeting
317
318.. _Architecture Project: https://github.com/zephyrproject-rtos/zephyr/projects/18
319
320.. _Architecture Working Group: https://github.com/zephyrproject-rtos/zephyr/wiki/Architecture-Working-Group
321