Skip to content
Merged
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
37 changes: 10 additions & 27 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ jobs:
name: Check conventional commits
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Check conventional commits
uses: webiny/action-conventional-commits@v1.0.3

ruff:
name: Check linting with Ruff
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Check code linting with Ruff
uses: chartboost/ruff-action@v1
with:
Expand All @@ -28,32 +26,17 @@ jobs:
name: Run pytest
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Set up python 3.9
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: '3.9'
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: 2.2.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install project
run: poetry install --no-interaction -vvv
enable-cache: true
- name: Install the project
run: uv sync --locked --all-extras --dev
- name: Run tests
run: |
source .venv/bin/activate
pytest tests
run: uv run pytest tests
69 changes: 40 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Python Version](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Code style: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

# TDP Lib

Expand Down Expand Up @@ -72,31 +72,42 @@ tdp --help

Contributions are welcome! Here are some guidelines specific to this project:

- Use [Poetry](https://python-poetry.org/) for development:

```sh
# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
# Install the dependencies
poetry install --all-extras
```

- Commit messages must adhere to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard.
- Run tests on all supported databases before submitting a PR:

```sh
docker compose -f dev/docker-compose.yaml up -d
poetry run pytest tests --database-dsn 'postgresql+psycopg2://postgres:postgres@localhost:5432/tdp' --database-dsn 'mysql+pymysql://mysql:mysql@localhost:3306/tdp' --database-dsn 'mysql+pymysql://mariadb:mariadb@localhost:3307/tdp'
docker compose -f dev/docker-compose.yaml down -v
```

- Format and lint code using [Ruff](https://beta.ruff.rs/docs/):

```sh
# Format the code and reoder imports
poetry run ruff check --select I --fix && ruff format
# Check the code for linting issues
poetry run ruff check
# Lint the code
poetry run ruff check --fix
```
### Dev environment

Use [uv](https://docs.astral.sh/uv/) for development:

```sh
# Install dependencies
uv sync --all-extras
```

### Testing

Tests are based on [Pytest](https://docs.pytest.org/en/stable/):

```sh
uv run pytest
```

`tdp-lib` is supporting SQLite, PostgreSQL and MariaDB. A `compose.yaml` is provided to run test accross all suported environments:

```sh
docker compose -f dev/docker-compose.yaml up -d
uv run pytest tests --database-dsn 'postgresql+psycopg2://postgres:postgres@localhost:5432/tdp' --database-dsn 'mysql+pymysql://mysql:mysql@localhost:3306/tdp' --database-dsn 'mysql+pymysql://mariadb:mariadb@localhost:3307/tdp'
docker compose -f dev/docker-compose.yaml down -v
```

### Contributions

Commit messages must adhere to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard.

Code must be formated and ensure the linting rules before being merged. This project use [Ruff](https://docs.astral.sh/ruff/):

```sh
# Format the code and reorder imports
uv run ruff check --select I --fix && uv run ruff format
# Check the code for linting issues
uv run ruff check
# Lint the code
uv run ruff check --fix
```
Loading