Skip to content

Commit 84fe7be

Browse files
authored
fix CI for uv (#218)
1 parent e014a42 commit 84fe7be

File tree

6 files changed

+81
-386
lines changed

6 files changed

+81
-386
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ jobs:
1212
strategy:
1313
max-parallel: 4
1414
matrix:
15-
python-version: ["3.9", "3.10", "3.11"]
15+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1616

1717
steps:
1818
- uses: actions/checkout@v4
19-
- uses: actions/setup-python@v5
19+
- uses: astral-sh/setup-uv@v5
2020
with:
21+
enable-cache: true
2122
python-version: ${{ matrix.python-version }}
2223

2324
- name: Install tokenizers
@@ -31,21 +32,16 @@ jobs:
3132
git apply ./24.patch && ./configure && \
3233
sudo make && sudo make install && sudo ldconfig -v
3334
34-
- run: python -m pip install --upgrade pip
35-
- run: pip install .[all]
35+
- name: Install dependencies
36+
run: uv sync --group dev --all-extras
3637

3738
- run: |
38-
pip install ruff
39-
ruff check src
40-
ruff format --diff src
39+
uv run ruff check src
40+
uv run ruff format --diff src
4141
42-
- run: |
43-
pip install mypy types-requests
44-
mypy src
42+
- run: uv run mypy src
4543

46-
- run: |
47-
pip install pytest httpx
48-
pytest
44+
- run: uv run pytest
4945
env:
5046
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
5147
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

Dockerfile

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ RUN apt update -y \
1919
python3-pip \
2020
&& rm -rf /var/lib/apt/lists/*
2121

22+
# uv
23+
COPY --from=ghcr.io/astral-sh/uv:0.6.17 /uv /uvx /bin/
24+
2225
WORKDIR /tmp
2326

2427
# kytea
@@ -32,18 +35,29 @@ RUN tar zxvf kytea-0.4.7.tar.gz \
3235

3336
WORKDIR /work
3437

35-
COPY ./data ./data
36-
COPY ./src ./src
37-
COPY ./pyproject.toml ./pyproject.toml
38-
COPY ./requirements.lock ./requirements.lock
39-
COPY ./README.md ./README.md
38+
ENV UV_COMPILE_BYTECODE=1
39+
ENV UV_LINK_MODE=copy
40+
41+
# install dependencies
42+
RUN --mount=type=cache,target=/root/.cache/uv \
43+
--mount=type=bind,source=uv.lock,target=uv.lock \
44+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
45+
uv sync --frozen --no-install-project --no-dev
46+
47+
ADD ./data /work
48+
ADD ./src /work
49+
ADD ./pyproject.toml /work
50+
ADD ./uv.lock /work
51+
ADD ./README.md /work
52+
53+
# install project
54+
RUN --mount=type=cache,target=/root/.cache/uv \
55+
uv sync --frozen --no-dev --all-extras
4056

41-
RUN python3.10 -m pip install -U pip
42-
RUN python3.10 -m pip install -r requirements.lock
43-
RUN python3.10 -m pip install .
57+
ENV PATH="/work/.venv/bin:$PATH"
4458

4559
CMD [ \
46-
"python3.10", "-m", "uvicorn", \
60+
"uvicorn", \
4761
"--factory", "konoha.api.server:create_app", \
4862
"--reload", "--host", "0.0.0.0", "--port", "8000" \
4963
]

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,19 @@ module = [
7171
]
7272
ignore_missing_imports = true
7373

74-
[tool.uv]
75-
dev-dependencies = [
74+
[dependency-groups]
75+
dev = [
7676
"pytest>=8.2.0",
7777
"httpx>=0.27.0",
7878
"ruff>=0.4.4",
7979
"mypy>=1.10.0",
8080
"sphinx>=7.3.7",
8181
"pydata-sphinx-theme>=0.16.1",
82+
"types-requests>=2.31.0.6",
8283
]
8384

85+
[tool.uv]
86+
default-groups = ["dev"]
87+
8488
[tool.ruff]
8589
line-length = 119

requirements-dev.lock

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

0 commit comments

Comments
 (0)