Skip to content

Commit 1976e4d

Browse files
authored
Release 7.0.0 (2026-02) (#127)
* migrate to uv (#119) Signed-off-by: rafsaf <[email protected]> * bump Signed-off-by: rafsaf <[email protected]> * rewrite to new design Signed-off-by: rafsaf <[email protected]> * working tests Signed-off-by: rafsaf <[email protected]> * metrics and main Signed-off-by: rafsaf <[email protected]> * rename tests, bump pg, add lifespan and probe, add makefile Signed-off-by: rafsaf <[email protected]> * bump gh actions Signed-off-by: rafsaf <[email protected]> * update readme Signed-off-by: rafsaf <[email protected]> * readme fixes Signed-off-by: rafsaf <[email protected]> * last typos in README.md Signed-off-by: rafsaf <[email protected]> --------- Signed-off-by: rafsaf <[email protected]>
1 parent 3485a74 commit 1976e4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2012
-2675
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ DATABASE__HOSTNAME=localhost
66
DATABASE__USERNAME=rDGJeEDqAz
77
DATABASE__PASSWORD=XsPQhCoEfOQZueDjsILetLDUvbvSxAMnrVtgVZpmdcSssUgbvs
88
DATABASE__PORT=5455
9-
DATABASE__DB=default_db
9+
DATABASE__DB=default_db
10+
11+
PROMETHEUS__ENABLED=true
12+
PROMETHEUS__ADDR="127.0.0.1"

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
3+
- package-ecosystem: uv
44
directory: /
55
schedule:
66
interval: monthly
7-
open-pull-requests-limit: 5
7+
open-pull-requests-limit: 1
88
allow:
99
- dependency-type: "all"
1010
groups:

.github/workflows/dev_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
dev_build:
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v6
2424

2525
- name: Login to DockerHub
2626
uses: docker/login-action@v3

.github/workflows/tests.yml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
services:
1313
postgres:
14-
image: postgres
14+
image: postgres:18
1515
env:
1616
POSTGRES_PASSWORD: postgres
1717
options: >-
@@ -22,36 +22,27 @@ jobs:
2222
ports:
2323
- 5432:5432
2424
steps:
25-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v6
2626

27-
- name: Set up Python
28-
uses: actions/setup-python@v5
27+
- name: "Set up Python"
28+
uses: actions/setup-python@v6
2929
with:
30-
python-version: "3.13.1"
30+
python-version-file: "pyproject.toml"
3131

32-
- name: Install Poetry
33-
uses: snok/install-poetry@v1
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v7
3434
with:
35-
virtualenvs-create: true
36-
virtualenvs-in-project: false
37-
virtualenvs-path: /opt/venv
35+
version: "0.9.2"
36+
enable-cache: true
3837

39-
- name: Load cached venv
40-
id: cached-poetry-dependencies
41-
uses: actions/cache@v4
42-
with:
43-
path: /opt/venv
44-
key: venv-${{ runner.os }}-python-3.13.1-${{ hashFiles('poetry.lock') }}
45-
46-
- name: Install dependencies and actiavte virtualenv
47-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
48-
run: |
49-
poetry install --no-interaction --no-root
38+
- name: Install the project
39+
run: uv sync --locked --all-extras --dev
40+
shell: bash
5041

5142
- name: Run tests
5243
env:
5344
SECURITY__JWT_SECRET_KEY: very-not-secret
5445
DATABASE__HOSTNAME: localhost
5546
DATABASE__PASSWORD: postgres
5647
run: |
57-
poetry run pytest
48+
uv run pytest

.github/workflows/type_check.yml

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,23 @@ jobs:
1414

1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818

19-
- name: Set up Python
20-
uses: actions/setup-python@v5
19+
- name: "Set up Python"
20+
uses: actions/setup-python@v6
2121
with:
22-
python-version: "3.13.1"
22+
python-version-file: "pyproject.toml"
2323

24-
- name: Install Poetry
25-
uses: snok/install-poetry@v1
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v7
2626
with:
27-
virtualenvs-create: true
28-
virtualenvs-in-project: true
27+
version: "0.9.2"
28+
enable-cache: true
2929

30-
- name: Install Poetry
31-
uses: snok/install-poetry@v1
32-
with:
33-
virtualenvs-create: true
34-
virtualenvs-in-project: false
35-
virtualenvs-path: /opt/venv
36-
37-
- name: Load cached venv
38-
id: cached-poetry-dependencies
39-
uses: actions/cache@v4
40-
with:
41-
path: /opt/venv
42-
key: venv-${{ runner.os }}-python-3.13.1-${{ hashFiles('poetry.lock') }}
43-
44-
- name: Install dependencies and actiavte virtualenv
45-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
46-
run: |
47-
poetry install --no-interaction --no-root
30+
- name: Install the project
31+
run: uv sync --locked --all-extras --dev
32+
shell: bash
4833

4934
- name: Run ${{ matrix.check }}
5035
run: |
51-
poetry run ${{ matrix.check }} .
36+
uv run ${{ matrix.check }} .

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-yaml
66

77
- repo: https://github.com/astral-sh/ruff-pre-commit
8-
rev: v0.11.12
8+
rev: v0.14.14
99
hooks:
1010
- id: ruff-format
1111

1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.11.12
13+
rev: v0.14.14
1414
hooks:
15-
- id: ruff
15+
- id: ruff-check
1616
args: [--fix]

Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
FROM python:3.13.5-slim-bookworm AS base
1+
FROM python:3.14-slim-trixie AS base
22

33
ENV PYTHONUNBUFFERED=1
44
WORKDIR /build
55

66
# Create requirements.txt file
7-
FROM base AS poetry
8-
RUN pip install poetry==2.1.3
9-
RUN poetry self add poetry-plugin-export
10-
COPY poetry.lock pyproject.toml ./
11-
RUN poetry export -o /requirements.txt --without-hashes
7+
FROM base AS uv
8+
COPY --from=ghcr.io/astral-sh/uv:0.9.2 /uv /uvx /bin/
9+
COPY uv.lock pyproject.toml ./
10+
RUN uv export --no-dev --no-hashes -o /requirements.txt --no-install-workspace --frozen
11+
RUN uv export --only-group dev --no-hashes -o /requirements-dev.txt --no-install-workspace --frozen
1212

1313
FROM base AS final
14-
COPY --from=poetry /requirements.txt .
14+
COPY --from=uv /requirements.txt .
1515

1616
# Create venv, add it to path and install requirements
1717
RUN python -m venv /venv
@@ -28,8 +28,9 @@ COPY alembic.ini .
2828
COPY pyproject.toml .
2929
COPY init.sh .
3030

31-
# Expose port
31+
# Expose port 8000 for app and optional 9090 for prometheus metrics
3232
EXPOSE 8000
33+
EXPOSE 9090
3334

3435
# Make the init script executable
3536
RUN chmod +x ./init.sh
@@ -39,4 +40,4 @@ ENTRYPOINT ["./init.sh"]
3940

4041
# Set CMD to uvicorn
4142
# /venv/bin/uvicorn is used because from entrypoint script PATH is new
42-
CMD ["/venv/bin/uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2", "--loop", "uvloop"]
43+
CMD ["/venv/bin/uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1", "--loop", "uvloop"]

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
BIND_PORT ?= 8000
2+
BIND_HOST ?= localhost
3+
4+
.PHONY: help
5+
help: ## Print this help message
6+
grep -E '^[\.a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
7+
8+
.env: ## Ensure there is env file or create one
9+
echo "No .env file found. Want to create it from .env.example? [y/n]" && read answer && if [ $${answer:-'N'} = 'y' ]; then cp .env.example .env;fi
10+
11+
.PHONY: local-setup
12+
local-setup: ## Setup local postgres database
13+
docker compose up -d
14+
15+
.PHONY: up
16+
up: local-setup ## Run FastAPI development server
17+
uv run alembic upgrade head
18+
uv run uvicorn app.main:app --reload --host $(BIND_HOST) --port $(BIND_PORT)
19+
20+
.PHONY: run
21+
run: up ## Alias for `up`
22+
23+
.PHONY: down
24+
down: ## Stop database
25+
docker compose down
26+
27+
.PHONY: test
28+
test: local-setup ## Run unit tests
29+
uv run pytest .
30+
31+
.PHONY: lint
32+
lint: local-setup ## Run all linters
33+
uv run pre-commit run -a
34+
uv run mypy .

0 commit comments

Comments
 (0)