|
15 | 15 |
|
16 | 16 | .. image:: https://img.shields.io/gitter/room/python-gitlab/Lobby.svg |
17 | 17 | :target: https://gitter.im/python-gitlab/Lobby |
18 | | - |
| 18 | + |
19 | 19 | .. image:: https://img.shields.io/badge/code%20style-black-000000.svg |
20 | 20 | :target: https://github.com/python/black |
21 | 21 |
|
@@ -96,160 +96,4 @@ You can build the documentation using ``sphinx``:: |
96 | 96 | Contributing |
97 | 97 | ============ |
98 | 98 |
|
99 | | -You can contribute to the project in multiple ways: |
100 | | - |
101 | | -* Write documentation |
102 | | -* Implement features |
103 | | -* Fix bugs |
104 | | -* Add unit and functional tests |
105 | | -* Everything else you can think of |
106 | | - |
107 | | -Development workflow |
108 | | --------------------- |
109 | | - |
110 | | -Before contributing, please make sure you have `pre-commit <https://pre-commit.com>`_ |
111 | | -installed and configured. This will help automate adhering to code style and commit |
112 | | -message guidelines described below: |
113 | | - |
114 | | -.. code-block:: bash |
115 | | -
|
116 | | - cd python-gitlab/ |
117 | | - pip3 install --user pre-commit |
118 | | - pre-commit install -t pre-commit -t commit-msg --install-hooks |
119 | | -
|
120 | | -Please provide your patches as GitHub pull requests. Thanks! |
121 | | - |
122 | | -Commit message guidelines |
123 | | -------------------------- |
124 | | - |
125 | | -We enforce commit messages to be formatted using the `conventional-changelog <https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines>`_. |
126 | | -This leads to more readable messages that are easy to follow when looking through the project history. |
127 | | - |
128 | | -Code-Style |
129 | | ----------- |
130 | | - |
131 | | -We use black as code formatter, so you'll need to format your changes using the |
132 | | -`black code formatter |
133 | | -<https://github.com/python/black>`_. Pre-commit hooks will validate/format your code |
134 | | -when committing. You can then stage any changes ``black`` added if the commit failed. |
135 | | - |
136 | | -To format your code according to our guidelines before committing, run: |
137 | | - |
138 | | -.. code-block:: bash |
139 | | -
|
140 | | - cd python-gitlab/ |
141 | | - pip3 install --user black |
142 | | - black . |
143 | | -
|
144 | | -Running unit tests |
145 | | ------------------- |
146 | | - |
147 | | -Before submitting a pull request make sure that the tests and lint checks still succeed with |
148 | | -your change. Unit tests and functional tests run in GitHub Actions and |
149 | | -passing checks are mandatory to get merge requests accepted. |
150 | | - |
151 | | -Please write new unit tests with pytest and using `responses |
152 | | -<https://github.com/getsentry/responses/>`_. |
153 | | -An example can be found in ``tests/unit/objects/test_runner.py`` |
154 | | - |
155 | | -You need to install ``tox`` (``pip3 install tox``) to run tests and lint checks locally: |
156 | | - |
157 | | -.. code-block:: bash |
158 | | -
|
159 | | - # run unit tests using your installed python3, and all lint checks: |
160 | | - tox -s |
161 | | -
|
162 | | - # run unit tests for all supported python3 versions, and all lint checks: |
163 | | - tox |
164 | | -
|
165 | | - # run tests in one environment only: |
166 | | - tox -epy38 |
167 | | -
|
168 | | - # build the documentation, the result will be generated in |
169 | | - # build/sphinx/html/ |
170 | | - tox -edocs |
171 | | -
|
172 | | -Running integration tests |
173 | | -------------------------- |
174 | | - |
175 | | -Integration tests run against a running gitlab instance, using a docker |
176 | | -container. You need to have docker installed on the test machine, and your user |
177 | | -must have the correct permissions to talk to the docker daemon. |
178 | | - |
179 | | -To run these tests: |
180 | | - |
181 | | -.. code-block:: bash |
182 | | -
|
183 | | - # run the CLI tests: |
184 | | - tox -e cli_func_v4 |
185 | | -
|
186 | | - # run the python API tests: |
187 | | - tox -e py_func_v4 |
188 | | -
|
189 | | -When developing tests it can be a little frustrating to wait for GitLab to spin |
190 | | -up every run. To prevent the containers from being cleaned up afterwards, pass |
191 | | -`--keep-containers` to pytest, i.e.: |
192 | | - |
193 | | -.. code-block:: bash |
194 | | -
|
195 | | - tox -e py_func_v4 -- --keep-containers |
196 | | -
|
197 | | -If you then wish to test against a clean slate, you may perform a manual clean |
198 | | -up of the containers by running: |
199 | | - |
200 | | -.. code-block:: bash |
201 | | -
|
202 | | - docker-compose -f tests/functional/fixtures/docker-compose.yml -p pytest-python-gitlab down -v |
203 | | -
|
204 | | -By default, the tests run against the latest version of the ``gitlab/gitlab-ce`` |
205 | | -image. You can override both the image and tag by providing either the |
206 | | -``GITLAB_IMAGE`` or ``GITLAB_TAG`` environment variables. |
207 | | - |
208 | | -This way you can run tests against different versions, such as ``nightly`` for |
209 | | -features in an upcoming release, or an older release (e.g. ``12.8.0-ce.0``). |
210 | | -The tag must match an exact tag on Docker Hub: |
211 | | - |
212 | | -.. code-block:: bash |
213 | | -
|
214 | | - # run tests against `nightly` or specific tag |
215 | | - GITLAB_TAG=nightly tox -e py_func_v4 |
216 | | - GITLAB_TAG=12.8.0-ce.0 tox -e py_func_v4 |
217 | | -
|
218 | | - # run tests against the latest gitlab EE image |
219 | | - GITLAB_IMAGE=gitlab/gitlab-ee tox -e py_func_v4 |
220 | | -
|
221 | | -A freshly configured gitlab container will be available at |
222 | | -http://localhost:8080 (login ``root`` / password ``5iveL!fe``). A configuration |
223 | | -for python-gitlab will be written in ``/tmp/python-gitlab.cfg``. |
224 | | - |
225 | | -To cleanup the environment delete the container: |
226 | | - |
227 | | -.. code-block:: bash |
228 | | -
|
229 | | - docker rm -f gitlab-test |
230 | | - docker rm -f gitlab-runner-test |
231 | | -
|
232 | | -Releases |
233 | | --------- |
234 | | - |
235 | | -A release is automatically published once a month on the 28th if any commits merged |
236 | | -to the main branch contain commit message types that signal a semantic version bump |
237 | | -(``fix``, ``feat``, ``BREAKING CHANGE:``). |
238 | | - |
239 | | -Additionally, the release workflow can be run manually by maintainers to publish urgent |
240 | | -fixes, either on GitHub or using the ``gh`` CLI with ``gh workflow run release.yml``. |
241 | | - |
242 | | -**Note:** As a maintainer, this means you should carefully review commit messages |
243 | | -used by contributors in their pull requests. If scopes such as ``fix`` and ``feat`` |
244 | | -are applied to trivial commits not relevant to end users, it's best to squash their |
245 | | -pull requests and summarize the addition in a single conventional commit. |
246 | | -This avoids triggering incorrect version bumps and releases without functional changes. |
247 | | - |
248 | | -The release workflow uses `python-semantic-release |
249 | | -<https://python-semantic-release.readthedocs.io>`_ and does the following: |
250 | | - |
251 | | -* Bumps the version in ``__version__.py`` and adds an entry in ``CHANGELOG.md``, |
252 | | -* Commits and tags the changes, then pushes to the main branch as the ``github-actions`` user, |
253 | | -* Creates a release from the tag and adds the changelog entry to the release notes, |
254 | | -* Uploads the package as assets to the GitHub release, |
255 | | -* Uploads the package to PyPI using ``PYPI_TOKEN`` (configured as a secret). |
| 99 | +For guidelines for contributing to ``python-gitlab``, refer to `CONTRIBUTING.rst <https://github.com/python-gitlab/python-gitlab/blob/master/CONTRIBUTING.rst>`_. |
0 commit comments