Skip to content

Commit

Permalink
chore: attempt at migrating to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
eMerzh committed Oct 1, 2024
1 parent 37e94e3 commit 6ee5ce6
Show file tree
Hide file tree
Showing 8 changed files with 410 additions and 677 deletions.
37 changes: 24 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
FROM python:3.12-slim@sha256:f11725aba18c19664a408902103365eaf8013823ffc56270f921d1dc78a198cb
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Install the project into `/app`
WORKDIR /app

# Install poetry and virtualenv
COPY poetry-requirements.txt pip-requirements.txt /
RUN pip install --no-cache-dir -r /poetry-requirements.txt -r pip-requirements.txt \
&& rm -rf /root/.cache
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

# Setup our virtualenv workdir and PATH
WORKDIR /app
ENV POETRY_VIRTUALENVS_CREATE false
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy

# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-dev

# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev

COPY pyproject.toml .
COPY poetry.lock .
# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"

RUN poetry install --only main \
&& rm -rf /root/.cache
# Reset the entrypoint, don't invoke `uv`
ENTRYPOINT []

COPY launch.sh dev-sync.py /app/

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Installation

poetry install
poetry shell
uv sync

poetry run python dev-sync.py from_github --dry-run to_test
uv run dev-sync.py from_github --dry-run to_test
23 changes: 13 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,24 @@ outputs:
runs:
using: "composite"
steps:
- name: Install Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.12"
# Install a specific version of uv.
version: "0.4.17"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install poetry
shell: bash
run: pip install poetry -r ${{github.action_path}}/poetry-requirements.txt
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: Install dependencies
shell: bash
run: poetry install -C ${{github.action_path}} --only main
- name: Install the project
run: uv sync --all-extras --dev

- name: Run dev-sync script
run: poetry run -C ${{github.action_path}} python ${{github.action_path}}/dev-sync.py from_github to_zendesk to_slack
run: uv run dev-sync.py from_github to_zendesk to_slack
shell: bash
env:
FROM_REF: ${{ inputs.from_ref }}
Expand Down
3 changes: 0 additions & 3 deletions pip-requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions poetry-requirements.txt

This file was deleted.

629 changes: 0 additions & 629 deletions poetry.lock

This file was deleted.

33 changes: 16 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[tool.poetry]
package-mode = false

[tool.poetry.dependencies]
python = ">= 3.12, < 3.13"
requests = { extras = ["security"], version = "==2.32.3" }
click = "==8.1.7"
werkzeug = "==3.0.4"
python-dotenv = "==1.0.1"
PyGithub = "==2.4.0"
semver = "==3.0.2"

[tool.poetry.dev-dependencies]
ruff = "0.6.8"
[project]
name = "toolsync"
version = "0.1.0"
description = "sync issue & deploy status between external tools"
requires-python = ">=3.12"
readme = "README.md"
dependencies = [
"click>=8.1.7",
"pygithub>=2.4.0",
"python-dotenv>=1.0.1",
"requests[security]>=2.32.3",
"semver>=3.0.2",
"werkzeug>=3.0.4",
]

[tool.ruff]
line-length = 120
Expand Down Expand Up @@ -64,6 +64,5 @@ reportUnnecessaryTypeIgnoreComment = true
reportShadowedImports = true
reportMissingTypeStubs = false

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.uv]
dev-dependencies = ["ruff>=0.6.8"]
355 changes: 355 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

0 comments on commit 6ee5ce6

Please sign in to comment.