|
| 1 | +.. highlight:: shell |
| 2 | + |
| 3 | +============ |
| 4 | +Contributing |
| 5 | +============ |
| 6 | + |
| 7 | +Contributions are welcome, and they are greatly appreciated! Every little bit |
| 8 | +helps, and credit will always be given. |
| 9 | + |
| 10 | +You can contribute in many ways: |
| 11 | + |
| 12 | +Types of Contributions |
| 13 | +---------------------- |
| 14 | + |
| 15 | +Report Bugs |
| 16 | +~~~~~~~~~~~ |
| 17 | + |
| 18 | +Report bugs at https://github.com/D3-AI/Cardea/issues. |
| 19 | + |
| 20 | +If you are reporting a bug, please include: |
| 21 | + |
| 22 | +* Your operating system name and version. |
| 23 | +* Any details about your local setup that might be helpful in troubleshooting. |
| 24 | +* Detailed steps to reproduce the bug. |
| 25 | + |
| 26 | +Fix Bugs |
| 27 | +~~~~~~~~ |
| 28 | + |
| 29 | +Look through the GitHub issues for bugs. Anything tagged with "bug" and "help |
| 30 | +wanted" is open to whoever wants to implement it. |
| 31 | + |
| 32 | +Implement Features |
| 33 | +~~~~~~~~~~~~~~~~~~ |
| 34 | + |
| 35 | +Look through the GitHub issues for features. Anything tagged with "enhancement" |
| 36 | +and "help wanted" is open to whoever wants to implement it. |
| 37 | + |
| 38 | +Write Documentation |
| 39 | +~~~~~~~~~~~~~~~~~~~ |
| 40 | + |
| 41 | +Cardea could always use more documentation, whether as part of the |
| 42 | +official Cardea docs, in docstrings, or even on the web in blog posts, |
| 43 | +articles, and such. |
| 44 | + |
| 45 | +Submit Feedback |
| 46 | +~~~~~~~~~~~~~~~ |
| 47 | + |
| 48 | +The best way to send feedback is to file an issue at https://github.com/D3-AI/Cardea/issues. |
| 49 | + |
| 50 | +If you are proposing a feature: |
| 51 | + |
| 52 | +* Explain in detail how it would work. |
| 53 | +* Keep the scope as narrow as possible, to make it easier to implement. |
| 54 | +* Remember that this is a volunteer-driven project, and that contributions |
| 55 | + are welcome :) |
| 56 | + |
| 57 | +Get Started! |
| 58 | +------------ |
| 59 | + |
| 60 | +Ready to contribute? Here's how to set up `Cardea` for local development. |
| 61 | + |
| 62 | +1. Fork the `Cardea` repo on GitHub. |
| 63 | +2. Clone your fork locally:: |
| 64 | + |
| 65 | + $ git clone [email protected]:your_name_here/Cardea.git |
| 66 | + |
| 67 | +3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, |
| 68 | + this is how you set up your fork for local development:: |
| 69 | + |
| 70 | + $ mkvirtualenv Cardea |
| 71 | + $ cd Cardea/ |
| 72 | + $ pip install -e . |
| 73 | + $ pip install -r requirements_dev.txt |
| 74 | + |
| 75 | +4. Create a branch for local development:: |
| 76 | + |
| 77 | + $ git checkout -b name-of-your-bugfix-or-feature |
| 78 | + |
| 79 | + Now you can make your changes locally. |
| 80 | + |
| 81 | +5. While hacking your changes, make sure to cover all your developments with the required |
| 82 | + unit tests, and that none of the old tests fail as a consequence of your changes. |
| 83 | + For this, make sure to run the tests suite and check the code coverage:: |
| 84 | + |
| 85 | + $ make test # Run the tests |
| 86 | + $ make coverage # Get the coverage report |
| 87 | + |
| 88 | +6. When you're done making changes, check that your changes pass flake8 and the |
| 89 | + tests, including testing other Python versions with tox:: |
| 90 | + |
| 91 | + $ make test-all |
| 92 | + |
| 93 | +7. Make also sure to include the necessary documentation in the code as docstrings following |
| 94 | + the [google](https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments) |
| 95 | + or the [numpy](https://numpydoc.readthedocs.io/en/latest/format.html) docstring style. |
| 96 | + If you want to view how your documentation will look like when it is published, you can |
| 97 | + generate and view the docs with this command:: |
| 98 | + |
| 99 | + $ make viewdocs |
| 100 | + |
| 101 | +8. Commit your changes and push your branch to GitHub:: |
| 102 | + |
| 103 | + $ git add . |
| 104 | + $ git commit -m "Your detailed description of your changes." |
| 105 | + $ git push origin name-of-your-bugfix-or-feature |
| 106 | + |
| 107 | +9. Submit a pull request through the GitHub website. |
| 108 | + |
| 109 | +Pull Request Guidelines |
| 110 | +----------------------- |
| 111 | + |
| 112 | +Before you submit a pull request, check that it meets these guidelines: |
| 113 | + |
| 114 | +1. It resolves an open GitHub Issue and contains its reference in the title or |
| 115 | + the comment. If there is no associated issue, feel free to create one. |
| 116 | +2. Whenever possible, it resolves only **one** issue. If your PR resolves more than |
| 117 | + one issue, try to split it in more than one pull request. |
| 118 | +3. The pull request should include unit tests that cover all the changed code |
| 119 | +4. If the pull request adds functionality, the docs should be updated. Put |
| 120 | + your new functionality into a function with a docstring, and add the |
| 121 | + feature to the list in README.rst. |
| 122 | +5. The pull request should work for Python2.7, 3.4, 3.5 and 3.6. Check |
| 123 | + https://travis-ci.org/D3-AI/Cardea/pull_requests |
| 124 | + and make sure that all the checks pass. |
| 125 | + |
| 126 | +Unit Testing Guidelines |
| 127 | +----------------------- |
| 128 | + |
| 129 | +All the Unit Tests should comply with the following requirements: |
| 130 | + |
| 131 | +1. Unit Tests should be based only in unittest and pytest modules. |
| 132 | + |
| 133 | +2. The tests that cover a module called ``cardea/path/to/a_module.py`` should be |
| 134 | + implemented in a separated module called ``tests/cardea/path/to/test_a_module.py``. |
| 135 | + Note that the module name has the ``test_`` prefix and is located in a path similar |
| 136 | + to the one of the tested module, just inside te ``tests`` folder. |
| 137 | + |
| 138 | +3. Each method of the tested module should have at least one associated test method, and |
| 139 | + each test method should cover only **one** use case or scenario. |
| 140 | + |
| 141 | +4. Test case methods should start with the ``test_`` prefix and have descriptive names |
| 142 | + that indicate which scenario they cover. |
| 143 | + Names such as ``test_some_methed_input_none``, ``test_some_method_value_error`` or |
| 144 | + ``test_some_method_timeout`` are right, but names like ``test_some_method_1``, |
| 145 | + ``some_method`` or ``test_error`` are not. |
| 146 | + |
| 147 | +5. Each test should validate only what the code of the method being tested does, and not |
| 148 | + cover the behavior of any third party package or tool being used, which is assumed to |
| 149 | + work properly as far as it is being passed the right values. |
| 150 | + |
| 151 | +6. Any third party tool that may have any kind of random behavior, such as some Machine |
| 152 | + Learning models, databases or Web APIs, will be mocked using the ``mock`` library, and |
| 153 | + the only thing that will be tested is that our code passes the right values to them. |
| 154 | + |
| 155 | +7. Unit tests should not use anything from outside the test and the code being tested. This |
| 156 | + includes not reading or writting to any filesystem or database, which will be properly |
| 157 | + mocked. |
| 158 | + |
| 159 | +Tips |
| 160 | +---- |
| 161 | + |
| 162 | +To run a subset of tests:: |
| 163 | + |
| 164 | + $ pytest tests.test_cardea |
| 165 | + |
| 166 | +Release Workflow |
| 167 | +---------------- |
| 168 | + |
| 169 | +The process of releasing a new version involves several steps combining both ``git`` and |
| 170 | +``bumpversion`` which, briefly: |
| 171 | + |
| 172 | +1. Merge what is in ``master`` branch into ``stable`` branch. |
| 173 | +2. Update the version in ``setup.cfg``, ``cardea/__init__.py`` and ``HISTORY.md`` files. |
| 174 | +3. Create a new TAG pointing at the correspoding commit in ``stable`` branch. |
| 175 | +4. Merge the new commit from ``stable`` into ``master``. |
| 176 | +5. Update the version in ``setup.cfg`` and ``cardea/__init__.py`` to open the next |
| 177 | + development interation. |
| 178 | + |
| 179 | +**Note:** Before starting the process, make sure that ``HISTORY.md`` has a section titled |
| 180 | +**Unreleased** with the list of changes that will be included in the new version, and that |
| 181 | +these changes are committed and available in ``master`` branch. |
| 182 | +Normally this is just a list of the Pull Requests that have been merged since the latest version. |
| 183 | + |
| 184 | +Once this is done, just run the following commands:: |
| 185 | + |
| 186 | + git checkout stable |
| 187 | + git merge --no-ff master # This creates a merge commit |
| 188 | + bumpversion release # This creates a new commit and a TAG |
| 189 | + git push --tags origin stable |
| 190 | + make release |
| 191 | + git checkout master |
| 192 | + git merge stable |
| 193 | + bumpversion --no-tag patch |
| 194 | + git push |
0 commit comments