Skip to content

Commit aab08ec

Browse files
committed
clear rst formatting
1 parent b5b6f6d commit aab08ec

37 files changed

Lines changed: 1549 additions & 161 deletions

mddocs/docs/en/contributing.md

Lines changed: 338 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,339 @@
1-
```{eval-rst}
2-
.. include:: ../CONTRIBUTING.rst
1+
# Contributing Guide
2+
3+
Welcome! There are many ways to contribute, including submitting bug reports, improving documentation, submitting feature requests, reviewing new submissions, or contributing code that can be incorporated into the project.
4+
5+
## Initial setup for local development
6+
7+
### Install Git
8+
9+
Please follow [instruction](https://docs.github.com/en/get-started/quickstart/set-up-git).
10+
11+
### Create a fork
12+
13+
If you are not a member of a development team building Data.Rentgen, you should create a fork before making any changes.
14+
15+
Please follow [instruction](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
16+
17+
### Clone the repo
18+
19+
Open terminal and run these commands:
20+
21+
```bash
22+
git clone https://github.com/MobileTeleSystems/data-rentgen -b develop
23+
24+
cd data_rentgen
25+
```
26+
27+
### Setup environment
28+
29+
Firstly, install [make](https://www.gnu.org/software/make/manual/make.html). It is used for running complex commands in local environment.
30+
31+
Secondly, create virtualenv and install dependencies:
32+
33+
```bash
34+
make venv
35+
```
36+
37+
If you already have venv, but need to install dependencies required for development:
38+
39+
```bash
40+
make venv-install
41+
```
42+
43+
We are using [poetry](https://python-poetry.org/docs/managing-dependencies/) for managing dependencies and building the package.
44+
It allows to keep development environment the same for all developers due to using lock file with fixed dependency versions.
45+
46+
There are *extra* dependencies (included into package as optional):
47+
48+
* `backend`
49+
* `client-sync`
50+
* `postgres`
51+
* `seed`
52+
53+
And *groups* (not included into package, used locally and in CI):
54+
55+
* `test` - for running tests
56+
* `dev` - for development, like linters, formatters, mypy, pre-commit and so on
57+
* `docs` - for building documentation
58+
59+
### Enable pre-commit hooks
60+
61+
[pre-commit](https://pre-commit.com/) hooks allows to validate & fix repository content before making new commit.
62+
It allows to run linters, formatters, fix file permissions and so on. If something is wrong, changes cannot be committed.
63+
64+
Firstly, install pre-commit hooks:
65+
66+
```bash
67+
pre-commit install --install-hooks
68+
```
69+
70+
Ant then test hooks run:
71+
72+
```bash
73+
pre-commit run
74+
```
75+
76+
## How to
77+
78+
### Run development instance locally
79+
80+
Start DB container & seed database with some examples:
81+
82+
```bash
83+
make db db-seed
84+
```
85+
86+
Then start development server:
87+
88+
```bash
89+
make dev-server
90+
```
91+
92+
And open [http://localhost:8000/docs](http://localhost:8000/docs)
93+
94+
Settings are stored in `.env.local` file.
95+
96+
To start developlment consumer, open a new terminal window/tab, and run:
97+
98+
```bash
99+
make broker dev-consumer
100+
```
101+
102+
### Working with migrations
103+
104+
Start database:
105+
106+
```bash
107+
make db-start
108+
```
109+
110+
Generate revision:
111+
112+
```bash
113+
make db-revision ARGS="-m 'Message'"
114+
```
115+
116+
Upgrade db to `head` migration:
117+
118+
```bash
119+
make db-upgrade
120+
```
121+
122+
Downgrade db to `head-1` migration:
123+
124+
```bash
125+
make db-downgrade
126+
```
127+
128+
### Run tests locally
129+
130+
This is as simple as:
131+
132+
```bash
133+
make test
134+
```
135+
136+
This command starts all necessary containers (Postgres, Kafka), runs all necessary migrations, and then runs Pytest.
137+
138+
You can pass additional arguments to pytest like this:
139+
140+
```bash
141+
make test PYTEST_ARGS="-m client-sync -lsx -vvvv --log-cli-level=INFO"
142+
```
143+
144+
Stop all containers and remove created volumes:
145+
146+
```bash
147+
make test-cleanup ARGS="-v"
148+
```
149+
150+
Get fixtures not used by any test:
151+
152+
```bash
153+
make test-check-fixtures
154+
```
155+
156+
### Run production instance locally
157+
158+
Firstly, build production image:
159+
160+
```bash
161+
make prod-build
162+
```
163+
164+
And then start it:
165+
166+
```bash
167+
make prod
168+
```
169+
170+
Then open [http://localhost:8000/docs](http://localhost:8000/docs)
171+
172+
Settings are stored in `.env.docker` file.
173+
174+
### Build documentation
175+
176+
Build documentation using Sphinx & open it:
177+
178+
```bash
179+
make docs
180+
```
181+
182+
If documentation should be build cleanly instead of reusing existing build result:
183+
184+
```bash
185+
make docs-fresh
186+
```
187+
188+
## Review process
189+
190+
Please create a new GitHub issue for any significant changes and enhancements that you wish to make. Provide the feature you would like to see, why you need it, and how it will work. Discuss your ideas transparently and get community feedback before proceeding.
191+
192+
Significant Changes that you wish to contribute to the project should be discussed first in a GitHub issue that clearly outlines the changes and benefits of the feature.
193+
194+
Small Changes can directly be crafted and submitted to the GitHub Repository as a Pull Request.
195+
196+
### Create pull request
197+
198+
Commit your changes:
199+
200+
```bash
201+
git commit -m "Commit message"
202+
git push
203+
```
204+
205+
Then open Github interface and [create pull request](https://docs.github.com/en/get-started/quickstart/contributing-to-projects#making-a-pull-request).
206+
Please follow guide from PR body template.
207+
208+
After pull request is created, it get a corresponding number, e.g. 123 (`pr_number`).
209+
210+
### Write release notes
211+
212+
Data.Rentgen uses [towncrier](https://pypi.org/project/towncrier/) for changelog management.
213+
214+
To submit a change note about your PR, add a text file into the [docs/changelog/next_release](./next_release) folder. It should contain an explanation of what applying this PR will change in the way end-users interact with the project. One sentence is usually enough but feel free to add as many details as you feel necessary for the users to understand what it means.
215+
216+
**Use the past tense** for the text in your fragment because, combined with others, it will be a part of the “news digest” telling the readers **what changed** in a specific version of the library *since the previous version*.
217+
218+
reStructuredText syntax for highlighting code (inline or block), linking parts of the docs or external sites. If you wish to sign your change, feel free to add `-- by :user:`github-username` at the end (replace `github-username` with your own!).
219+
220+
Finally, name your file following the convention that Towncrier understands: it should start with the number of an issue or a PR followed by a dot, then add a patch type, like `feature`, `doc`, `misc` etc., and add `.rst` as a suffix. If you need to add more than one fragment, you may add an optional sequence number (delimited with another period) between the type and the suffix.
221+
222+
In general the name will follow `<pr_number>.<category>.rst` pattern, where the categories are:
223+
224+
* `feature`: Any new feature
225+
* `bugfix`: A bug fix
226+
* `improvement`: An improvement
227+
* `doc`: A change to the documentation
228+
* `dependency`: Dependency-related changes
229+
* `misc`: Changes internal to the repo like CI, test and build changes
230+
231+
A pull request may have more than one of these components, for example
232+
a code change may introduce a new feature that deprecates an old
233+
feature, in which case two fragments should be added. It is not
234+
necessary to make a separate documentation fragment for documentation
235+
changes accompanying the relevant code changes.
236+
237+
#### Examples for adding changelog entries to your Pull Requests
238+
239+
```rst
240+
Added a ``:github:user:`` role to Sphinx config -- by :github:user:`someuser`
241+
```
242+
243+
```rst
244+
Fixed behavior of ``backend`` -- by :github:user:`someuser`
245+
```
246+
247+
```rst
248+
Added support of ``timeout`` in ``LDAP``
249+
-- by :github:user:`someuser`, :github:user:`anotheruser` and :github:user:`otheruser`
250+
```
251+
252+
#### How to skip change notes check?
253+
254+
Just add `ci:skip-changelog` label to pull request.
255+
256+
#### Release Process
257+
258+
Before making a release from the `develop` branch, follow these steps:
259+
260+
1. Checkout to `develop` branch and update it to the actual state
261+
262+
```bash
263+
git checkout develop
264+
git pull -p
265+
```
266+
267+
1. Backup `NEXT_RELEASE.rst`
268+
269+
```bash
270+
cp "docs/changelog/NEXT_RELEASE.rst" "docs/changelog/temp_NEXT_RELEASE.rst"
271+
```
272+
273+
1. Build the Release notes with Towncrier
274+
275+
```bash
276+
VERSION=$(poetry version -s)
277+
towncrier build "--version=${VERSION}" --yes
278+
```
279+
280+
1. Change file with changelog to release version number
281+
282+
```bash
283+
mv docs/changelog/NEXT_RELEASE.rst "docs/changelog/${VERSION}.rst"
284+
```
285+
286+
1. Remove content above the version number heading in the `${VERSION}.rst` file
287+
288+
```bash
289+
awk '!/^.*towncrier release notes start/' "docs/changelog/${VERSION}.rst" > temp && mv temp "docs/changelog/${VERSION}.rst"
290+
```
291+
292+
1. Update Changelog Index
293+
294+
```bash
295+
awk -v version=${VERSION} '/DRAFT/{print;print " " version;next}1' docs/changelog/index.rst > temp && mv temp docs/changelog/index.rst
296+
```
297+
298+
1. Restore `NEXT_RELEASE.rst` file from backup
299+
300+
```bash
301+
mv "docs/changelog/temp_NEXT_RELEASE.rst" "docs/changelog/NEXT_RELEASE.rst"
302+
```
303+
304+
1. Commit and push changes to `develop` branch
305+
306+
```bash
307+
git add .
308+
git commit -m "Prepare for release ${VERSION}"
309+
git push
310+
```
311+
312+
1. Merge `develop` branch to `master`, **WITHOUT** squashing
313+
314+
```bash
315+
git checkout master
316+
git pull
317+
git merge develop
318+
git push
319+
```
320+
321+
1. Add git tag to the latest commit in `master` branch
322+
323+
```bash
324+
git tag "$VERSION"
325+
git push origin "$VERSION"
326+
```
327+
328+
1. Update version in `develop` branch **after release**:
329+
330+
```bash
331+
git checkout develop
332+
333+
NEXT_VERSION=$(echo "$VERSION" | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
334+
poetry version "$NEXT_VERSION"
335+
336+
git add .
337+
git commit -m "Bump version"
338+
git push
3339
```

0 commit comments

Comments
 (0)