Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Welcome to the team! We're excited to have you on board as part of our development team.
To ensure a smooth and efficient workflow, we've put together some key rules and guidelines.
Please take a moment to review them before getting started.
- [Backend](#backend)
- [First steps](#first-steps)
- [Testing](#testing)
- [Code quality](#code-qualtiy)
- [Version Control](#version-control)
- [Collaboration & Communication](#collaboration--communication)
## Backend
### First steps:
We recommend using `uv` to manage Python versions, project dependencies, and virtual environments for this project.
Expand Down Expand Up @@ -56,6 +62,52 @@ uv run pytest
# Run a specific test
uv run pytest tests/test_something.py
```
### Code qualtiy
#### Linter - Ruff
```bash
# With uv
uv run ruff check

# With an activated environment
ruff check

# Pass the --fix option to automatically fix the fixable errors
uv run ruff check --fix
ruff check --fix
```
If available you can also install the ruff extension to your IDE.
For more information refer to the [docs](https://docs.astral.sh/ruff/).
#### Formatter - Ruff & isort
```bash
# With uv
uv run ruff format
uv run isort . # you can also pass a file as an arugment

# With an activated environment
ruff format
isort . # you can also pass a file as an arugment
```
For more information refer to the [ruff](https://docs.astral.sh/ruff/) and [isort](https://pycqa.github.io/isort/) docs.
#### Pre-commit hooks
To simplify the process of maintaining coding quality standards, we've added a pre-commit configuration. This ensures that your code is automatically linted and reformatted before every commit, making it easier to keep everything clean and consistent.

##### Install the git hook scripts
```bash
# With uv
uv run pre-commit install

# With an activated environment
pre-commit install
```
Now `pre-commit` will run automatically on `git commit`, checking the files in the staging area. If it finds any errors, it will abort the commit.
It is recommended to run the hooks against all of the files when adding new hooks.
```bash
# With uv
uv run pre-commit run --all-files

# With an activated environment
pre-commit run --all-files
```

## Version Control
- Branching: For every task or feature, create a fresh branch.
Expand Down
16 changes: 16 additions & 0 deletions backend/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.3
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
3 changes: 3 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ dependencies = [
"httpx==0.27.2",
"idna==3.8",
"iniconfig==2.0.0",
"isort>=5.13.2",
"jinja2==3.1.4",
"markdown-it-py==3.0.0",
"markupsafe==2.1.5",
"mdurl==0.1.2",
"motor>=3.5.1",
"packaging==24.1",
"pluggy==1.5.0",
"pre-commit>=3.8.0",
"pydantic-core==2.20.1",
"pydantic-settings>=2.4.0",
"pydantic==2.8.2",
Expand All @@ -38,6 +40,7 @@ dependencies = [
"python-multipart==0.0.9",
"pyyaml==6.0.2",
"rich==13.8.0",
"ruff>=0.6.3",
"shellingham==1.5.4",
"sniffio==1.3.1",
"starlette==0.38.4",
Expand Down
21 changes: 21 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ certifi==2024.8.30
# quiz-app-backend (pyproject.toml)
# httpcore
# httpx
cfgv==3.4.0
# via pre-commit
click==8.1.7
# via
# quiz-app-backend (pyproject.toml)
Expand All @@ -26,6 +28,8 @@ colorama==0.4.6
# click
# pytest
# uvicorn
distlib==0.3.8
# via virtualenv
dnspython==2.6.1
# via
# quiz-app-backend (pyproject.toml)
Expand All @@ -39,6 +43,8 @@ fastapi==0.112.2
# via quiz-app-backend (pyproject.toml)
fastapi-cli==0.0.5
# via quiz-app-backend (pyproject.toml)
filelock==3.15.4
# via virtualenv
h11==0.14.0
# via
# quiz-app-backend (pyproject.toml)
Expand All @@ -54,6 +60,8 @@ httptools==0.6.1
# uvicorn
httpx==0.27.2
# via quiz-app-backend (pyproject.toml)
identify==2.6.0
# via pre-commit
idna==3.8
# via
# quiz-app-backend (pyproject.toml)
Expand All @@ -64,6 +72,8 @@ iniconfig==2.0.0
# via
# quiz-app-backend (pyproject.toml)
# pytest
isort==5.13.2
# via quiz-app-backend (pyproject.toml)
jinja2==3.1.4
# via quiz-app-backend (pyproject.toml)
markdown-it-py==3.0.0
Expand All @@ -82,15 +92,21 @@ mdurl==0.1.2
# markdown-it-py
motor==3.5.1
# via quiz-app-backend (pyproject.toml)
nodeenv==1.9.1
# via pre-commit
packaging==24.1
# via
# quiz-app-backend (pyproject.toml)
# marshmallow
# pytest
platformdirs==4.2.2
# via virtualenv
pluggy==1.5.0
# via
# quiz-app-backend (pyproject.toml)
# pytest
pre-commit==3.8.0
# via quiz-app-backend (pyproject.toml)
pydantic==2.8.2
# via
# quiz-app-backend (pyproject.toml)
Expand Down Expand Up @@ -125,11 +141,14 @@ python-multipart==0.0.9
pyyaml==6.0.2
# via
# quiz-app-backend (pyproject.toml)
# pre-commit
# uvicorn
rich==13.8.0
# via
# quiz-app-backend (pyproject.toml)
# typer
ruff==0.6.3
# via quiz-app-backend (pyproject.toml)
shellingham==1.5.4
# via
# quiz-app-backend (pyproject.toml)
Expand Down Expand Up @@ -158,6 +177,8 @@ uvicorn==0.30.6
# via
# quiz-app-backend (pyproject.toml)
# fastapi-cli
virtualenv==20.26.3
# via pre-commit
watchfiles==0.24.0
# via
# quiz-app-backend (pyproject.toml)
Expand Down
Loading