2012-10-14 11:27:04 -04:00
|
|
|
.. _devguide_workflow:
|
2012-10-13 21:29:48 -04:00
|
|
|
|
|
|
|
|
====================
|
|
|
|
|
Development Workflow
|
|
|
|
|
====================
|
|
|
|
|
|
2022-02-14 23:36:14 +00:00
|
|
|
Anyone wishing to make contributions to OpenMC should be fully acquainted and
|
2013-09-07 21:38:41 -04:00
|
|
|
comfortable working with git_ and GitHub_. We assume here that you have git
|
|
|
|
|
installed on your system, have a GitHub account, and have setup SSH keys to be
|
2015-02-16 20:08:35 -05:00
|
|
|
able to create/push to repositories on GitHub.
|
2013-09-07 21:38:41 -04:00
|
|
|
|
|
|
|
|
Overview
|
|
|
|
|
--------
|
|
|
|
|
|
|
|
|
|
Development of OpenMC relies heavily on branching; specifically, we use a
|
|
|
|
|
branching model sometimes referred to as `git flow`_. If you plan to contribute
|
|
|
|
|
to OpenMC development, we highly recommend that you read the linked blog post to
|
|
|
|
|
get a sense of how the branching model works. There are two main branches that
|
|
|
|
|
always exist: *master* and *develop*. The *master* branch is a stable branch
|
|
|
|
|
that contains the latest release of the code. The *develop* branch is where any
|
|
|
|
|
ongoing development takes place prior to a release and is not guaranteed to be
|
|
|
|
|
stable. When the development team decides that a release should occur, the
|
|
|
|
|
*develop* branch is merged into *master*.
|
|
|
|
|
|
2018-08-05 16:57:22 -05:00
|
|
|
All new features, enhancements, and bug fixes should be developed on a branch
|
2013-09-07 21:38:41 -04:00
|
|
|
that branches off of *develop*. When the feature is completed, a `pull request`_
|
2018-08-05 16:57:22 -05:00
|
|
|
is initiated on GitHub that is then reviewed by a committer. If the pull request
|
|
|
|
|
is satisfactory, it is then merged into *develop*. Note that a committer may not
|
|
|
|
|
review their own pull request (i.e., an independent code review is required).
|
2013-09-07 21:38:41 -04:00
|
|
|
|
|
|
|
|
Code Review Criteria
|
|
|
|
|
--------------------
|
|
|
|
|
|
2013-09-07 23:00:16 -04:00
|
|
|
In order to be considered suitable for inclusion in the *develop* branch, the
|
2013-09-07 21:38:41 -04:00
|
|
|
following criteria must be satisfied for all proposed changes:
|
|
|
|
|
|
2013-09-07 23:00:16 -04:00
|
|
|
- Changes have a clear purpose and are useful.
|
2018-08-05 16:57:22 -05:00
|
|
|
- Compiles and passes all tests under multiple build configurations (This is
|
2017-03-17 07:06:07 -04:00
|
|
|
checked by Travis CI).
|
2018-08-05 16:57:22 -05:00
|
|
|
- If appropriate, test cases are added to regression or unit test suites.
|
2013-09-07 21:38:41 -04:00
|
|
|
- No memory leaks (checked with valgrind_).
|
|
|
|
|
- Conforms to the OpenMC `style guide`_.
|
|
|
|
|
- No degradation of performance or greatly increased memory usage. This is not a
|
|
|
|
|
hard rule -- in certain circumstances, a performance loss might be acceptable
|
|
|
|
|
if there are compelling reasons.
|
|
|
|
|
- New features/input are documented.
|
2013-09-07 23:00:16 -04:00
|
|
|
- No unnecessary external software dependencies are introduced.
|
2013-09-07 21:38:41 -04:00
|
|
|
|
|
|
|
|
Contributing
|
|
|
|
|
------------
|
|
|
|
|
|
|
|
|
|
Now that you understand the basic development workflow, let's discuss how an
|
2020-10-08 20:04:32 -04:00
|
|
|
individual can contribute to development. Note that this would apply to both new
|
2013-09-07 21:38:41 -04:00
|
|
|
features and bug fixes. The general steps for contributing are as follows:
|
2012-10-13 21:29:48 -04:00
|
|
|
|
2018-08-02 10:49:40 -05:00
|
|
|
1. Fork the main openmc repository from `openmc-dev/openmc`_. This will create a
|
2013-09-07 21:38:41 -04:00
|
|
|
repository with the same name under your personal account. As such, you can
|
|
|
|
|
commit to it as you please without disrupting other developers.
|
|
|
|
|
|
2014-01-08 23:15:59 -05:00
|
|
|
.. image:: ../_images/fork.png
|
2013-09-07 21:38:41 -04:00
|
|
|
|
|
|
|
|
2. Clone your fork of OpenMC and create a branch that branches off of *develop*:
|
|
|
|
|
|
|
|
|
|
.. code-block:: sh
|
|
|
|
|
|
2020-01-12 16:49:09 -06:00
|
|
|
git clone --recurse-submodules git@github.com:yourusername/openmc.git
|
2013-09-07 21:38:41 -04:00
|
|
|
cd openmc
|
|
|
|
|
git checkout -b newbranch develop
|
|
|
|
|
|
2021-08-11 13:45:29 -05:00
|
|
|
3. Run ``tools/dev/install-commit-hooks.sh`` to install a post-commit hook that
|
|
|
|
|
runs clang-format on C++ files to apply :ref:`automatic code formatting
|
2021-08-13 09:09:55 -05:00
|
|
|
<styleguide_formatting>` (requires that clang-format already be installed).
|
|
|
|
|
In addition, you may want to configure your text editor to automatically run
|
|
|
|
|
clang-format when saving C++ files.
|
2021-08-11 13:45:29 -05:00
|
|
|
|
2013-09-07 21:38:41 -04:00
|
|
|
3. Make your changes on the new branch that you intend to have included in
|
2015-02-16 20:08:35 -05:00
|
|
|
*develop*. If you have made other changes that should not be merged back,
|
2013-09-07 21:38:41 -04:00
|
|
|
ensure that those changes are made on a different branch.
|
|
|
|
|
|
|
|
|
|
4. Issue a pull request from GitHub and select the *develop* branch of
|
2018-08-02 10:49:40 -05:00
|
|
|
openmc-dev/openmc as the target.
|
2013-09-07 21:38:41 -04:00
|
|
|
|
|
|
|
|
At a minimum, you should describe what the changes you've made are and why
|
2022-02-14 23:36:14 +00:00
|
|
|
you are making them. If the changes are related to an outstanding issue, make
|
2017-03-17 07:06:07 -04:00
|
|
|
sure it is cross-referenced.
|
2012-10-13 21:29:48 -04:00
|
|
|
|
2018-08-03 12:59:50 -05:00
|
|
|
5. A committer will review your pull request based on the criteria
|
2013-09-07 21:38:41 -04:00
|
|
|
above. Any issues with the pull request can be discussed directly on the pull
|
|
|
|
|
request page itself.
|
2012-10-13 21:29:48 -04:00
|
|
|
|
2013-09-07 21:38:41 -04:00
|
|
|
6. After the pull request has been thoroughly vetted, it is merged back into the
|
2018-08-02 10:49:40 -05:00
|
|
|
*develop* branch of openmc-dev/openmc.
|
2012-10-13 21:29:48 -04:00
|
|
|
|
2013-09-07 21:38:41 -04:00
|
|
|
Private Development
|
|
|
|
|
-------------------
|
2012-10-13 21:29:48 -04:00
|
|
|
|
|
|
|
|
While the process above depends on the fork of the OpenMC repository being
|
|
|
|
|
publicly available on GitHub, you may also wish to do development on a private
|
|
|
|
|
repository for research or commercial purposes. The proper way to do this is to
|
|
|
|
|
create a complete copy of the OpenMC repository (not a fork from GitHub). The
|
|
|
|
|
private repository can then either be stored just locally or in conjunction with
|
2013-09-07 21:38:41 -04:00
|
|
|
a private repository on Github (this requires a `paid plan`_). Alternatively,
|
|
|
|
|
`Bitbucket`_ offers private repositories for free. If you want to merge some
|
2018-08-02 10:49:40 -05:00
|
|
|
changes you've made in your private repository back to openmc-dev/openmc
|
2013-09-07 21:38:41 -04:00
|
|
|
repository, simply follow the steps above with an extra step of pulling a branch
|
|
|
|
|
from your private repository into a public fork.
|
2012-10-13 21:29:48 -04:00
|
|
|
|
2018-01-31 13:13:15 -06:00
|
|
|
.. _devguide_editable:
|
|
|
|
|
|
|
|
|
|
Working in "Development" Mode
|
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
|
|
If you are making changes to the Python API during development, it is highly
|
|
|
|
|
suggested to install the Python API in development/editable mode using
|
|
|
|
|
pip_. From the root directory of the OpenMC repository, run:
|
|
|
|
|
|
|
|
|
|
.. code-block:: sh
|
|
|
|
|
|
2023-06-13 06:19:10 -05:00
|
|
|
python -m pip install -e .[test]
|
2018-01-31 13:13:15 -06:00
|
|
|
|
|
|
|
|
This installs the OpenMC Python package in `"editable" mode
|
2022-03-04 10:34:37 -06:00
|
|
|
<https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs>`_ so that 1)
|
|
|
|
|
it can be imported from a Python interpreter and 2) any changes made are
|
2018-01-31 13:13:15 -06:00
|
|
|
immediately reflected in the installed version (that is, you don't need to keep
|
|
|
|
|
reinstalling it). While the same effect can be achieved using the
|
|
|
|
|
:envvar:`PYTHONPATH` environment variable, this is generally discouraged as it
|
|
|
|
|
can interfere with virtual environments.
|
|
|
|
|
|
2025-02-28 17:38:31 +01:00
|
|
|
.. _git: https://git-scm.com/
|
2012-10-13 21:29:48 -04:00
|
|
|
.. _GitHub: https://github.com/
|
2021-03-05 08:02:53 -06:00
|
|
|
.. _git flow: https://nvie.com/git-model
|
2025-03-07 14:49:36 -06:00
|
|
|
.. _valgrind: https://valgrind.org/
|
2019-10-03 13:17:15 -05:00
|
|
|
.. _style guide: https://docs.openmc.org/en/latest/devguide/styleguide.html
|
2021-03-05 08:02:53 -06:00
|
|
|
.. _pull request: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests
|
2018-08-02 10:49:40 -05:00
|
|
|
.. _openmc-dev/openmc: https://github.com/openmc-dev/openmc
|
2021-03-05 08:02:53 -06:00
|
|
|
.. _paid plan: https://github.com/pricing
|
2013-09-07 21:38:41 -04:00
|
|
|
.. _Bitbucket: https://bitbucket.org
|
2018-01-31 13:13:15 -06:00
|
|
|
.. _pip: https://pip.pypa.io/en/stable/
|