Skip to content

Commit fe2d723

Browse files
authored
Merge pull request #1213 from tisnik/contributing-guide-test
Contributing guide: test
2 parents aa48185 + af67d0d commit fe2d723

1 file changed

Lines changed: 256 additions & 1 deletion

File tree

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTING.md

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
# CONTRIBUTING
2+
3+
<!-- the following line is used by tool to autogenerate Table of Content when the document is changed -->
4+
<!-- vim-markdown-toc GFM -->
5+
6+
* [TLDR;](#tldr)
7+
* [Prerequisites](#prerequisites)
8+
* [Tooling installation](#tooling-installation)
9+
* [Setting up your development environment](#setting-up-your-development-environment)
10+
* [PR description](#pr-description)
11+
* [Definition of Done](#definition-of-done)
12+
* [A deliverable is to be considered “done” when](#a-deliverable-is-to-be-considered-done-when)
13+
* [AI assistants](#ai-assistants)
14+
* [“Mark” code with substantial AI-generated portions.](#mark-code-with-substantial-ai-generated-portions)
15+
* [Copyright and licence notices](#copyright-and-licence-notices)
16+
* [Automation](#automation)
17+
* [Pre-commit hook settings](#pre-commit-hook-settings)
18+
* [Code coverage measurement](#code-coverage-measurement)
19+
* [Linters](#linters)
20+
* [Type hints checks](#type-hints-checks)
21+
* [Ruff](#ruff)
22+
* [Pylint](#pylint)
23+
* [Security checks](#security-checks)
24+
* [Code style](#code-style)
25+
* [Formatting rules](#formatting-rules)
26+
* [Docstrings style](#docstrings-style)
27+
28+
<!-- vim-markdown-toc -->
29+
30+
## TLDR;
31+
32+
1. Create your own fork of the repo
33+
2. Make changes to the code in your fork
34+
3. Run unit tests and integration tests
35+
4. Check the code with linters
36+
5. Submit PR from your fork to main branch of the project repo
37+
38+
39+
## Prerequisites
40+
41+
- git
42+
- Python 3.12 or 3.13
43+
- pip
44+
45+
The development requires at least [Python 3.12](https://docs.python.org/3/whatsnew/3.12.html) due to significant improvement on performance, optimizations which benefit modern ML, AI, LLM, NL stacks, and improved asynchronous processing capabilities. It is also possible to use Python 3.13.
46+
47+
48+
49+
### Tooling installation
50+
51+
1. `pip install --user uv`
52+
1. `uv --version` -- should return no error
53+
54+
55+
56+
## Setting up your development environment
57+
58+
```bash
59+
# clone your fork
60+
git clone https://github.com/YOUR-GIT-PROFILE/lightspeed-stack.git
61+
62+
# move into the directory
63+
cd lightspeed-stack
64+
65+
# setup your devel environment with uv
66+
uv sync --group dev
67+
68+
# Now you can run test commands trough make targets, or prefix the rest of commands with `uv run`, eg. `uv run make test` or do `uv venv`, which creates virtual environment and prints activation command, and run commands inside venv.
69+
70+
# run unit tests
71+
make test-unit
72+
73+
# run integration tests
74+
make test-integration
75+
76+
# code formatting
77+
# (this is also run automatically as part of pre-commit hook if configured)
78+
make format
79+
80+
# code style and docstring style
81+
# (this is also run automatically as part of pre-commit hook if configured)
82+
make verify
83+
84+
# check type hints
85+
# (this is also run automatically as part of pre-commit hook)
86+
make check-types
87+
```
88+
89+
Happy hacking!
90+
91+
92+
## PR description
93+
94+
* Jira ticket needs to be added into PR title, for example: `LCORE-740: type hints for models unit tests`
95+
* Fill-in all relevant information in the PR template
96+
- unused parts of PR template (like information about testing etc.) can be deleted
97+
* Please note that CodeRabbitAI will create a summary of your pull request
98+
99+
100+
## Definition of Done
101+
102+
### A deliverable is to be considered “done” when
103+
104+
* Code is complete, commented, and merged to the relevant release branch
105+
* User facing documentation written (where relevant)
106+
* Acceptance criteria in the related Jira ticket (where applicable) are verified and fulfilled
107+
* Pull request title+commit includes Jira number
108+
* Changes are covered by unit tests that run cleanly in the CI environment (where relevant)
109+
* Changes are covered by integration tests that run cleanly in the CI environment (where relevant)
110+
* Changes are covered by E2E tests that run cleanly in the CI environment (where relevant)
111+
* All linters are running cleanly in the CI environment
112+
* Code changes reviewed by at least one peer
113+
* Code changes acked by at least one project owner
114+
115+
## AI assistants
116+
117+
### “Mark” code with substantial AI-generated portions.
118+
119+
Nontrivial and substantial AI-generated or AI-assisted content should be
120+
“marked” in appropriate cases. In deciding how to approach this, consider
121+
adopting one or more of the following recommendations. (This assumes you have
122+
not concluded that a suggestion is a match to some existing third-party code.)
123+
124+
In a commit message, or in a pull request/merge request description field,
125+
identify the code assistant that you used, perhaps elaborating on how it was
126+
used. You may wish to use a trailer like “Assisted-by:” or “Generated-by:”. For
127+
example:
128+
129+
```
130+
Assisted-by: <name of code assistant>
131+
```
132+
133+
In a source file comment, indicate the use of the code assistant. For example:
134+
135+
```
136+
Generated by: <name of code assistant>
137+
```
138+
139+
### Copyright and licence notices
140+
141+
If the contents of an entire file or files in PR were substantially generated
142+
by a code assistant with little to no creative input or modification by you
143+
(which should typically not be the case), copyright protection may be limited,
144+
but it is particularly appropriate to mark the contents of the file as
145+
recommended above.
146+
147+
## Automation
148+
149+
### Pre-commit hook settings
150+
151+
It is possible to run formatters and linters automatically for all commits. You just need
152+
to copy file `hooks/pre-commit` into subdirectory `.git/hooks/`. It must be done manually
153+
because the copied file is an executable script (so from GIT point of view it is unsafe
154+
to enable it automatically).
155+
156+
157+
## Code coverage measurement
158+
159+
During testing, code coverage is measured. If the coverage is below the defined threshold (see `pyproject.toml` settings for actual value stored in section `[tool.coverage.report]`), tests will fail. We measured and checked code coverage in order to be able to develop software with high quality.
160+
161+
Code coverage reports are generated in JSON and also in format compatible with [_JUnit_ test automation framework](https://junit.org/junit5/). It is also possible to start `make coverage-report` to generate code coverage reports in the form of interactive HTML pages. These pages are stored in the `htmlcov` subdirectory. Just open the index page from this subdirectory in your web browser.
162+
163+
164+
165+
## Linters
166+
167+
_Black_, _Ruff_, Pyright, _Pylint_, __Pydocstyle__, __Mypy__, and __Bandit__ tools are used as linters. There are a bunch of linter rules enabled for this repository. All of them are specified in `pyproject.toml`, such as in sections `[tool.ruff]` and `[tool.pylint."MESSAGES CONTROL"]`. Some specific rules can be disabled using `ignore` parameter (empty now).
168+
169+
170+
### Type hints checks
171+
172+
It is possible to check if type hints added into the code are correct and whether assignments, function calls etc. use values of the right type. This check is invoked by following command:
173+
174+
```
175+
make check-types
176+
```
177+
178+
Please note that type hints check might be very slow on the first run.
179+
Subsequent runs are much faster thanks to the cache that Mypy uses. This check
180+
is part of a CI job that verifies sources.
181+
182+
183+
### Ruff
184+
185+
List of all _Ruff_ rules recognized by Ruff can be retrieved by:
186+
187+
188+
```
189+
ruff linter
190+
```
191+
192+
Description of all _Ruff_ rules are available on https://docs.astral.sh/ruff/rules/
193+
194+
Ruff rules can be disabled in source code (for a given line or block) by using a special `noqa` comment line. For example:
195+
196+
```python
197+
# noqa: E501
198+
```
199+
200+
### Pylint
201+
202+
List of all _Pylint_ rules can be retrieved by:
203+
204+
```
205+
pylint --list-msgs
206+
```
207+
208+
Description of all rules are available on https://pylint.readthedocs.io/en/latest/user_guide/checkers/features.html
209+
210+
To disable _Pylint_ rule in source code, the comment line in following format can be used:
211+
212+
```python
213+
# pylint: disable=C0415
214+
```
215+
216+
217+
218+
### Security checks
219+
220+
Static security check is performed by _Bandit_ tool. The check can be started by using:
221+
222+
```
223+
make security-check
224+
```
225+
226+
227+
228+
## Code style
229+
230+
### Formatting rules
231+
232+
Code formatting rules are checked by __Black__. More info can be found on [https://black.readthedocs.io/en/stable/](https://black.readthedocs.io/en/stable/).
233+
234+
### Docstrings style
235+
We are using [Google's docstring style](https://google.github.io/styleguide/pyguide.html).
236+
237+
Here is simple example:
238+
```python
239+
def function_with_pep484_type_annotations(param1: int, param2: str) -> bool:
240+
"""Example function with PEP 484 type annotations.
241+
242+
Args:
243+
param1: The first parameter.
244+
param2: The second parameter.
245+
246+
Returns:
247+
The return value. True for success, False otherwise.
248+
249+
Raises:
250+
ValueError: If the first parameter does not contain proper model name
251+
"""
252+
```
253+
254+
For further guidance, see the rest of our codebase, or check sources online. There are many, e.g. [this one](https://gist.github.com/redlotus/3bc387c2591e3e908c9b63b97b11d24e).
255+
256+

0 commit comments

Comments
 (0)