Part 1
요약·해설
Apache 2.0과 DCO, source tree, Pull Request와 commit message, coding style, CI와 Coverity, fork·rebase workflow, RFC·treewide change와 특수 driver 요구 사항을 다룹니다.
License · DCO · Origin
Style · CI · Analysis
PR · Review · RFC
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
3DF686F6691D0CC9C851BA1EAD408DE4972483CCD01FA7D2A22699738D971EC3
.. _contribute_guidelines:
Contribution Guidelines
#######################
As an open-source project, we welcome and encourage the community to submit
patches directly to the project. In our collaborative open source environment,
standards and methods for submitting changes help reduce the chaos that can result
from an active development community.
This document explains how to participate in project conversations, log bugs
and enhancement requests, and submit patches to the project so your patch will
be accepted quickly in the codebase.
.. _licensing_requirements:
Licensing
*********
Licensing is very important to open source projects. It helps ensure the
software continues to be available under the terms that the author desired.
.. _Apache 2.0 license:
https://github.com/zephyrproject-rtos/zephyr/blob/main/LICENSE
.. _GitHub repo: https://github.com/zephyrproject-rtos/zephyr
Zephyr uses the `Apache 2.0 license`_ (as found in the LICENSE file in
the project's `GitHub repo`_) to strike a balance between open
contribution and allowing you to use the software however you would like
to. The Apache 2.0 license is a permissive open source license that
allows you to freely use, modify, distribute and sell your own products
that include Apache 2.0 licensed software. (For more information about
this, check out articles such as `Why choose Apache 2.0 licensing`_ and
`Top 10 Apache License Questions Answered`_).
.. _Why choose Apache 2.0 licensing:
https://www.zephyrproject.org/faqs/#1571346989065-9216c551-f523
.. _Top 10 Apache License Questions Answered:
https://www.whitesourcesoftware.com/whitesource-blog/top-10-apache-license-questions-answered/
A license tells you what rights you have as a developer, as provided by the
copyright holder. It is important that the contributor fully understands the
licensing rights and agrees to them. Sometimes the copyright holder isn't the
contributor, such as when the contributor is doing work on behalf of a
company.
Components using other Licenses
===============================
There are some imported or reused components of the Zephyr project that
use other licensing, as described in :ref:`Zephyr_Licensing`.
Importing code into the Zephyr OS from other projects that use a license
other than the Apache 2.0 license needs to be fully understood in
context and approved by the Zephyr governing board.
By carefully reviewing potential contributions and also enforcing a
:ref:`DCO` for contributed code, we can ensure that
the Zephyr community can develop products with the Zephyr Project
without concerns over patent or copyright issues.
See :ref:`external-contributions` for more information about
this contributing and review process for imported components.
.. only:: latex
.. toctree::
:maxdepth: 1
../LICENSING.rst
.. _copyrights:
Copyrights Notices
*******************
Please follow this `Community Best Practice`_ for Copyright Notices from the
Linux Foundation.
.. _Community Best Practice:
https://www.linuxfoundation.org/blog/copyright-notices-in-open-source-software-projects/
.. _DCO:
Developer Certification of Origin (DCO)
***************************************
To make a good faith effort to ensure licensing criteria are met, the Zephyr
project requires the Developer Certificate of Origin (DCO) process to be
followed.
The DCO is an attestation attached to every contribution made by every
developer. In the commit message of the contribution, (described more fully
later in this document), the developer simply adds a ``Signed-off-by``
statement and thereby agrees to the DCO.
When a developer submits a patch, it is a commitment that the contributor has
the right to submit the patch per the license. The DCO agreement is shown
below and at http://developercertificate.org/.
.. code-block:: none
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the
best of my knowledge, is covered under an appropriate open
source license and I have the right under that license to
submit that work with modifications, whether created in whole
or in part by me, under the same open source license (unless
I am permitted to submit under a different license), as
Indicated in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including
all personal information I submit with it, including my
sign-off) is maintained indefinitely and may be redistributed
consistent with this project or the open source license(s)
involved.
DCO Sign-Off
============
The "sign-off" in the DCO is a "Signed-off-by:" line in each commit's log
message. The Signed-off-by: line must be in the following format::
Signed-off-by: Your Name <[email protected]>
For your commits, replace:
- ``Your Name`` with your legal name (pseudonyms, hacker handles, and the
names of groups are not allowed)
- ``[email protected]`` with the same email address you are using to
author the commit (CI will fail if there is no match)
You can automatically add the Signed-off-by: line to your commit body using
``git commit -s``. Use other commits in the zephyr git history as examples.
See :ref:`git_setup` for instructions on configuring user and email settings
in Git.
Additional requirements:
- If you are altering an existing commit created by someone else, you must add
your Signed-off-by: line without removing the existing one.
- If you forget to add the Signed-off-by: line, you can add it to your previous
commit by running ``git commit --amend -s``.
- If you've pushed your changes to GitHub already you'll need to force push
your branch after this with ``git push -f``.
Notes
=====
Any contributions made as part of submitted pull requests are considered free
for the Project to use. Developers are permitted to cherry-pick patches that
are included in pull requests submitted by other contributors. It is expected
that
* the content of the patches will not be substantially modified,
* the cherry-picked commits or portions of a commit shall preserve the original
sign-off messages and the author identity.
:ref:`modifying_contributions` describes additional recommended policies
around working with contributions submitted by other developers.
Prerequisites
*************
.. _Zephyr Project website: https://zephyrproject.org
As a contributor, you'll want to be familiar with the Zephyr project, how to
configure, install, and use it as explained in the `Zephyr Project website`_
and how to set up your development environment as introduced in the Zephyr
:ref:`getting_started`.
You should be familiar with common developer tools such as Git and CMake, and
platforms such as GitHub.
If you haven't already done so, you'll need to create a (free) GitHub account
on https://github.com and have Git tools available on your development system.
.. note::
The Zephyr development workflow supports all 3 major operating systems
(Linux, macOS, and Windows) but some of the tools used in the sections below
are only available on Linux and macOS. On Windows, instead of running these
tools yourself, you will need to rely on the Continuous Integration (CI)
service using Github Actions, which runs automatically on GitHub when you submit
your Pull Request (PR). You can see any failure results in the workflow
details link near the end of the PR conversation list. See
`Continuous Integration`_ for more information
.. _source_tree_v2:
Source Tree Structure
*********************
To clone the main Zephyr Project repository use the instructions in
:ref:`get_the_code`.
This section describes the main repository's source tree. In addition to the
Zephyr kernel itself, you'll also find the sources for technical documentation,
sample code, supported board configurations, and a collection of subsystem
tests. All of these are available for developers to contribute to and enhance.
Understanding the Zephyr source tree can help locate the code
associated with a particular Zephyr feature.
At the top of the tree, several files are of importance:
:file:`CMakeLists.txt`
The top-level file for the CMake build system, containing a lot of the
logic required to build Zephyr.
:file:`Kconfig`
The top-level Kconfig file, which refers to the file :file:`Kconfig.zephyr`
also found in the top-level directory.
See :ref:`the Kconfig section of the manual <kconfig>` for detailed Kconfig
documentation.
:file:`west.yml`
The :ref:`west` manifest, listing the external repositories managed by
the west command-line tool.
The Zephyr source tree also contains the following top-level
directories, each of which may have one or more additional levels of
subdirectories not described here.
:file:`arch`
Architecture-specific kernel and system-on-chip (SoC) code.
Each supported architecture (for example, x86 and ARM)
has its own subdirectory,
which contains additional subdirectories for the following areas:
* architecture-specific kernel source files
* architecture-specific kernel include files for private APIs
:file:`soc`
SoC related code and configuration files.
:file:`boards`
Board related code and configuration files.
:file:`doc`
Zephyr technical documentation source files and tools used to
generate the https://docs.zephyrproject.org web content.
:file:`drivers`
Device driver code.
:file:`dts`
:ref:`devicetree <dt-guide>` source files used to describe non-discoverable
board-specific hardware details.
:file:`include`
Include files for all public APIs, except those defined under :file:`lib`.
:file:`kernel`
Architecture-independent kernel code.
:file:`lib`
Library code, including the minimal standard C library.
:file:`misc`
Miscellaneous code that doesn't belong to any of the other top-level
directories.
:file:`samples`
Sample applications that demonstrate the use of Zephyr features.
:file:`scripts`
Various programs and other files used to build and test Zephyr
applications.
:file:`cmake`
Additional build scripts needed to build Zephyr.
:file:`subsys`
Subsystems of Zephyr, including:
* USB device stack code
* Networking code, including the Bluetooth stack and networking stacks
* File system code
* Bluetooth host and controller
:file:`tests`
Test code and benchmarks for Zephyr features.
:file:`share`
Additional architecture independent data. It currently contains Zephyr's CMake
package.
Pull Requests and Issues
************************
.. _Zephyr Project Issues: https://github.com/zephyrproject-rtos/zephyr/issues
.. _open pull requests: https://github.com/zephyrproject-rtos/zephyr/pulls
.. _Zephyr devel mailing list: https://lists.zephyrproject.org/g/devel
.. _Zephyr Discord Server: https://chat.zephyrproject.org
Before starting on a patch, first check in our issues `Zephyr Project Issues`_
system to see what's been reported on the issue you'd like to address. Have a
conversation on the `Zephyr devel mailing list`_ (or the `Zephyr Discord
Server`_) to see what others think of your issue (and proposed solution). You
may find others that have encountered the issue you're finding, or that have
similar ideas for changes or additions. Send a message to the `Zephyr devel
mailing list`_ to introduce and discuss your idea with the development
community.
It's always a good practice to search for existing or related issues before
submitting your own. When you submit an issue (bug or feature request), the
triage team will review and comment on the submission, typically within a few
business days.
You can find all `open pull requests`_ on GitHub and open `Zephyr Project
Issues`_ in Github issues.
.. _git_setup:
Git Setup
*********
We need to know who you are, and how to contact you. To add this
information to your Git installation, set the Git configuration
variables ``user.name`` to your full name, and ``user.email`` to your
email address.
For example, if your name is ``Zephyr Developer`` and your email
address is ``[email protected]``:
.. code-block:: console
git config --global user.name "Zephyr Developer"
git config --global user.email "[email protected]"
Pull Request Guidelines
***********************
When opening a new Pull Request, adhere to the following guidelines to ensure
compliance with Zephyr standards and facilitate the review process.
If in doubt, it's advisible to explore existing Pull Requests within the Zephyr
repository. Use the search filters and labels to locate PRs related to changes
similar to the ones you are proposing.
.. _commit-guidelines:
Commit Message Guidelines
=========================
Changes are submitted as Git commits. Each commit has a *commit
message* describing the change. Acceptable commit messages look like
this:
.. code-block:: none
[area]: [summary of change]
[Commit message body (must be non-empty)]
Signed-off-by: [Your Full Name] <[your.email@address]>
You need to change text in square brackets (``[like this]``) above to
fit your commit.
Examples and more details follow.
Example
-------
Here is an example of a good commit message.
.. code-block:: none
drivers: sensor: abcd1234: fix bus I/O error handling
The abcd1234 sensor driver is failing to check the flags field in
the response packet from the device which signals that an error
occurred. This can lead to reading invalid data from the response
buffer. Fix it by checking the flag and adding an error path.
Signed-off-by: Zephyr Developer <[email protected]>
[area]: [summary of change]
---------------------------
This line is called the commit's *title*. Titles must be:
* one line
* less than 72 characters long
* followed by a completely blank line
[area]
The ``[area]`` prefix usually identifies the area of code
being changed. It can also identify the change's wider
context if multiple areas are affected.
Here are some examples:
* ``doc: ...`` for documentation changes
* ``drivers: foo:`` for ``foo`` driver changes
* ``Bluetooth: Shell:`` for changes to the Bluetooth shell
* ``net: ethernet:`` for Ethernet-related networking changes
* ``dts:`` for treewide devicetree changes
* ``style:`` for code style changes
If you're not sure what to use, try running ``git log FILE``, where
``FILE`` is a file you are changing, and using previous commits that
changed the same file as inspiration.
[summary of change]
The ``[summary of change]`` part should be a quick description of
what you've done. Here are some examples:
* ``doc: update wiki references to new site``
* ``drivers: sensor: sensor_shell: fix channel name collision``
Commit Message Body
-------------------
.. warning::
An empty commit message body is not permitted. Even for trivial
changes, please include a descriptive commit message body. Your
pull request will fail CI checks if you do not.
This part of the commit should explain what your change does, and why
it's needed. Be specific. A body that says ``"Fixes stuff"`` will be
rejected. Be sure to include the following as relevant:
* **what** the change does,
* **why** you chose that approach,
* **what** assumptions were made, and
* **how** you know it works -- for example, which tests you ran.
Each line in your commit message should usually be 75 characters or
less. Use newlines to wrap longer lines. Exceptions include lines
with long URLs, email addresses, etc.
For examples of accepted commit messages, you can refer to the Zephyr GitHub
`changelog <https://github.com/zephyrproject-rtos/zephyr/commits/main>`__.
Signed-off-by: ...
------------------
.. tip::
You should have set your :ref:`git_setup`
already. Create your commit with ``git commit -s`` to add the
Signed-off-by: line automatically using this information.
For open source licensing reasons, your commit must include a
Signed-off-by: line that looks like this:
.. code-block:: none
Signed-off-by: [Your Full Name] <[your.email@address]>
For example, if your full name is ``Zephyr Developer`` and your email
address is ``[email protected]``:
.. code-block:: none
Signed-off-by: Zephyr Developer <[email protected]>
This means that you have personally made sure your change complies
with the :ref:`DCO`. For this reason, you must use your legal name.
Pseudonyms or "hacker aliases" are not permitted.
Your name and the email address you use must match the name and email
in the Git commit's ``Author:`` field.
See the :ref:`contributor-expectations` for a more complete discussion of
contributor and reviewer expectations.
Adding links
------------
.. _GitHub references:
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls
Do not include `GitHub references`_ in the commit message directly, as it can
lose meaning in case the repository is forked, for example. Instead, if the
change addresses a specific GitHub issue, include in the Pull Request message a
line of the form:
.. code-block:: none
Fixes #[issue number]
Where ``[issue number]`` is the relevant GitHub issue's number. For
example:
.. code-block:: none
Fixes: #1234
You can point to other relevant information that can be found on the web using
:code:`Link:` tags. This includes, for example: GitHub issues, datasheets,
reference manuals, etc.
.. code-block:: none
Link: https://github.com/zephyrproject-rtos/zephyr/issues/<issue number>
.. _coding_style:
Coding Style
============
.. _Linux kernel coding style:
https://kernel.org/doc/html/latest/process/coding-style.html
In general, follow the `Linux kernel coding style`_, with the following
exceptions:
* The line length is 100 columns or fewer. In the documentation, longer lines
for URL references are an allowed exception.
* Add braces to every ``if``, ``else``, ``do``, ``while``, ``for`` and
``switch`` body, even for single-line code blocks. Use the ``--ignore BRACES``
flag to make *checkpatch* stop complaining.
* Use spaces instead of tabs to align comments after declarations, as needed.
* Use C89-style single line comments, ``/* */``. The C99-style single line
comment, ``//``, is not allowed.
* Use ``/** */`` for doxygen comments that need to appear in the documentation.
* Avoid using binary literals (constants starting with ``0b``).
* Avoid using non-ASCII symbols in code, unless it significantly improves
clarity, avoid emojis in any case.
Use these coding guidelines to ensure that your development complies with the
project's style and naming conventions.
The Linux kernel GPL-licensed tool ``checkpatch`` is used to check
coding style conformity.
.. note::
checkpatch does not currently run on Windows.
Checkpatch is available in the scripts directory. To invoke it when committing
code, make the file *$ZEPHYR_BASE/.git/hooks/pre-commit* executable and edit
it to contain:
.. code-block:: bash
#!/bin/sh
set -e exec
exec git diff --cached | ${ZEPHYR_BASE}/scripts/checkpatch.pl -
Instead of running checkpatch at each commit, you may prefer to run it only
before pushing on zephyr repo. To do this, make the file
*$ZEPHYR_BASE/.git/hooks/pre-push* executable and edit it to contain:
.. code-block:: bash
#!/bin/sh
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
echo "Run push hook"
while read local_ref local_sha remote_ref remote_sha
do
args="$remote $url $local_ref $local_sha $remote_ref $remote_sha"
exec ${ZEPHYR_BASE}/scripts/series-push-hook.sh $args
done
exit 0
If you want to override checkpatch verdict and push you branch despite reported
issues, you can add option --no-verify to the git push command.
A more complete alternative to this is using :ref:`check_compliance_py` script.
clang-format
------------
The `clang-format tool <https://clang.llvm.org/docs/ClangFormat.html>`_ can
be helpful to quickly reformat large amounts of new source code to our
`Coding Style`_ standards together with the ``.clang-format`` configuration file
provided in the repository. ``clang-format`` is well integrated into most
editors, but you can also run it manually like this:
.. code-block:: bash
clang-format -i my_source_file.c
``clang-format`` is part of LLVM, which can be downloaded from the project
`releases page <https://github.com/llvm/llvm-project/releases>`_. Note that if
you are a Linux user, ``clang-format`` will likely be available as a package in
your distribution repositories.
When there are differences between the `Coding Style`_ guidelines and the
formatting generated by code formatting tools, the `Coding Style`_ guidelines
take precedence. If there is ambiguity between formatting tools and the
guidelines, maintainers may decide which style should be adopted.
.. _Continuous Integration:
Continuous Integration (CI)
===========================
The Zephyr Project operates a Continuous Integration (CI) system that runs on
every Pull Request (PR) in order to verify several aspects of the PR:
* Git commit formatting
* Coding Style
* Twister builds for multiple architectures and boards
* Documentation build to verify any doc changes
CI is run on Github Actions and it uses the same tools described in the
`CI Tests`_ section. The CI results must be green indicating "All
checks have passed" before the Pull Request can be merged. CI is run when the
PR is created, and again every time the PR is modified with a commit.
The current status of the CI run can always be found at the bottom of the
GitHub PR page, below the review status. Depending on the success or failure
of the run you will see:
* "All checks have passed"
* "All checks have failed"
In case of failure you can click on the "Details" link presented below the
failure message in order to navigate to ``Github Actions`` and inspect the
results.
Once you click on the link you will be taken to the ``Github actions`` summary
results page where a table with all the different builds will be shown. To see
what build or test failed click on the row that contains the failed (i.e.
non-green) build.
.. _CI Tests:
Running CI Tests Locally
========================
.. _check_compliance_py:
check_compliance.py
-------------------
The ``check_compliance.py`` script serves as a valuable tool for assessing code
compliance with Zephyr's established guidelines and best practices. The script
acts as wrapper for a suite of tools that performs various checks, including
linters and formatters.
Developers are encouraged to run the script locally to validate their changes
before opening a new Pull Request:
.. code-block:: bash
./scripts/ci/check_compliance.py -c upstream/main..
twister
-------
.. note::
twister is only fully supported on Linux; on Windows and MacOS the execution
of tests is not supported, only building.
If you think your change may break some test, you can submit your PR as a draft
and let the project CI automatically run the :ref:`twister_script` for you.
If a test fails, you can check from the CI run logs how to rerun it locally,
for example:
.. code-block:: bash
west twister -p native_sim -s tests/drivers/build_all/sensor/sensors.generic_test
.. _static_analysis:
Static Code Analysis
********************
Coverity Scan is a free service for static code analysis of Open Source
projects. It is based on Coverity's commercial product and is able to analyze
C, C++ and Java code.
Coverity's static code analysis doesn't run the code. Instead of that it uses
abstract interpretation to gain information about the code's control flow and
data flow. It's able to follow all possible code paths that a program may take.
For example the analyzer understands that malloc() returns a memory that must
be freed with free() later. It follows all branches and function calls to see
if all possible combinations free the memory. The analyzer is able to detect
all sorts of issues like resource leaks (memory, file descriptors), NULL
dereferencing, use after free, unchecked return values, dead code, buffer
overflows, integer overflows, uninitialized variables, and many more.
The results are available on the `Coverity Scan
<https://scan.coverity.com/projects/zephyr>`_ website. In order to access the
results you have to create an account yourself. From the Zephyr project page,
you may select "Add me to project" to be added to the project. New members must
be approved by an admin.
Static analysis of the Zephyr codebase is conducted on a bi-weekly basis. GitHub
issues are automatically created for any issues detected by static analysis
tools. These issues will have the same (or equivalent) priority initially
defined by the tool.
To ensure accountability and efficient issue resolution, they are assigned to
the respective maintainer who is responsible for the affected code.
A dedicated team comprising members with expertise in static analysis, code
quality, and software security ensures the effectiveness of the static
analysis process and verifies that identified issues are properly
triaged and resolved in a timely manner.
Workflow
========
If after analyzing the Coverity report it is concluded that it is a false
positive please set the classification to either "False positive" or
"Intentional", the action to "Ignore", owner to your own account and add a
comment why the issue is considered false positive or intentional.
Update the related Github issue in the zephyr project with the details, and only close
it after completing the steps above on scan service website. Any issues
closed without a fix or without ignoring the entry in the scan service will be
automatically reopened if the issue continues to be present in the code.
.. _Contribution workflow:
Contribution Workflow
*********************
One general practice we encourage, is to make small,
controlled changes. This practice simplifies review, makes merging and
rebasing easier, and keeps the change history clear and clean.
When contributing to the Zephyr Project, it is also important you provide as much
information as you can about your change, update appropriate documentation,
and test your changes thoroughly before submitting.
The general GitHub workflow used by Zephyr developers uses a combination of
command line Git commands and browser interaction with GitHub. As it is with
Git, there are multiple ways of getting a task done. We'll describe a typical
workflow here:
.. _Create a Fork of Zephyr:
https://github.com/zephyrproject-rtos/zephyr#fork-destination-box
#. `Create a Fork of Zephyr`_
to your personal account on GitHub. (Click on the fork button in the top
right corner of the Zephyr project repo page in GitHub.)
#. On your development computer, change into the :file:`zephyr` folder that was
created when you :ref:`obtained the code <get_the_code>`::
cd zephyrproject/zephyr
Rename the default remote pointing to the `upstream repository
<https://github.com/zephyrproject-rtos/zephyr>`_ from ``origin`` to
``upstream``::
git remote rename origin upstream
Let Git know about the fork you just created, naming it ``origin``::
git remote add origin https://github.com/<your github id>/zephyr
and verify the remote repos::
git remote -v
The output should look similar to::
origin https://github.com/<your github id>/zephyr (fetch)
origin https://github.com/<your github id>/zephyr (push)
upstream https://github.com/zephyrproject-rtos/zephyr (fetch)
upstream https://github.com/zephyrproject-rtos/zephyr (push)
#. Create a topic branch (off of ``main``) for your work (if you're addressing
an issue, we suggest including the issue number in the branch name)::
git checkout main
git checkout -b fix_comment_typo
Some Zephyr subsystems do development work on a separate branch from
``main`` so you may need to indicate this in your checkout::
git checkout -b fix_out_of_date_patch origin/net
#. Make changes, test locally, change, test, test again, ... (Check out the
prior chapter on `twister`_ as well).
#. When things look good, start the pull request process by adding your changed
files::
git add [file(s) that changed, add -p if you want to be more specific]
You can see files that are not yet staged using::
git status
#. Verify changes to be committed look as you expected::
git diff --cached
#. Commit your changes to your local repo::
git commit -s
The ``-s`` option automatically adds your ``Signed-off-by:`` to your commit
message. Your commit will be rejected without this line that indicates your
agreement with the :ref:`DCO`. See the :ref:`commit-guidelines` section for
specific guidelines for writing your commit messages.
#. Push your topic branch with your changes to your fork in your personal
GitHub account::
git push origin fix_comment_typo
#. In your web browser, go to your forked repo and click on the
``Compare & pull request`` button for the branch you just worked on and
you want to open a pull request with.
#. Review the pull request changes, and verify that you are opening a pull
request for the ``main`` branch. The title and message from your commit
message should appear as well.
#. A bot will assign one or more suggested reviewers (based on the
MAINTAINERS file in the repo). If you are a project member, you can
select additional reviewers now too.
#. Click on the submit button and your pull request is sent and awaits
review. Email will be sent as review comments are made, or you can check
on your pull request at https://github.com/zephyrproject-rtos/zephyr/pulls.
.. note:: As more commits are merged upstream, the GitHub PR page will show
a ``This branch is out-of-date with the base branch`` message and a
``Update branch`` button on the PR page. That message should be ignored,
as the commits will be rebased as part of merging anyway, and triggering
a branch update from the GitHub UI will cause the PR approvals to be
dropped.
#. While you're waiting for your pull request to be accepted and merged, you
can create another branch to work on another issue. (Be sure to make your
new branch off of ``main`` and not the previous branch.)::
git checkout main
git checkout -b fix_another_issue
and use the same process described above to work on this new topic branch.
#. If reviewers do request changes to your patch, you can interactively rebase
commit(s) to fix review issues. In your development repo::
git rebase -i <offending-commit-id>^
In the interactive rebase editor, replace ``pick`` with ``edit`` to select
a specific commit (if there's more than one in your pull request), or
remove the line to delete a commit entirely. Then edit files to fix the
issues in the review.
As before, inspect and test your changes. When ready, continue the
patch submission::
git add [file(s)]
git rebase --continue
Update commit comment if needed, and continue::
git push --force origin fix_comment_typo
By force pushing your update, your original pull request will be updated
with your changes so you won't need to resubmit the pull request.
#. After pushing the requested change, check on the PR page if there is a
merge conflict. If so, rebase your local branch::
git fetch --all
git rebase --ignore-whitespace upstream/main
The ``--ignore-whitespace`` option stops ``git apply`` (called by rebase)
from changing any whitespace. Resolve the conflicts and push again::
git push --force origin fix_comment_typo
.. note:: While amending commits and force pushing is a common review model
outside GitHub, and the one recommended by Zephyr, it's not the main
model supported by GitHub. Forced pushes can cause unexpected behavior,
such as not being able to use "View Changes" buttons except for the last
one - GitHub complains it can't find older commits. You're also not
always able to compare the latest reviewed version with the latest
submitted version. When rewriting history GitHub only guarantees access
to the latest version.
#. If the CI run fails, you will need to make changes to your code in order
to fix the issues and amend your commits by rebasing as described above.
Additional information about the CI system can be found in
`Continuous Integration`_.
.. _contribution_tips:
Contribution Tips
=================
The following is a list of tips to improve and accelerate the review process of
Pull Requests. If you follow them, chances are your pull request will get the
attention needed and it will be ready for merge sooner than later:
.. _git-rebase:
https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---keep-base
#. When pushing follow-up changes, use the ``--keep-base`` option of
`git-rebase`_
#. On the PR page, check if the change can still be merged with no merge
conflicts
#. Make sure title of PR explains what is being fixed or added
#. Make sure your PR has a body with more details about the content of your
submission
#. Make sure you reference the issue you are fixing in the body of the PR
#. Watch early CI results immediately after submissions and fix issues as they
are discovered
#. Revisit PR after 1-2 hours to see the status of all CI checks, make sure all
is green
#. If you get request for changes and submit a change to address them, make
sure you click the "Re-request review" button on the GitHub UI to notify
those who asked for the changes
Submitting Proposals
====================
You can request a new feature or submit a proposal by submitting an issue to
our GitHub Repository.
If you would like to implement a new feature, please submit an issue with a
proposal (RFC) for your work first, to be sure that we can use it. Please
consider what kind of change it is:
* For a Major Feature, first open an issue and outline your proposal so that it
can be discussed. This will also allow us to better coordinate our efforts,
prevent duplication of work, and help you to craft the change so that it is
successfully accepted into the project. Providing the following information
will increase the chances of your issue being dealt with quickly:
* Overview of the Proposal
* Motivation for or Use Case
* Design Details
* Alternatives
* Test Strategy
* Small Features can be crafted and directly submitted as a Pull Request.
Identifying Contribution Origin
===============================
When adding a new file to the tree, it is important to detail the source of
origin on the file, provide attributions, and detail the intended usage. In
cases where the file is an original to Zephyr, the commit message should
include the following ("Original" is the assumption if no Origin tag is
present)::
Origin: Original
In cases where the file is :ref:`imported from an external project
<external-contributions>`, the commit message shall contain details regarding
the original project, the location of the project, the SHA-id of the origin
commit for the file and the intended purpose.
For example, a copy of a locally maintained import::
Origin: Contiki OS
License: BSD 3-Clause
URL: http://www.contiki-os.org/
commit: 853207acfdc6549b10eb3e44504b1a75ae1ad63a
Purpose: Introduction of networking stack.
For example, a copy of an externally maintained import in a module repository::
Origin: Tiny Crypt
License: BSD 3-Clause
URL: https://github.com/01org/tinycrypt
commit: 08ded7f21529c39e5133688ffb93a9d0c94e5c6e
Purpose: Introduction of TinyCrypt
Contributions to External Modules
**********************************
Follow the guidelines in the :ref:`modules` section for contributing
:ref:`new modules <submitting_new_modules>` and
submitting changes to :ref:`existing modules <changes_to_existing_module>`.
.. _treewide-changes:
Treewide Changes
****************
This section describes contributions that are treewide changes and some
additional associated requirements that apply to them. These requirements exist
to try to give such changes increased review and user visibility due to their
large impact.
Definition and Decision Making
==============================
A *treewide change* is defined as any change to Zephyr APIs, coding practices,
or other development requirements that either implies required changes
throughout the zephyr source code repository or can reasonably be expected to
do so for a wide class of external Zephyr-based source code.
This definition is informal by necessity. This is because the decision on
whether any particular change is treewide can be subjective and may depend on
additional context.
Project maintainers should use good judgement and prioritize the Zephyr
developer experience when deciding when a proposed change is treewide.
Protracted disagreements can be resolved by the Zephyr Project's Technical
Steering Committee (TSC), but please avoid premature escalation to the TSC.
Requirements for Treewide Changes
=================================
- The zephyr repository must apply the 'treewide' GitHub label to any issues or
pull requests that are treewide changes
- The person proposing a treewide change must create an `RFC issue
<https://github.com/zephyrproject-rtos/zephyr/issues/new?assignees=&labels=RFC&template=003_rfc-proposal.md&title=>`_
describing the change, its rationale and impact, etc. before any pull
requests related to the change can be merged
- The project's `Architecture Working Group (WG)
<https://github.com/zephyrproject-rtos/zephyr/wiki/Architecture-Working-Group>`_
must include the issue on the agenda and discuss whether the project will
accept or reject the change before any pull requests related to the change
can be merged (with escalation to the TSC if consensus is not reached at the
WG)
- The Architecture WG must specify the procedure for merging any PRs associated
with each individual treewide change, including any required approvals for
pull requests affecting specific subsystems or extra review time requirements
- The person proposing a treewide change must email
[email protected] about the RFC if it is accepted by the
Architecture WG before any pull requests related to the change can be merged
Examples
========
Some example past treewide changes are:
- the deprecation of version 1 of the :ref:`Logging API <logging_api>` in favor
of version 2 (see commit `262cc55609
<https://github.com/zephyrproject-rtos/zephyr/commit/262cc55609b73ea61b5f999c6c6daaba20bc5240>`_)
- the removal of support for a legacy :ref:`dt-bindings` syntax
(`6bf761fc0a
<https://github.com/zephyrproject-rtos/zephyr/commit/6bf761fc0a2811b037abec0c963d60b00c452acb>`_)
Note that adding a new version of a widely used API while maintaining
support for the old one is not a treewide change. Deprecation and removal of
such APIs, however, are treewide changes.
Specialized driver requirements
*******************************
Drivers for standalone devices should use the Zephyr bus APIs (SPI, I2C...)
whenever possible so that the device can be used with any SoC from any vendor
implementing a compatible bus.
If it is not technically possible to achieve full performance using the Zephyr
APIs due to specialized accelerators in a particular SoC family, one could
extend the support for an external device by providing a specialized path for
that SoC family. However, the driver must still provide a regular path (via
Zephyr APIs) for all other SoCs. Every exception must be approved by the
Architecture WG in order to be validated and potentially to be learned/improved
from.
Part 3
한국어 전문 번역
기여 지침
Zephyr는 open-source project이므로 community가 patch를 project에 직접 제출하는 것을 환영하고 권장합니다. 활발한 개발 community가 만들 수 있는 혼란을 줄이려면 협업 환경에서 변경 제출 기준과 방법을 함께 지켜야 합니다.
이 문서는 project 대화에 참여하고, bug와 개선 요청을 기록하고, patch가 codebase에 빠르게 수락되도록 제출하는 방법을 설명합니다.
License
License는 저자가 의도한 조건으로 software를 계속 이용할 수 있게 보장하므로 open-source project에서 매우 중요합니다.
Zephyr는 Apache 2.0 license를 사용합니다. 이 license는 열린 기여와 자유로운 software 이용 사이에서 균형을 잡는 permissive open-source license입니다. Apache 2.0 code를 포함한 자체 제품을 자유롭게 사용·수정·배포·판매할 수 있습니다. 자세한 배경은 Why choose Apache 2.0 licensing과 Top 10 Apache License Questions Answered를 참고하십시오.
License는 copyright holder가 developer에게 부여한 권리를 나타냅니다. Contributor는 그 권리를 완전히 이해하고 동의해야 합니다. 회사 업무로 기여할 때처럼 copyright holder와 contributor가 서로 다를 수도 있습니다.
다른 License를 사용하는 component
Zephyr가 가져오거나 재사용한 일부 component는 Zephyr licensing 문서에 설명된 다른 license를 사용합니다.
Apache 2.0이 아닌 license의 다른 project code를 Zephyr OS로 가져오려면 맥락을 완전히 이해하고 Zephyr governing board의 승인을 받아야 합니다.
잠재적 기여를 신중히 검토하고 기여 code에 DCO를 강제하면 Zephyr community가 patent나 copyright 문제를 걱정하지 않고 제품을 개발할 수 있습니다.
External component 기여에서 외부 component를 가져오는 기여와 review 절차를 자세히 설명합니다.
Copyright notice
Copyright notice에는 Linux Foundation의 Community Best Practice를 따르십시오.
Developer Certificate of Origin(DCO)
Zephyr project는 license 기준을 충족하기 위한 선의의 조치로 Developer Certificate of Origin(DCO) 절차를 요구합니다.
DCO는 모든 developer의 모든 기여에 붙는 확인 선언입니다. Developer는 commit message에 Signed-off-by 문장을 추가해 DCO에 동의합니다.
Patch를 제출한다는 것은 contributor가 해당 license에 따라 patch를 제출할 권리가 있음을 약속하는 것입니다. 다음은 developercertificate.org에 게시된 DCO 1.1 원문입니다.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the
best of my knowledge, is covered under an appropriate open
source license and I have the right under that license to
submit that work with modifications, whether created in whole
or in part by me, under the same open source license (unless
I am permitted to submit under a different license), as
Indicated in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including
all personal information I submit with it, including my
sign-off) is maintained indefinitely and may be redistributed
consistent with this project or the open source license(s)
involved.위 선언의 뜻은 다음과 같습니다.
- 기여를 전부 또는 일부 직접 만들었고 file에 표시된 open-source license로 제출할 권리가 있거나,
- 적절한 open-source license의 기존 작업을 바탕으로 했으며 같은 license 또는 허용된 다른 license로 수정본을 제출할 권리가 있거나,
- 위 조건을 인증한 다른 사람이 직접 제공한 기여를 수정하지 않고 전달했으며,
- Project와 기여가 공개되고 sign-off를 포함한 제출 기록이 영구 보존·재배포될 수 있음을 이해하고 동의한다는 뜻입니다.
DCO Sign-Off
DCO의 "sign-off"는 각 commit log message에 들어가는 Signed-off-by: 줄입니다. 형식은 다음과 같아야 합니다.
Signed-off-by: Your Name <[email protected]>Your Name에는 pseudonym, hacker handle, group name이 아닌 법적 이름을 넣습니다. [email protected]에는 commit author가 사용하는 것과 같은 email address를 넣어야 하며, 일치하지 않으면 CI가 실패합니다.
git commit -s를 사용하면 commit body에 Signed-off-by: 줄을 자동으로 추가할 수 있습니다. Zephyr Git history의 다른 commit을 예로 보고, Git 사용자 이름과 email 설정은 이 문서의 Git Setup 절을 참고하십시오.
추가 요구 사항:
- 다른 사람이 만든 기존 commit을 수정하면 그 사람의 sign-off를 지우지 말고 자신의 Signed-off-by 줄을 추가합니다.
Signed-off-by:를 빠뜨렸다면git commit --amend -s로 직전 commit에 추가할 수 있습니다.- 이미 GitHub에 push했다면 이후
git push -f로 branch를 force push해야 합니다.
참고 사항
제출된 Pull Request에 포함된 기여는 Project가 자유롭게 사용할 수 있는 것으로 봅니다. Developer는 다른 contributor가 제출한 Pull Request의 patch를 cherry-pick할 수 있습니다. 다만 다음을 지켜야 합니다.
- Patch 내용은 실질적으로 크게 바꾸지 않습니다.
- Cherry-pick한 commit 또는 commit 일부는 원래 sign-off message와 author identity를 보존합니다.
Modifying Contributions는 다른 developer가 제출한 기여를 다룰 때 권장하는 추가 policy를 설명합니다.
사전 준비
Contributor는 Zephyr Project website와 Getting Started Guide를 통해 Zephyr project의 구성·설치·사용 방법과 개발 환경 설정을 익혀야 합니다.
Git, CMake 같은 일반 개발 도구와 GitHub 같은 platform에도 익숙해야 합니다.
GitHub 무료 계정을 만들고 개발 system에서 Git tool을 사용할 수 있게 준비하십시오.
Source tree 구조
Get the Code 절의 방법으로 main Zephyr Project repository를 clone합니다.
Main repository에는 Zephyr kernel뿐 아니라 기술 문서 source, sample code, 지원 board configuration, subsystem test 모음이 있습니다. 모두 developer가 기여하고 개선할 수 있습니다. Source tree 구조를 이해하면 특정 Zephyr feature와 관련된 code를 찾기 쉽습니다.
Tree 최상위의 중요한 file:
CMakeLists.txtZephyr를 build하는 데 필요한 많은 logic을 담은 최상위 CMake build system file입니다.
Kconfig최상위 Kconfig file이며 같은 최상위 directory의
Kconfig.zephyr를 참조합니다. 자세한 내용은 Kconfig manual을 참고하십시오.west.ymlWest command-line tool이 관리하는 외부 repository 목록을 담은 west manifest입니다.
Zephyr source tree의 주요 최상위 directory:
archArchitecture별 kernel과 SoC code입니다. x86, ARM 같은 각 지원 architecture에 하위 directory가 있고 architecture별 kernel source와 private API include file을 둡니다.
socSoC 관련 code와 configuration file입니다.
boardsBoard 관련 code와 configuration file입니다.
docZephyr 기술 문서 source와 docs.zephyrproject.org web content 생성 도구입니다.
driversDevice driver code입니다.
dts검색할 수 없는 board별 hardware detail을 설명하는 devicetree source입니다.
includelib아래 정의된 것을 제외한 모든 public API include file입니다.kernelArchitecture에 독립적인 kernel code입니다.
libMinimal standard C library를 포함한 library code입니다.
misc다른 최상위 directory에 속하지 않는 기타 code입니다.
samplesZephyr feature 사용법을 보여 주는 sample application입니다.
scriptsZephyr application build와 test에 사용하는 여러 program과 file입니다.
cmakeZephyr build에 필요한 추가 build script입니다.
subsysUSB device stack, Bluetooth host·controller, network stack, file system 등 Zephyr subsystem code입니다.
testsZephyr feature test code와 benchmark입니다.
shareArchitecture에 독립적인 추가 data이며 현재 Zephyr CMake package가 들어 있습니다.
Pull Request와 Issue
Patch 작업을 시작하기 전에 Zephyr Project Issues에서 같은 문제나 관련 보고가 있는지 찾으십시오. Zephyr devel mailing list 또는 Zephyr Discord Server에서 문제와 제안한 해법에 관한 의견을 나누면 비슷한 경험이나 아이디어를 가진 사람을 찾을 수 있습니다.
새 bug나 feature request를 내기 전 기존 관련 issue를 검색하는 것이 좋습니다. Issue를 제출하면 triage team이 보통 영업일 기준 며칠 안에 검토하고 comment합니다.
Open Pull Requests와 열린 Zephyr Project Issue는 GitHub에서 확인할 수 있습니다.
Git 설정
user.name에는 full name, user.email에는 연락할 email address를 설정해 Git이 contributor identity를 알 수 있게 합니다.
Zephyr Developer와 [email protected]을 사용하는 예:
git config --global user.name "Zephyr Developer"
git config --global user.email "[email protected]"Pull Request 지침
새 Pull Request를 열 때 Zephyr 기준을 충족하고 review를 원활하게 하려면 다음 지침을 따르십시오.
확신이 없으면 Zephyr repository의 기존 Pull Request를 살펴보고 search filter와 label로 제안 변경과 비슷한 PR을 찾는 것이 좋습니다.
Commit message 지침
변경은 Git commit으로 제출하며 각 commit에는 변경을 설명하는 commit message가 있습니다. 허용되는 기본 형식은 다음과 같습니다.
[area]: [summary of change]
[Commit message body (must be non-empty)]
Signed-off-by: [Your Full Name] <[your.email@address]>대괄호 안의 text를 실제 commit 내용에 맞게 바꾸십시오.
예시
좋은 commit message의 예:
drivers: sensor: abcd1234: fix bus I/O error handling
The abcd1234 sensor driver is failing to check the flags field in
the response packet from the device which signals that an error
occurred. This can lead to reading invalid data from the response
buffer. Fix it by checking the flag and adding an error path.
Signed-off-by: Zephyr Developer <[email protected]>[area]: [summary of change]
첫 줄은 commit의 title이며 한 줄, 72자 미만이어야 하고 완전히 빈 줄 하나가 뒤따라야 합니다.
[area]대개 변경한 code 영역을 식별합니다. 여러 영역에 영향을 주면 더 넓은 맥락을 나타낼 수도 있습니다. 예를 들어 documentation 변경은
doc: ...,foodriver 변경은drivers: foo:, Bluetooth shell은Bluetooth: Shell:, Ethernet network는net: ethernet:, tree 전체 devicetree 변경은dts:, style 변경은style:를 사용합니다. 무엇을 쓸지 모르겠다면git log FILE로 같은 file을 바꾼 이전 commit을 참고하십시오.[summary of change]수행한 작업을 빠르게 설명합니다. 예:
doc: update wiki references to new site,drivers: sensor: sensor_shell: fix channel name collision.
Commit message body
Body는 변경이 무엇을 하고 왜 필요한지 구체적으로 설명해야 합니다. 단순히 "Fixes stuff"라고 쓰면 거부됩니다. 관련되는 경우 다음 내용을 포함하십시오.
- 변경이 무엇을 하는지
- 왜 그 접근을 선택했는지
- 어떤 가정을 했는지
- 어떻게 동작을 확인했는지, 예를 들어 실행한 test
Commit message 각 줄은 보통 75자 이하로 작성하고 긴 줄은 newline으로 감쌉니다. 긴 URL이나 email address는 예외입니다.
수락된 예시는 Zephyr GitHub changelog를 참고하십시오.
Signed-off-by: ...
Open-source licensing을 위해 commit에는 다음 형식의 Signed-off-by 줄이 반드시 있어야 합니다.
Signed-off-by: [Your Full Name] <[your.email@address]>이름과 email 예:
Signed-off-by: Zephyr Developer <[email protected]>이 줄은 변경이 DCO를 준수하는지 직접 확인했다는 의미입니다. 법적 이름을 사용해야 하며 pseudonym이나 hacker alias는 허용되지 않습니다. 이름과 email address는 Git commit의 Author field와 일치해야 합니다.
Contributor Expectations는 contributor와 reviewer에게 기대하는 사항을 더 자세히 설명합니다.
Link 추가
GitHub reference는 repository를 fork하면 의미를 잃을 수 있으므로 commit message에 직접 넣지 마십시오. 변경이 특정 GitHub issue를 해결한다면 Pull Request message에 다음 형식의 줄을 넣습니다.
Fixes #[issue number]예:
Fixes: #1234GitHub issue, datasheet, reference manual처럼 web의 관련 정보는 Link: tag로 가리킬 수 있습니다.
Link: https://github.com/zephyrproject-rtos/zephyr/issues/<issue number>Coding style
일반적으로 Linux kernel coding style을 따르되 다음 예외를 적용합니다.
- 줄 길이는 100 column 이하입니다. Documentation의 긴 URL reference는 예외입니다.
if,else,do,while,for,switchbody에는 한 줄뿐이어도 brace를 넣습니다. checkpatch의 brace 경고는--ignore BRACES로 끕니다.- Declaration 뒤 comment 정렬에는 필요에 따라 tab 대신 space를 사용합니다.
/* */형태의 C89 single-line comment를 사용하며 C99//comment는 허용하지 않습니다.- Documentation에 나타나야 하는 Doxygen comment에는
/** */를 사용합니다. 0b로 시작하는 binary literal은 피합니다.- 명확성을 크게 높이지 않는 한 code에 non-ASCII symbol을 사용하지 말고 emoji는 항상 피합니다.
이 지침으로 project style과 naming convention을 준수하십시오. Linux kernel의 GPL license 도구 checkpatch가 coding style 적합성을 검사합니다.
Commit할 때 실행하려면 $ZEPHYR_BASE/.git/hooks/pre-commit file을 실행 가능하게 만들고 다음 내용을 넣습니다.
#!/bin/sh
set -e exec
exec git diff --cached | ${ZEPHYR_BASE}/scripts/checkpatch.pl -매 commit이 아니라 Zephyr repository에 push하기 전에만 실행하려면 $ZEPHYR_BASE/.git/hooks/pre-push를 실행 가능하게 만들고 다음 내용을 넣습니다.
#!/bin/sh
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
echo "Run push hook"
while read local_ref local_sha remote_ref remote_sha
do
args="$remote $url $local_ref $local_sha $remote_ref $remote_sha"
exec ${ZEPHYR_BASE}/scripts/series-push-hook.sh $args
done
exit 0Checkpatch가 문제를 보고해도 verdict를 무시하고 push하려면 git push에 --no-verify option을 추가할 수 있습니다. 더 완전한 대안은 뒤의 check_compliance.py script입니다.
clang-format
clang-format은 repository의 .clang-format configuration과 함께 많은 새 source code를 Zephyr coding style에 맞게 빠르게 format할 때 유용합니다. 대부분의 editor와 통합되며 직접 실행할 수도 있습니다.
clang-format -i my_source_file.cLLVM release page에서 내려받을 수 있고 Linux distribution에서는 package로 제공될 가능성이 큽니다.
Coding Style 지침과 formatting tool 결과가 다르면 지침이 우선합니다. 둘 사이가 모호하면 maintainer가 채택할 style을 결정할 수 있습니다.
Continuous Integration(CI)
Zephyr Project는 모든 Pull Request에서 CI를 실행해 다음을 검증합니다.
- Git commit format
- Coding style
- 여러 architecture와 board를 대상으로 한 Twister build
- Documentation 변경을 검증하는 문서 build
CI는 GitHub Actions에서 실행되며 아래 CI Tests 절과 같은 도구를 사용합니다. Pull Request를 merge하려면 결과가 녹색인 "All checks have passed" 상태여야 합니다. PR 생성 시와 commit으로 PR을 수정할 때마다 다시 실행됩니다.
GitHub PR page의 review 상태 아래에서 현재 CI 상태를 항상 확인할 수 있습니다. 성공하면 "All checks have passed", 실패하면 "All checks have failed"가 표시됩니다. 실패 message 아래 Details link를 누르면 GitHub Actions summary로 이동하며 build 표에서 녹색이 아닌 row를 눌러 실패한 build나 test를 조사할 수 있습니다.
CI test를 local에서 실행
check_compliance.py
check_compliance.py는 Zephyr 지침과 best practice에 맞는지 평가하는 도구입니다. 여러 linter와 formatter를 포함한 검사 suite를 감싸는 wrapper로 동작합니다.
새 Pull Request를 열기 전에 local에서 실행해 변경을 검증하는 것이 좋습니다.
./scripts/ci/check_compliance.py -c upstream/main..twister
변경이 test를 깨뜨릴 수 있다고 생각하면 draft PR을 제출해 project CI가 Twister를 자동 실행하게 할 수 있습니다.
Test가 실패하면 CI log에서 local 재실행 방법을 확인할 수 있습니다. 예:
west twister -p native_sim -s tests/drivers/build_all/sensor/sensors.generic_testStatic code analysis
Coverity Scan은 open-source project에 무료로 제공되는 static code analysis service입니다. Commercial Coverity 제품을 기반으로 C, C++, Java code를 분석합니다.
malloc()이 반환한 memory를 나중에 free()해야 한다는 관계처럼 code를 실행하지 않고 abstract interpretation으로 control flow와 data flow를 파악합니다. 가능한 모든 branch와 function call 조합을 따라 resource leak, NULL dereference, use-after-free, unchecked return value, dead code, buffer overflow, integer overflow, uninitialized variable 등을 찾습니다.
결과는 Coverity Scan Zephyr page에서 볼 수 있습니다. 계정을 만든 뒤 Zephyr project page에서 "Add me to project"를 선택하면 admin 승인을 거쳐 project에 추가됩니다.
Zephyr codebase static analysis는 격주로 수행합니다. 도구가 찾은 문제마다 GitHub issue가 자동 생성되고 처음에는 도구가 정한 것과 같거나 동등한 priority가 부여됩니다. Issue는 해당 code maintainer에게 배정됩니다.
Static analysis, code quality, software security 전문 팀이 process의 효과를 보장하고 발견한 문제를 적절히 triage해 제때 해결하는지 확인합니다.
Workflow
Coverity report를 분석해 false positive라고 판단했다면 classification을 "False positive" 또는 "Intentional", action을 "Ignore", owner를 자신의 account로 설정하고 그렇게 판단한 이유를 comment로 남깁니다.
Zephyr project의 관련 GitHub issue에도 detail을 갱신하고 scan service에서 위 절차를 끝낸 뒤에만 닫습니다. Fix 없이 닫거나 scan service entry를 ignore하지 않은 문제는 code에 계속 존재하면 자동으로 다시 열립니다.
기여 workflow
작고 통제된 변경을 만드는 것이 권장되는 일반 원칙입니다. Review를 단순하게 하고 merge와 rebase를 쉽게 하며 변경 history를 명확하고 깨끗하게 유지합니다.
변경에 관해 가능한 많은 정보를 제공하고 적절한 문서를 갱신하며 제출 전 충분히 test해야 합니다.
Zephyr developer가 쓰는 일반 GitHub workflow는 command-line Git과 browser의 GitHub interaction을 조합합니다. Git 작업 방법은 여러 가지이지만 대표 절차는 다음과 같습니다.
- Zephyr repository를 fork해 개인 GitHub account에 만듭니다. Repository page 오른쪽 위 Fork button을 누릅니다.
- Code를 받은 뒤 개발 computer에서
zephyrfolder로 이동합니다.
기본 upstream remote 이름을cd zephyrproject/zephyrorigin에서upstream으로 바꿉니다.
새 fork를git remote rename origin upstreamorigin으로 등록합니다.
Remote를 확인합니다.git remote add origin https://github.com/<your github id>/zephyr
결과는 다음과 비슷해야 합니다.git remote -vorigin https://github.com/<your github id>/zephyr (fetch) origin https://github.com/<your github id>/zephyr (push) upstream https://github.com/zephyrproject-rtos/zephyr (fetch) upstream https://github.com/zephyrproject-rtos/zephyr (push) main에서 작업용 topic branch를 만듭니다. Issue를 해결한다면 branch name에 issue 번호를 넣는 것이 좋습니다.
일부 subsystem이git checkout main git checkout -b fix_comment_typomain과 다른 branch에서 개발된다면 해당 branch를 지정합니다.git checkout -b fix_out_of_date_patch origin/net- 변경하고 local test하고 다시 변경하고 또 test합니다. 앞의 Twister 절도 참고하십시오.
- 준비되면 변경 file을 stage합니다.
아직 stage하지 않은 file은 다음으로 봅니다.git add [file(s) that changed, add -p if you want to be more specific]git status - Commit할 변경이 예상한 모습인지 확인합니다.
git diff --cached - Local repository에 commit합니다.
git commit -s-s는 DCO 동의를 나타내는Signed-off-by:를 자동으로 추가하며 이 줄이 없으면 commit이 거부됩니다. - Topic branch를 개인 GitHub fork에 push합니다.
git push origin fix_comment_typo - Browser에서 fork repository로 가서 작업 branch의
Compare & pull requestbutton을 누릅니다. mainbranch를 대상으로 PR을 여는지 확인하고 변경과 commit title·message를 검토합니다.- Bot이 repository의 MAINTAINERS file을 바탕으로 reviewer를 제안해 배정합니다. Project member라면 reviewer를 더 선택할 수 있습니다.
- Submit button을 누르면 PR이 review를 기다립니다. Review comment는 email로 오며 open Pull Requests에서도 확인할 수 있습니다.
- PR을 기다리는 동안 다른 issue용 branch를 만들 수 있습니다. 이전 topic branch가 아니라
main에서 새 branch를 만드십시오.git checkout main git checkout -b fix_another_issue - Reviewer가 변경을 요청하면 interactive rebase로 해당 commit을 고칩니다.
Editor에서 특정 commit의git rebase -i <offending-commit-id>^pick을edit로 바꾸거나 줄을 지워 commit 전체를 제거합니다. File을 수정하고 test한 뒤 계속합니다.
필요하면 commit comment를 갱신하고 force push합니다.git add [file(s)] git rebase --continue
기존 PR이 갱신되므로 다시 제출할 필요가 없습니다.git push --force origin fix_comment_typo - 변경 push 뒤 PR page에서 merge conflict를 확인합니다. Conflict가 있으면 local branch를 rebase합니다.
Conflict를 해결한 뒤 다시 push합니다.git fetch --all git rebase --ignore-whitespace upstream/maingit push --force origin fix_comment_typo - CI run이 실패하면 code를 고치고 위 rebase 절차로 commit을 amend해야 합니다. CI의 자세한 내용은 Continuous Integration 절을 참고하십시오.
기여 tip
Pull Request review를 빠르게 하고 merge 준비를 앞당기려면 다음을 따르십시오.
- 후속 변경을 push할 때 git-rebase의
--keep-baseoption을 사용합니다. - PR page에서 merge conflict 없이 여전히 merge 가능한지 확인합니다.
- PR title이 수정하거나 추가한 내용을 설명하는지 확인합니다.
- PR body에 제출 내용의 detail을 충분히 적습니다.
- PR body에서 해결하는 issue를 reference합니다.
- 제출 직후 초기 CI 결과를 보고 발견되는 문제를 바로 고칩니다.
- 1~2시간 뒤 PR을 다시 확인해 모든 CI check가 녹색인지 봅니다.
- 변경 요청을 해결해 새 변경을 제출했다면 GitHub UI에서 Re-request review button을 눌러 요청한 reviewer에게 알립니다.
제안 제출
GitHub repository에 issue를 제출해 새 feature를 요청하거나 제안할 수 있습니다. 새 feature를 구현하려면 먼저 proposal(RFC) issue를 열어 project가 사용할 수 있는 변경인지 확인하십시오.
- Major Feature는 먼저 issue를 열어 제안을 설명하고 토론합니다. 작업 중복을 막고 성공적으로 수락될 형태를 만드는 데 도움이 됩니다. 빠른 처리를 위해
- 제안 개요
- 동기 또는 use case
- Design detail
- 대안
- Test 전략
- Small Feature는 바로 만들고 Pull Request로 제출할 수 있습니다.
기여 origin 식별
Tree에 새 file을 추가할 때 file의 원래 source, attribution, 의도한 사용 방법을 자세히 밝혀야 합니다. Zephyr에서 처음 만든 file이면 commit message에 다음을 넣습니다. Origin tag가 없을 때도 Original로 간주합니다.
Origin: Original외부 project에서 가져온 file이면 원 project, project 위치, 원본 commit의 SHA-id, 의도한 목적을 commit message에 넣어야 합니다.
Local에서 유지보수하는 import copy 예:
Origin: Contiki OS
License: BSD 3-Clause
URL: http://www.contiki-os.org/
commit: 853207acfdc6549b10eb3e44504b1a75ae1ad63a
Purpose: Introduction of networking stack.Module repository에서 외부 유지보수하는 import copy 예:
Origin: Tiny Crypt
License: BSD 3-Clause
URL: https://github.com/01org/tinycrypt
commit: 08ded7f21529c39e5133688ffb93a9d0c94e5c6e
Purpose: Introduction of TinyCrypt외부 module 기여
Modules 절의 지침에 따라 새 module을 기여하거나 기존 module 변경을 제출하십시오.
Tree 전체 변경
이 절은 source tree 전체에 영향을 주는 기여와 그 추가 요구 사항을 설명합니다. 큰 영향 때문에 review와 사용자 visibility를 높이기 위한 규칙입니다.
정의와 의사 결정
Treewide change는 Zephyr API, coding practice, 기타 개발 요구 사항을 바꿔 Zephyr source repository 전체에 필수 변경을 일으키거나 많은 외부 Zephyr 기반 source code에도 그럴 가능성이 합리적으로 예상되는 변경입니다.
어떤 변경이 treewide인지 판단하는 일은 주관적이고 추가 맥락에 따라 달라질 수 있으므로 정의가 의도적으로 비형식적입니다.
Project maintainer는 좋은 판단을 사용하고 Zephyr developer experience를 우선해야 합니다. 오래 이어지는 의견 충돌은 Technical Steering Committee(TSC)가 해결할 수 있지만 너무 이른 TSC escalation은 피하십시오.
Tree 전체 변경 요구 사항
- Zephyr repository는 treewide change인 issue나 Pull Request에
treewideGitHub label을 적용해야 합니다. - 제안자는 관련 PR을 merge하기 전에 변경·근거·영향을 설명하는 RFC issue를 만들어야 합니다.
- Architecture Working Group은 관련 PR merge 전에 issue를 agenda에 넣고 project가 변경을 수락할지 논의해야 합니다. 합의하지 못하면 TSC로 올립니다.
- Architecture WG는 subsystem별 추가 승인이나 추가 review 기간을 포함해 각 treewide change 관련 PR을 merge하는 절차를 지정해야 합니다.
- Architecture WG가 RFC를 수락하면 제안자는 관련 PR merge 전에 [email protected]로 RFC를 알려야 합니다.
예시
과거 treewide change 예:
- Logging API version 1을 version 2로 대체하며 deprecate한 변경(commit 262cc55609)
- Legacy devicetree binding syntax 지원을 제거한 변경(commit 6bf761fc0a)
널리 쓰이는 API의 이전 version을 유지하면서 새 version을 추가하는 것만으로는 treewide change가 아닙니다. 하지만 그 API를 deprecate하거나 제거하는 것은 treewide change입니다.
특수 driver 요구 사항
Standalone device driver는 가능한 한 Zephyr bus API(SPI, I2C 등)를 사용해야 합니다. 그러면 compatible bus를 구현하는 어느 vendor의 SoC에서도 device를 사용할 수 있습니다.
특정 SoC family의 특수 accelerator 때문에 Zephyr API만으로 full performance를 낼 수 없다면 그 SoC family에 special path를 제공해 외부 device 지원을 확장할 수 있습니다. 그러나 다른 모든 SoC에는 Zephyr API를 통한 일반 path도 반드시 제공해야 합니다. 모든 예외는 Architecture WG 승인을 받아 검증하고 잠재적으로 배우거나 개선할 수 있게 해야 합니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.