Skip to content

Commit bd8f015

Browse files
authored
migrate from pipenv to uv (#8)
1 parent 2179c1f commit bd8f015

12 files changed

Lines changed: 939 additions & 599 deletions

File tree

.github/workflows/publish-dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
version: '${{ github.run_number }}.0.0'
1919
repository: testpypi
2020
secrets:
21-
twine_username: ${{ secrets.TESTPYPI_USERNAME }}
22-
twine_password: ${{ secrets.TESTPYPI_TOKEN }}
21+
twine_token: ${{ secrets.TESTPYPI_TOKEN }}
22+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2323

2424
build_image:
2525
# TODO: remove this entire job if an image does not make sense (ie: just a library, no CLI)

.github/workflows/publish-main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
# so easy to forget bumping the version to match the tag, just override it!
1313
version: ${{ github.ref_name }}
1414
secrets:
15-
twine_username: ${{ secrets.PYPI_USERNAME }}
16-
twine_password: ${{ secrets.PYPI_TOKEN }}
15+
twine_token: ${{ secrets.PYPI_TOKEN }}
16+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1717

1818
build_image:
1919
# TODO: remove this entire job if an image does not make sense (ie: just a library, no CLI)

.github/workflows/publish.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,31 @@ on:
1010
default: pypi
1111
type: string
1212
secrets:
13-
twine_username:
13+
twine_token:
1414
required: true
15-
twine_password:
15+
CODECOV_TOKEN:
16+
required: false
17+
workflow_dispatch:
18+
inputs:
19+
version:
20+
description: 'Version to publish (for example: 1.2.3)'
21+
type: string
1622
required: true
23+
repository:
24+
description: 'Package index repository'
25+
type: choice
26+
options:
27+
- pypi
28+
- testpypi
29+
default: pypi
1730

1831
run-name: publish to ${{ inputs.repository }}
1932

2033
jobs:
2134
test:
2235
uses: ./.github/workflows/test.yml
36+
secrets:
37+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2338

2439
publish:
2540
name: publish to ${{ inputs.repository }}
@@ -36,21 +51,20 @@ jobs:
3651

3752
- name: Install dependencies
3853
run: |
39-
pip install pipenv
40-
pipenv requirements --dev > reqs.txt
41-
pip install -r reqs.txt
54+
pip install uv
55+
uv sync --group dev
4256
- name: force right version
4357
run: |
4458
.github/change_version.py --set '${{ inputs.version }}'
4559
- name: Build
46-
run: pyproject-build
60+
run: uv run pyproject-build
4761
- name: Publish
4862
env:
49-
TWINE_USERNAME: ${{ secrets.twine_username }}
50-
TWINE_PASSWORD: ${{ secrets.twine_password }}
63+
TWINE_USERNAME: __token__
64+
TWINE_PASSWORD: ${{ secrets.twine_token }}
5165
run: |
52-
pyproject-build
53-
twine upload --repository ${{ inputs.repository }} dist/*
66+
uv run pyproject-build
67+
uv run twine upload --verbose --repository ${{ inputs.repository }} dist/*
5468
- name: highlight
5569
# TODO: update package name in summary text
5670
run: |

.github/workflows/test.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: 🧪 tests
22

33
on:
44
workflow_call:
5+
secrets:
6+
CODECOV_TOKEN:
7+
required: false
58
push:
69
branches-ignore:
710
# these are already tested by publish-dev
@@ -23,9 +26,8 @@ jobs:
2326

2427
- name: Install dependencies
2528
run: |
26-
pip install pipenv
27-
pipenv requirements --dev > reqs.txt
28-
pip install -r reqs.txt
29+
pip install uv
30+
uv sync --group dev
2931
3032
- name: Lint check
3133
id: lint-check
@@ -39,15 +41,10 @@ jobs:
3941
make test
4042
4143
- name: Upload results to Codecov
42-
uses: codecov/codecov-action@v4
43-
with:
44-
token: ${{ secrets.CODECOV_TOKEN }}
45-
46-
- name: Upload test results to Codecov
47-
if: ${{ !cancelled() }}
48-
uses: codecov/test-results-action@v1
44+
uses: codecov/codecov-action@v5
4945
with:
5046
token: ${{ secrets.CODECOV_TOKEN }}
47+
report_type: test_results
5148

5249
- name: Final check
5350
if: ${{ steps.lint-check.outcome == 'failure' }}

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
## Build
22

3-
This project uses a `Pipfile`, so set up the virtualenv by running
3+
This project uses `uv`, so set up the virtualenv by running
44

55
```
6-
pipenv install --dev
6+
uv sync --group dev
77
```
88

99
Use `make test` to make sure all tests pass before pushing.
@@ -12,4 +12,4 @@ Use `make lint` to make sure lint check passes before pushing.
1212

1313
## Guidelines
1414

15-
...
15+
...

Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ FROM python:3.10-alpine AS base
44
# --- builder
55
FROM base AS builder
66
WORKDIR /app
7-
WORKDIR /
8-
9-
COPY Pipfile.lock .
10-
RUN pip install pipenv
11-
RUN pipenv requirements > requirements.txt
12-
RUN pip install --target=/app -r requirements.txt
7+
RUN pip install uv
8+
# TODO: replace with your package name
9+
COPY example /src/example
10+
COPY pyproject.toml README.md /src/
11+
RUN uv pip install --target=/app /src
1312

1413
# --- main
1514
FROM base
1615
COPY --from=builder /app /app
1716
ENV PYTHONPATH=/app
18-
# TODO: replace with your package name
19-
COPY example /app/example
2017

18+
# TODO: replace with your package name
2119
ENTRYPOINT ["python3", "-m", "example"]

Makefile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
lint:
2-
ruff format
3-
ruff check --fix
4-
pyproject-pipenv --fix
2+
uv run ruff format
3+
uv run ruff check --fix
54

65
lint-check:
7-
ruff format --diff
8-
ruff check
9-
pyproject-pipenv
6+
uv run ruff format --diff
7+
uv run ruff check
108

119
test:
1210
if [ -n "$(GITHUB_RUN_ID)" ]; then \
13-
pytest --cov --cov-report=xml --junitxml=junit.xml -o junit_family=legacy; \
11+
uv run pytest --cov --cov-report=xml --junitxml=junit.xml -o junit_family=legacy; \
1412
else \
15-
python -m pytest --cov; \
13+
uv run python -m pytest --cov; \
1614
fi
1715

1816
testpub:
1917
rm -fr dist
20-
pyproject-build
21-
twine upload --repository testpypi dist/*
18+
uv run pyproject-build
19+
uv run twine upload --repository testpypi dist/*

Pipfile

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

0 commit comments

Comments
 (0)