Skip to content

Commit 4b0d4bb

Browse files
committed
Switch from poetry to uv
1 parent 3a591f9 commit 4b0d4bb

File tree

13 files changed

+436
-615
lines changed

13 files changed

+436
-615
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515
permissions:
1616
pull-requests: write
1717
contents: write
18+
env:
19+
# Configure a constant location for the uv cache
20+
UV_CACHE_DIR: /tmp/.uv-cache
21+
1822
steps:
1923
- name: Checkout
2024
uses: actions/checkout@v4
@@ -24,23 +28,17 @@ jobs:
2428
with:
2529
python-version: "3.12"
2630

27-
- name: Install Poetry
28-
# https://github.com/pypa/pipx/issues/1195
29-
run: |
30-
pipx install poetry --python="$(command -v python3.12)"
31-
32-
- name: Poetry caches
31+
- name: Restore uv cache
3332
uses: actions/cache@v4
3433
with:
35-
path: |
36-
~/.cache/
37-
key: ${{ hashFiles('poetry.lock') }}
38-
39-
- name: Install deps
40-
run: poetry install
34+
path: /tmp/.uv-cache
35+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
36+
restore-keys: |
37+
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
38+
uv-${{ runner.os }}
4139
4240
- name: Run tests
43-
run: poetry run pytest
41+
run: pipx run uv run pytest
4442
env:
4543
COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1 }}
4644
COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_2: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_2 }}
@@ -60,3 +58,6 @@ jobs:
6058
with:
6159
name: python-coverage-comment-action
6260
path: python-coverage-comment-action.txt
61+
62+
- name: Minimize uv cache
63+
run: pipx run uv cache prune --ci

.github/workflows/e2e-external-phase-2.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,17 @@ jobs:
9393
with:
9494
python-version: "3.12"
9595

96-
- name: Install Poetry
97-
# https://github.com/pypa/pipx/issues/1195
98-
run: |
99-
pipx install poetry --python="$(command -v python3.12)"
100-
101-
- name: Poetry caches
96+
- name: Restore uv cache
10297
uses: actions/cache@v4
10398
with:
104-
path: |
105-
~/.cache/
106-
key: ${{ hashFiles('poetry.lock') }}
107-
108-
- name: Install deps
109-
run: poetry install
99+
path: /tmp/.uv-cache
100+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
101+
restore-keys: |
102+
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
103+
uv-${{ runner.os }}
110104
111105
- name: Run end-to-end tests
112-
run: poetry run pytest tests/end_to_end
106+
run: pipx run uv run pytest tests/end_to_end
113107
env:
114108
COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1 }}
115109
COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_2: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_2 }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
dev-env-vars
55
.coverage*
66
__pycache__
7+
.venv
8+
*.egg-info

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,3 @@ repos:
2323
- id: ruff
2424
args: [ --fix ]
2525
- id: ruff-format
26-
27-
- repo: https://github.com/floatingpurr/sync_with_poetry
28-
rev: 1.1.0
29-
hooks:
30-
- id: sync_with_poetry

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ You're welcome to contribute, though I can't promise the experience will be as s
55
### Things to know:
66

77
- Python3.12
8-
- Use [Poetry](https://python-poetry.org/)
8+
- Use [uv](https://docs.astral.sh/uv/)
99
- Launch tests with `pytest`, config is in setup.cfg
1010
- `ruff` runs through `pre-commit`, so you can install hooks with `pre-commit install`.
1111
- `docker`. Classic stuff.
@@ -17,10 +17,12 @@ Use:
1717
```console
1818
$ source ./dev-env
1919
```
20+
2021
This should take care of everything and will display instructions.
2122
Feel free to read the script yourself to see what it does.
2223

2324
You'll need a GitHub token to test the action locally. You have 3 choices:
25+
2426
- Before launching `dev-env`, copy `dev-env-vars.dist` to `dev-env-vars` and
2527
set your token
2628
- After launching `dev-env`, run `token-from-gh` to reuse your `gh` token
@@ -30,6 +32,7 @@ You'll need a GitHub token to test the action locally. You have 3 choices:
3032
personal access token (feel free to then save it to `dev-env-vars`)
3133

3234
#### Manually
35+
3336
```console
3437
$ # Either push (compute & post badge), pull_request (compute comment) or workflow_run (post comment)
3538
$ export GITHUB_EVENT_NAME=workflow_run
@@ -44,7 +47,8 @@ $ export GITHUB_REPOSITORY=py-cov-action/python-coverage-comment-action-v3-examp
4447
$ # Used everywhere. Generate at https://github.com/settings/tokens/new?scopes=repo&description=test%20python-coverage-comment-action
4548
$ export GITHUB_TOKEN=
4649
```
47-
Then either launch with `poetry run coverage_comment` or through docker.
50+
51+
Then either launch with `uv run coverage_comment` or through docker.
4852

4953
### End to end tests
5054

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# See Dockerfile.build for instructions on bumping this.
2-
FROM ewjoachim/python-coverage-comment-action-base:v6
2+
FROM docker.io/ewjoachim/python-coverage-comment-action-base:v7
33

4-
COPY coverage_comment ./coverage_comment
5-
RUN md5sum -c pyproject.toml.md5 || pip install -e .
4+
COPY coverage_comment ./
5+
COPY pyproject.toml ./
6+
RUN md5sum -c pyproject.toml.md5 || uv pip install --editable .

Dockerfile.build

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# - Dockerfile
33
# - .github/workflows/release.yml
44

5-
FROM python:3.12-slim
5+
FROM docker.io/library/python:3.12-slim
6+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
67

78
RUN set -eux; \
89
apt-get update; \
@@ -18,10 +19,10 @@ COPY pyproject.toml ./
1819
RUN md5sum pyproject.toml > pyproject.toml.md5
1920

2021
COPY coverage_comment ./coverage_comment
21-
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
22-
ENV PIP_ROOT_USER_ACTION=ignore
2322
ENV PIP_NO_CACHE_DIR=off
2423

25-
RUN pip install -e .
24+
ENV PATH="/venv/bin:$PATH"
25+
ENV VIRTUAL_ENV="/venv"
26+
RUN uv venv /venv && uv pip install --no-cache --editable .
2627

2728
CMD [ "coverage_comment" ]

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
graft coverage_comment/template_files

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: install
22
install: ## install dependencies
3-
poetry install --with dev
3+
uv sync
44
pre-commit install
55

66
.PHONY: lint
@@ -9,4 +9,4 @@ lint: ## lint code
99

1010
.PHONY: test
1111
test: ## run all tests
12-
poetry run pytest tests
12+
uv run pytest tests

dev-env

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
# We're doing our best to keep it compatible with bash and zsh.
55

6-
if ! which poetry; then
7-
echo "This script needs poetry installed. Either follow the official method: https://python-poetry.org/docs/#installation or use pipx https://pypa.github.io/pipx/installation/" &>2
6+
if ! which uv; then
7+
echo "This script needs uv installed. See installation instructions: https://docs.astral.sh/uv/getting-started/installation/" &>2
88
return
99
fi
1010

@@ -29,10 +29,10 @@ else
2929
fi
3030

3131
echo "Installing virtualenv" >&2
32-
poetry install
32+
uv sync
3333

3434
echo "Activating virtualenv" >&2
35-
source $(poetry env info -p)/bin/activate
35+
source .venv/bin/activate
3636

3737
echo "Moving to a temporary folder" >&2
3838
TMPDIR=$(mktemp -d)

0 commit comments

Comments
 (0)