Skip to content

Commit 3d52e7c

Browse files
committed
Add CONTRIBUTING.rst
1 parent 9a43dac commit 3d52e7c

2 files changed

Lines changed: 333 additions & 0 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!-- Thank you for your contribution! -->
2+
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
3+
<!-- See https://github.com/dolfinus/setuptools-git-versioning/blob/master/CONTRIBUTING.rst for help on Contributing -->
4+
<!-- PLEASE DO **NOT** put issue ids in the PR title! Instead, add a descriptive title and put ids in the body -->
5+
6+
## Change Summary
7+
8+
<!-- Please give a short summary of the changes. -->
9+
10+
## Related issue number
11+
12+
<!-- Are there any issues opened that will be resolved by merging this change? -->
13+
<!-- WARNING: please use "fix #123" style references so the issue is closed when this PR is merged. -->
14+
15+
## Checklist
16+
17+
* [ ] Commit message and PR title is comprehensive
18+
* [ ] Keep the change as small as possible
19+
* [ ] Unit and integration tests for the changes exist
20+
* [ ] Tests pass on CI and coverage does not decrease
21+
* [ ] Documentation reflects the changes where applicable
22+
* [ ] `docs/changelog/next_release/<pull request or issue id>.<change type>.rst` file added describing change
23+
(see [CONTRIBUTING.rst](https://github.com/dolfinus/setuptools-git-versioning/blob/master/CONTRIBUTING.rst) for details.)
24+
* [ ] My PR is ready to review.

CONTRIBUTING.rst

Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
Contributing Guide
2+
==================
3+
4+
Welcome! There are many ways to contribute, including submitting bug
5+
reports, improving documentation, submitting feature requests, reviewing
6+
new submissions, or contributing code that can be incorporated into the
7+
project.
8+
9+
Review process
10+
--------------
11+
12+
For any **significant** changes please create a new GitHub issue and
13+
enhancements that you wish to make. Describe the feature you would like
14+
to see, why you need it, and how it will work. Discuss your ideas
15+
transparently and get community feedback before proceeding.
16+
17+
Small changes can directly be crafted and submitted to the GitHub
18+
Repository as a Pull Request. This requires creating a **repo fork** using
19+
`instruction <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_.
20+
21+
Important notes
22+
---------------
23+
24+
Please take into account that some users still use EOF Python versions, like 3.7. So it is required to keep compatibility if possible.
25+
26+
Initial setup for local development
27+
-----------------------------------
28+
29+
Install Git
30+
~~~~~~~~~~~
31+
32+
Please follow `instruction <https://docs.github.com/en/get-started/quickstart/set-up-git>`_.
33+
34+
Clone the repo
35+
~~~~~~~~~~~~~~
36+
37+
Open terminal and run these commands to clone a **forked** repo:
38+
39+
.. code:: bash
40+
41+
git clone git@github.com:myuser/setuptools-git-versioning.git -b develop
42+
43+
cd setuptools_git_versioning
44+
45+
Enable pre-commit hooks
46+
~~~~~~~~~~~~~~~~~~~~~~~
47+
48+
Create virtualenv and install dependencies:
49+
50+
.. code:: bash
51+
52+
make venv-install
53+
54+
Install pre-commit hooks:
55+
56+
.. code:: bash
57+
58+
prek install --install-hooks
59+
60+
Test pre-commit hooks run:
61+
62+
.. code:: bash
63+
64+
prek run
65+
66+
How to
67+
------
68+
69+
Run tests locally
70+
~~~~~~~~~~~~~~~~~
71+
72+
.. note::
73+
74+
You can skip this if only documentation is changed.
75+
76+
Setup environment
77+
^^^^^^^^^^^^^^^^^
78+
79+
Create virtualenv and install dependencies:
80+
81+
.. code:: bash
82+
83+
make venv-install
84+
85+
Run tests:
86+
87+
.. code:: bash
88+
89+
make test
90+
91+
Run specific tests:
92+
93+
.. code:: bash
94+
95+
make test PYTEST_ARGS="-k some_test"
96+
97+
You can pass additional arguments, they will be passed to pytest:
98+
99+
.. code:: bash
100+
101+
make test PYTEST_ARGS="-k some_test -lsx -vvvv --log-cli-level=INFO"
102+
103+
Build documentation
104+
~~~~~~~~~~~~~~~~~~~
105+
106+
.. note::
107+
108+
You can skip this if only source code behavior remains the same.
109+
110+
Create virtualenv and install dependencies:
111+
112+
.. code:: bash
113+
114+
make venv-install
115+
116+
Build documentation using Sphinx:
117+
118+
.. code:: bash
119+
120+
cd docs
121+
make html
122+
123+
Then open in browser ``docs/_build/index.html``.
124+
125+
Create pull request
126+
~~~~~~~~~~~~~~~~~~~
127+
128+
Commit your changes:
129+
130+
.. code:: bash
131+
132+
git commit -m "Commit message"
133+
git push
134+
135+
Then open Github interface and `create pull request <https://docs.github.com/en/get-started/quickstart/contributing-to-projects#making-a-pull-request>`_.
136+
Please follow guide from PR body template.
137+
138+
After pull request is created, it get a corresponding number, e.g. 123 (``pr_number``).
139+
140+
Write release notes
141+
~~~~~~~~~~~~~~~~~~~
142+
143+
``setuptools-git-versioning`` uses `towncrier <https://pypi.org/project/towncrier/>`_
144+
for changelog management.
145+
146+
To submit a change note about your PR, add a text file into the
147+
`docs/changelog/next_release <./next_release>`_ folder. It should contain an
148+
explanation of what applying this PR will change in the way
149+
end-users interact with the project. One sentence is usually
150+
enough but feel free to add as many details as you feel necessary
151+
for the users to understand what it means.
152+
153+
**Use the past tense** for the text in your fragment because,
154+
combined with others, it will be a part of the "news digest"
155+
telling the readers **what changed** in a specific version of
156+
the library *since the previous version*.
157+
158+
You should also use
159+
reStructuredText syntax for highlighting code (inline or block),
160+
linking parts of the docs or external sites.
161+
If you wish to sign your change, feel free to add ``-- by
162+
:user:`github-username``` at the end (replace ``github-username``
163+
with your own!).
164+
165+
Finally, name your file following the convention that Towncrier
166+
understands: it should start with the number of an issue or a
167+
PR followed by a dot, then add a patch type, like ``feature``,
168+
``doc``, ``misc`` etc., and add ``.rst`` as a suffix. If you
169+
need to add more than one fragment, you may add an optional
170+
sequence number (delimited with another period) between the type
171+
and the suffix.
172+
173+
In general the name will follow ``<pr_number>.<category>.rst`` pattern,
174+
where the categories are:
175+
176+
- ``feature``: Any new feature
177+
- ``bugfix``: A bug fix
178+
- ``improvement``: An improvement
179+
- ``doc``: A change to the documentation
180+
- ``dependency``: Dependency-related changes
181+
- ``misc``: Changes internal to the repo like CI, test and build changes
182+
183+
A pull request may have more than one of these components, for example
184+
a code change may introduce a new feature that deprecates an old
185+
feature, in which case two fragments should be added. It is not
186+
necessary to make a separate documentation fragment for documentation
187+
changes accompanying the relevant code changes.
188+
189+
Examples for adding changelog entries to your Pull Requests
190+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
191+
192+
.. code-block:: rst
193+
:caption: docs/changelog/next_release/1234.doc.1.rst
194+
195+
Added a ``:github:user:`` role to Sphinx config -- by :github:user:`someuser`
196+
197+
.. code-block:: rst
198+
:caption: docs/changelog/next_release/2345.bugfix.rst
199+
200+
Fixed behavior of ``WebDAV`` connector -- by :github:user:`someuser`
201+
202+
.. code-block:: rst
203+
:caption: docs/changelog/next_release/3456.feature.rst
204+
205+
Added support of ``timeout`` in ``S3`` connector
206+
-- by :github:user:`someuser`, :github:user:`anotheruser` and :github:user:`otheruser`
207+
208+
.. tip::
209+
210+
See `pyproject.toml <pyproject.toml>`_ for all available categories
211+
(``tool.towncrier.type``).
212+
213+
.. _Towncrier philosophy:
214+
https://towncrier.readthedocs.io/en/stable/#philosophy
215+
216+
How to skip change notes check?
217+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
218+
219+
Just add ``ci:skip-changelog`` label to pull request.
220+
221+
Release Process
222+
---------------
223+
224+
.. note::
225+
226+
This is for repo maintainers only
227+
228+
Before making a release from the ``develop`` branch, follow these steps:
229+
230+
0. Checkout to ``develop`` branch and update it to the actual state
231+
232+
.. code:: bash
233+
234+
git checkout develop
235+
git pull -p
236+
237+
1. Backup ``NEXT_RELEASE.rst``
238+
239+
.. code:: bash
240+
241+
cp "docs/changelog/NEXT_RELEASE.rst" "docs/changelog/temp_NEXT_RELEASE.rst"
242+
243+
2. Build the Release notes with Towncrier
244+
245+
.. code:: bash
246+
247+
VERSION=$(cat setuptools_git_versioning/VERSION)
248+
towncrier build "--version=${VERSION}" --yes
249+
250+
3. Change file with changelog to release version number
251+
252+
.. code:: bash
253+
254+
mv docs/changelog/NEXT_RELEASE.rst "docs/changelog/${VERSION}.rst"
255+
256+
4. Remove content above the version number heading in the ``${VERSION}.rst`` file
257+
258+
.. code:: bash
259+
260+
awk '!/^.*towncrier release notes start/' "docs/changelog/${VERSION}.rst" > temp && mv temp "docs/changelog/${VERSION}.rst"
261+
262+
5. Update Changelog Index
263+
264+
.. code:: bash
265+
266+
awk -v version=${VERSION} '/DRAFT/{print;print " " version;next}1' docs/changelog/index.rst > temp && mv temp docs/changelog/index.rst
267+
268+
6. Restore ``NEXT_RELEASE.rst`` file from backup
269+
270+
.. code:: bash
271+
272+
mv "docs/changelog/temp_NEXT_RELEASE.rst" "docs/changelog/NEXT_RELEASE.rst"
273+
274+
7. Commit and push changes to ``develop`` branch
275+
276+
.. code:: bash
277+
278+
git add .
279+
git commit -m "Prepare for release ${VERSION}"
280+
git push
281+
282+
8. Merge ``develop`` branch to ``master``, **WITHOUT** squashing
283+
284+
.. code:: bash
285+
286+
git checkout master
287+
git pull
288+
git merge develop
289+
git push
290+
291+
9. Add git tag to the latest commit in ``master`` branch
292+
293+
.. code:: bash
294+
295+
git tag "$VERSION"
296+
git push origin "$VERSION"
297+
298+
10. Update version in ``develop`` branch **after release**:
299+
300+
.. code:: bash
301+
302+
git checkout develop
303+
304+
NEXT_VERSION=$(echo "$VERSION" | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
305+
echo "$NEXT_VERSION" > setuptools_git_versioning/VERSION
306+
307+
git add .
308+
git commit -m "Bump version"
309+
git push

0 commit comments

Comments
 (0)