Skip to content

Commit 5920fdd

Browse files
committed
ci: Replace poetry with uv
1 parent 1c4375d commit 5920fdd

File tree

12 files changed

+1531
-2518
lines changed

12 files changed

+1531
-2518
lines changed

.github/workflows/linting-and-checks.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,16 @@ jobs:
4343
- name: "Setup: checkout repository"
4444
uses: actions/checkout@v4
4545

46-
- name: "Setup: install poetry"
47-
run: pipx install poetry
48-
49-
- name: "Setup: add python"
50-
uses: actions/setup-python@v5
46+
- name: "Setup: install uv"
47+
uses: astral-sh/setup-uv@v5
5148
with:
52-
python-version: "3.12"
53-
cache: "poetry"
49+
enable-cache: true
5450

5551
- name: "Setup: install dependencies"
56-
run: poetry install
52+
run: uv sync --locked --dev
5753

5854
- name: "Run: mypy"
59-
run: poetry run mypy src
55+
run: uv run mypy src
6056

6157
typescript-compile:
6258
runs-on: ubuntu-latest

.github/workflows/tests.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
run: |
2929
docker pull $API_IMAGE
3030
docker build --target development --tag api-development ./api # TODO: --cache-from $API_IMAGE
31-
3231
- name: Pytest Unit tests
3332
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm api pytest --unit
3433

@@ -44,7 +43,6 @@ jobs:
4443
run: |
4544
docker pull $API_IMAGE
4645
docker build --target development --tag api-development ./api # TODO: --cache-from $API_IMAGE
47-
4846
- name: BDD Integration tests
4947
if: ${{ false }} # disable for now
5048
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run api behave

api/Dockerfile

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
1-
FROM --platform=linux/amd64 python:3.13-slim AS base
2-
WORKDIR /code
3-
CMD ["/code/src/init.sh", "api"]
4-
EXPOSE 5000
1+
# First, build the application in the `/app` directory
2+
FROM --platform=linux/amd64 ghcr.io/astral-sh/uv:bookworm-slim AS uv-base
3+
ENV UV_COMPILE_BYTECODE=1
4+
ENV UV_LINK_MODE=copy
5+
6+
# Configure the Python directory so it is consistent
7+
ENV UV_PYTHON_INSTALL_DIR=/python
8+
9+
# Only use the managed Python version
10+
ENV UV_PYTHON_PREFERENCE=only-managed
511

6-
ENV PYTHONUNBUFFERED=1
7-
ENV PYTHONPATH=/code
12+
RUN uv python install 3.13
813

9-
RUN pip install --upgrade pip && \
10-
pip install poetry && \
11-
poetry config virtualenvs.create false
14+
FROM uv-base AS base
15+
# Install Python before the project for caching
16+
17+
WORKDIR /app
18+
RUN --mount=type=cache,target=/root/.cache/uv \
19+
--mount=type=bind,source=uv.lock,target=uv.lock \
20+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
21+
uv sync --locked --no-install-project --no-dev
22+
COPY . /app
23+
24+
# Place executables in the environment at the front of the path
25+
ENV PATH="/app/.venv/bin:$PATH"
26+
WORKDIR /app/src
27+
EXPOSE 5000
28+
CMD ["/app/src/init.sh", "api"]
1229

13-
COPY pyproject.toml pyproject.toml
14-
COPY poetry.lock poetry.lock
1530

1631
FROM base AS development
17-
RUN poetry install
18-
WORKDIR /code/src
19-
COPY src .
20-
USER 1000
32+
RUN --mount=type=cache,target=/root/.cache/uv \
33+
uv sync --locked --dev
2134

2235
FROM base AS prod
23-
RUN poetry install --without dev
24-
WORKDIR /code/src
25-
COPY src .
26-
USER 1000

api/poetry.lock

Lines changed: 0 additions & 2416 deletions
This file was deleted.

api/pyproject.toml

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
1-
[tool.poetry]
1+
[project]
22
name = "api"
3-
version = "1.4.0" # x-release-please-version
3+
version = "1.4.0"
44
description = "API for Template Fastapi React"
5-
authors = []
6-
license = ""
7-
package-mode = false
8-
9-
[tool.poetry.dependencies]
10-
cachetools = "^5.5.2"
11-
python = "^3.12"
12-
fastapi = { extras = ["standard"], version = "^0.115.8" }
13-
pyjwt = "^2.8.0"
14-
pymongo = "4.11.1"
15-
certifi = "^2025.1.31"
16-
httpx = "^0.28"
17-
pydantic = "^2.10"
18-
pydantic-settings = "^2.8"
19-
pydantic-extra-types = "^2.10"
20-
azure-monitor-opentelemetry = "^1.6.5"
21-
opentelemetry-instrumentation-fastapi = "^0.51b0"
22-
cryptography = "^44.0.1"
5+
requires-python = ">=3.13"
6+
dependencies = [
7+
"azure-monitor-opentelemetry>=1.6.5",
8+
"cachetools>=5.5.2",
9+
"certifi>=2025.4.26",
10+
"cryptography>=44.0.1",
11+
"fastapi[standard]>=0.115.8",
12+
"httpx>=0.28",
13+
"opentelemetry-instrumentation-fastapi>=0.51b0",
14+
"pydantic>=2.10",
15+
"pydantic-extra-types>=2.10",
16+
"pydantic-settings>=2.8",
17+
"pyjwt>=2.8.0",
18+
"pymongo>=4.11.1",
19+
]
2320

24-
[tool.poetry.group.dev.dependencies]
25-
pre-commit = ">=3"
26-
pytest = "^8.3"
27-
mongomock = "^4.1.2"
28-
mypy = "^1.14.1"
29-
types-cachetools = "^5.5.0.20240820"
21+
[dependency-groups]
22+
dev = [
23+
"mongomock>=4.1.2",
24+
"mypy>=1.14.1",
25+
"pre-commit>=3",
26+
"pytest>=8.3.0",
27+
"types-cachetools>=5.5.0.20240820",
28+
]
3029

31-
[build-system]
32-
requires = ["poetry-core>=1.0.0"]
33-
build-backend = "poetry.core.masonry.api"
3430

3531
[tool.mypy]
3632
plugins = ["pydantic.mypy"]
@@ -39,7 +35,7 @@ exclude = ["/tests/"]
3935
ignore_missing_imports = true
4036
namespace_packages = true
4137
explicit_package_bases = true
42-
allow_subclassing_any = true
38+
disallow_subclassing_any = false
4339

4440
[tool.ruff]
4541
src = ["src"]

0 commit comments

Comments
 (0)