Dev environment
Setup
- Install Poetry
- Install an environment with Poetry
poetry install- This will create a virtual environment in
.venvand install all dependencies - You can also use
poetry shellto activate the virtual environment - Install pre-commit hooks
Note: You can also use a custom virtual environment based on your preference.
Pre-commit hooks
The repository uses pre-commit hooks for:
- Gitleaks — prevents accidentally committing secrets
- Conventional commits — validates commit message format on commit-msg
Install both hook types after cloning:
pre-commit install
pre-commit install --hook-type commit-msg
See the Gitleaks documentation if you need additional Gitleaks configuration on your machine.
Package management
The project uses Poetry for package management. You can use the following commands to manage packages:
poetry add <package>: Add a package to the projectpoetry add --group dev <package>: Add a package to the development grouppoetry remove <package>: Remove a package from the projectpoetry update: Update all packages to their latest versionspoetry install: Install all packages listed in thepyproject.tomlfilepoetry lock: Lock the dependencies to their current versions
The Petry project uses poetry.lock file to lock the dependencies to their current versions. This file is automatically generated by Poetry when you run poetry install or poetry update. You should not edit this file manually.
Tox
The project uses Tox for testing and linting. You can use the following commands to run Tox:
tox: Run all tests and linterstox -e <env>: Run a specific environment (e.g.tox -e testto run tests )tox -e <env> -- <args>: Run a specific environment with additional arguments (e.g.tox -e test -- -vto run tests for with verbose output)
Code formatting
The project uses Ruff for code checking and formatting. You can use the following commands to check and format the code:
tox -e ruff: Run Ruff to check the code
We highly recommend to configure your IDE to run Ruff on save. This will help you to keep the code clean and consistent.
Testing
The project uses Pytest for testing. You can use the following commands to run tests:
tox -e test: Run all teststox -e test -- -v: Run all tests with verbose outputtox -e test -- -k <test_name>: Run a specific test (e.g.tox -e test -- -k test_exampleto run the test namedtest_example)
Integration Tests
The integration tests require external services to be running. These services are provided locally via Docker Compose.
-
Start the test services:
bash docker compose up -d -
Run the integration tests:
bash tox -e test-integration
Building the container image
The project contains a Containerfile that can be used to build a container image. You can use the following command to build the image:
podman build -t <image_name> .
Replace <image_name> with the name you want to give to the image.
Then you can run the image using the following command:
podman run -it <image_name>
Replace <image_name> with the name of the image you built.