Skip to content

Commit 93a5607

Browse files
authored
move to uv (#241)
1 parent 5ff97b9 commit 93a5607

8 files changed

Lines changed: 524 additions & 954 deletions

File tree

auto-tagger/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.venv
2+
.mypy_cache
3+
.ruff_cache

auto-tagger/Dockerfile

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
FROM python:3.13-alpine AS builder
22
HEALTHCHECK NONE
33

4-
ENV PATH="${PATH}:/app/.local/bin" \
5-
POETRY_VERSION=2.1.2 \
6-
PYTHONDONTWRITEBYTECODE=1 \
7-
POETRY_CACHE_DIR=/app/.cache \
8-
POETRY_NO_INTERACTION=1 \
9-
POETRY_VIRTUALENVS_IN_PROJECT=1 \
10-
POETRY_VIRTUALENVS_CREATE=1
4+
ENV UV_LINK_MODE=copy \
5+
UV_COMPILE_BYTECODE=1 \
6+
UV_PYTHON_DOWNLOADS=never \
7+
UV_PYTHON=python3.13 \
8+
UV_NO_PROGRESS=1
119

12-
# kics-scan ignore-line
13-
RUN apk add --no-cache musl-dev libffi-dev gcc
14-
RUN addgroup -g 1000 app && adduser -G app -u 999 -s /sbin/nologin -h /app app -D
10+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
1511
WORKDIR /app
16-
COPY pyproject.toml poetry.lock ./
17-
RUN chmod -R a+r .
18-
USER app
19-
RUN pip install poetry==${POETRY_VERSION} --no-cache-dir
20-
RUN poetry install --only main
12+
RUN --mount=type=cache,target=/root/.cache \
13+
--mount=type=bind,source=uv.lock,target=uv.lock \
14+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
15+
uv sync \
16+
--locked \
17+
--no-dev \
18+
--no-install-project --no-editable
19+
COPY pyproject.toml uv.lock ./
20+
COPY *.py ./
21+
RUN --mount=type=cache,target=/root/.cache/uv \
22+
uv sync --locked --no-editable --no-dev
2123

2224
FROM python:3.13-alpine AS runtime
2325
HEALTHCHECK NONE
2426

25-
ENV VIRTUAL_ENV=/app/.venv \
26-
PATH="/app/.venv/bin:${PATH}"
27+
ENV PATH="/app/.venv/bin:${PATH}"
2728

2829
RUN addgroup -g 1000 app && adduser -G app -u 999 -s /sbin/nologin -h /app app -D
2930
WORKDIR /app
30-
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
31-
COPY *.py ./
31+
COPY --from=builder /app /app
3232
RUN chmod -R a+r .
33-
USER app
3433
LABEL org.opencontainers.image.source=https://github.com/notdodo/github-actions/tree/main/auto-tagger
3534
LABEL org.opencontainers.image.description="A GitHub Action to automatically bump and/or create tags upon push to the default branch, using SemVer formatting."
3635

37-
CMD ["python", "/app/main.py"]
36+
USER app
37+
CMD ["python", "-OO", "/app/main.py"]

auto-tagger/Taskfile.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ tasks:
1212
install:
1313
desc: Install Python dependencies
1414
cmds:
15-
- poetry install --no-root
15+
- uv sync
1616

1717
format:
1818
desc: Format repository code
1919
cmds:
20-
- poetry run ruff format
21-
- poetry run ruff check --fix
20+
- uv run ruff format
21+
- uv run ruff check --fix
2222

2323
format-check:
2424
desc: Check the code format (without modifying)
2525
cmds:
26-
- poetry run ruff format --check
26+
- uv run ruff format --check
2727

2828
lint:
2929
desc: Run lint checks
3030
cmds:
31-
- poetry run ruff check
31+
- uv run ruff check
3232

3333
type-check:
3434
desc: Run static type checks
3535
cmds:
36-
- poetry run mypy .
36+
- uv run mypy .
3737

3838
check:
3939
desc: Run formatting check, lint, and type checks
@@ -42,4 +42,4 @@ tasks:
4242
test:
4343
desc: Run all tests
4444
cmds:
45-
- poetry run pytest
45+
- uv run pytest

auto-tagger/github_helpers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import copy
66
import os
7-
from datetime import datetime, timedelta, timezone
7+
from datetime import UTC, datetime, timedelta
88

99
from github import Github, InputGitAuthor
1010
from semver import Version, VersionInfo
@@ -17,6 +17,7 @@ class GitHubHelper:
1717
"""PyGitHub support class"""
1818

1919
def __init__(self, token: str, config: Configuration) -> None:
20+
"""init class"""
2021
self.token = token
2122
self.config = config
2223
self.repo = Github(token).get_repo(self.config.REPOSITORY)
@@ -148,7 +149,7 @@ def create_git_tag(self, tag: Tag) -> None:
148149
tagger=InputGitAuthor(
149150
name=str(commit.author.name),
150151
email=str(commit.author.email),
151-
date=str(datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")),
152+
date=str(datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ")),
152153
),
153154
)
154155
self.repo.create_git_ref(f"refs/tags/{tag.name}", tag.commit)

auto-tagger/github_resources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from dataclasses import dataclass, field
6-
from datetime import datetime, timezone
6+
from datetime import UTC, datetime
77

88

99
@dataclass
@@ -19,7 +19,7 @@ class Commit:
1919

2020
def now_utf() -> datetime:
2121
"""Factory for Datetime"""
22-
return datetime.now(timezone.utc)
22+
return datetime.now(UTC)
2323

2424

2525
@dataclass

auto-tagger/poetry.lock

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

auto-tagger/pyproject.toml

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
[tool.poetry]
1+
[project]
22
name = "auto-tagger"
33
version = "0.1.0"
44
description = "A GitHub Action to automatically bump and/or create tags upon push to the default branch, using SemVer formatting."
5-
authors = ["notdodo"]
5+
authors = [
6+
{ name = "notdodo", email = "6991986+notdodo@users.noreply.github.com" },
7+
]
8+
requires-python = ">3.12.0"
69
readme = "README.md"
7-
package-mode = false
10+
dependencies = ["pygithub>=2.7.0", "semver>=3.0.4"]
11+
12+
[dependency-groups]
13+
dev = [
14+
"mypy[faster-cache]>=1.17.1,<2",
15+
"ruff>=0.12.7,<0.13",
16+
"pydantic>=2.11.7,<3",
17+
]
818

9-
[tool.poetry.dependencies]
10-
python = "^3.11"
11-
pygithub = "^2.7.0"
12-
semver = "^3.0.4"
19+
[tool.uv]
20+
package = false
1321

14-
[tool.poetry.group.dev.dependencies]
15-
mypy = { extras = ["faster-cache"], version = "^1.17.1" }
16-
pydantic = "^2.11.7"
17-
pylint = "^3.3.8"
18-
ruff = "^0.12.10"
22+
[build-system]
23+
requires = ["hatchling"]
24+
build-backend = "hatchling.build"
1925

2026
[tool.ruff]
2127
output-format = "github"
@@ -24,17 +30,7 @@ output-format = "github"
2430
fixable = ["ALL"]
2531
unfixable = []
2632
select = ["ALL"]
27-
ignore = [
28-
"D2",
29-
"D4",
30-
"ANN",
31-
"COM812",
32-
"D107",
33-
"ISC001",
34-
"ERA001",
35-
"N803",
36-
"T201",
37-
]
33+
ignore = ["D2", "D4", "ANN", "COM812", "ISC001", "ERA001", "PLR0913", "T201"]
3834

3935
[tool.ruff.format]
4036
docstring-code-format = true
@@ -60,7 +56,3 @@ namespace_packages = true
6056
[tool.pylint."MESSAGES CONTROL"]
6157
persistent = "no"
6258
disable = ["fixme", "line-too-long"]
63-
64-
[build-system]
65-
requires = ["poetry-core"]
66-
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)