Skip to content

Commit 0407df6

Browse files
authored
chore(debugger): migrate to uv (#847)
* chore(debugger): migrate to uv * fix(ci): working-directory is under `with` * chore(ci): make separate sanity job for debugger - ruff and mypy checks to be resolved in later PR
1 parent 39f6319 commit 0407df6

7 files changed

Lines changed: 498 additions & 50 deletions

File tree

.github/workflows/pre-merge.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
types: [opened, reopened, synchronize, edited]
66

77
jobs:
8-
sanity:
8+
sanity-client:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
@@ -22,3 +22,20 @@ jobs:
2222
working-directory: ./client
2323
run: npm run build
2424

25+
sanity-debugger:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
31+
with:
32+
working-directory: debugger
33+
- name: Install debugger dependencies
34+
working-directory: debugger
35+
run: uv sync --locked --all-extras --dev
36+
# - run: uv format --check
37+
# working-directory: debugger
38+
# - run: uv run mypy src/
39+
# working-directory: debugger
40+
41+

debugger/Dockerfile.prod

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,42 @@
1-
from python:3.13.3-bookworm
1+
# adapted from https://github.com/astral-sh/uv-docker-example/blob/main/Dockerfile
2+
from ghcr.io/astral-sh/uv:python3.13-trixie-slim
3+
4+
run groupadd --system --gid 999 nonroot \
5+
&& useradd --system --gid 999 --uid 999 --create-home nonroot
26

37
workdir /app
48

9+
env PYTHONUNBUFFERED=1
10+
env UV_COMPILE_BYTECODE=1
11+
env UV_LINK_MODE=copy
12+
env UV_NO_DEV=1
13+
env UV_TOOL_BIN_DIR=/usr/local/bin
14+
15+
516
run apt-get update -y
617
run apt-get install -y gdb libprotobuf32 libnl-3-200 libnl-route-3-200 flex bison protobuf-compiler libnl-genl-3-dev libnl-3-dev libnl-route-3-dev git
718

8-
copy requirements.txt .
9-
run pip3 install -r requirements.txt --root-user-action=ignore
19+
run --mount=type=cache,target=/root/.cache/uv \
20+
--mount=type=bind,source=uv.lock,target=uv.lock \
21+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
22+
uv sync --locked --no-install-project
23+
24+
copy . /app
25+
run --mount=type=cache,target=/root/.cache/uv \
26+
uv sync --locked
27+
28+
env PATH="/app/.venv/bin:$PATH"
29+
30+
entrypoint []
31+
32+
user nonroot
1033

11-
copy . .
1234
workdir /app/src/debugger
1335
# run git clone https://github.com/google/nsjail.git
1436
# workdir /app/src/debugger/nsjail
1537
# run make && cp nsjail /usr/local/bin
1638
workdir /app
1739

1840
expose 8000
19-
cmd ["python3", "src/serve.py"]
41+
cmd ["python", "src/serve.py"]
42+

debugger/pyproject.toml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
[build-system]
2-
requires = ["hatchling"]
3-
build-backend = "hatchling.build"
2+
requires = ["uv_build>=0.12.3,<0.13"]
3+
build-backend = "uv_build"
44

55
[project]
66
name = "debugger"
77
version = "0.1.0"
88
requires-python = ">=3.13,<3.14"
9+
dependencies = [
10+
"aiofiles >=25, <26",
11+
"python-socketio >=5.16, <5.17",
12+
"uvicorn==0.52.0",
13+
"pydantic >=2, <3",
14+
"orjson >=3, <4",
15+
"pyroscope-io >=1, <2"
16+
]
917

10-
[project.scripts]
11-
check = "pyproject_commands:check"
18+
[dependency-groups]
19+
dev = [
20+
"pytest >=9.1, <9.2",
21+
"mypy >=2.3, <2.4",
22+
"ruff==0.16.2"
23+
]
1224

13-
[tool.hatch.build.targets.wheel]
14-
packages = []
15-
only-include = ["pyproject_commands.py"]
16-
17-
[tool.mypy]
18-
check_untyped_defs = true

debugger/pyproject_commands.py

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

debugger/requirements-dev.txt

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

debugger/requirements.txt

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

0 commit comments

Comments
 (0)