Skip to content

Commit 94922b3

Browse files
authored
Switch to uv (#69)
* Initial uv switch * Fix import sorts * Update Justfile * CI * CI * CI * Docs * Fix docs * Tweak test * Limit permissions * Set up doctests for future * Coverage patch * Fail under 98% * Pin action * Pin action * Changelog * Bump pypa/gh-action-pypi-publish
1 parent 223c8b3 commit 94922b3

File tree

19 files changed

+2947
-2526
lines changed

19 files changed

+2947
-2526
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
name: CI
33

4+
permissions: {}
5+
46
on:
57
push:
68
branches: ["main"]
@@ -17,28 +19,24 @@ jobs:
1719
matrix:
1820
python-version: ["3.11", "3.12", "3.13", "3.14"]
1921
redis-version: [6]
22+
fail-fast: false
2023

2124
steps:
2225
- uses: "actions/checkout@v4"
23-
24-
- uses: "pdm-project/setup-pdm@v4"
2526
with:
26-
python-version: "${{ matrix.python-version }}"
27-
allow-python-prereleases: true
28-
cache: true
29-
version: "2.25.9"
27+
persist-credentials: false
28+
29+
- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3.0.0
30+
- uses: hynek/setup-cached-uv@757bedc3f972eb7227a1aa657651f15a8527c817 # v2.3.0
3031

3132
- name: "Start Redis"
32-
uses: "supercharge/redis-github-action@1.2.0"
33+
uses: "supercharge/redis-github-action@ea9b21c6ecece47bd99595c532e481390ea0f044" # 1.8.0
3334
with:
3435
redis-version: "${{ matrix.redis-version }}"
3536

36-
- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3.0.0
37-
38-
- name: "Run Tox"
37+
- name: "Run Tests"
3938
run: |
40-
python -Im pip install --upgrade tox tox-gh-actions
41-
python -Im tox
39+
just python=${{ matrix.python-version }} covcleanup="false" cov
4240
4341
- name: Upload coverage data
4442
uses: actions/upload-artifact@v4
@@ -55,34 +53,31 @@ jobs:
5553

5654
steps:
5755
- uses: "actions/checkout@v4"
58-
59-
- uses: "actions/setup-python@v5"
6056
with:
61-
cache: "pip"
62-
python-version: "3.12"
63-
64-
- run: "python -Im pip install --upgrade coverage[toml]"
57+
persist-credentials: false
6558

6659
- name: Download coverage data
6760
uses: actions/download-artifact@v4
6861
with:
6962
pattern: coverage-data-*
7063
merge-multiple: true
64+
65+
- uses: hynek/setup-cached-uv@757bedc3f972eb7227a1aa657651f15a8527c817 # v2.3.0
7166

7267
- name: "Combine coverage"
7368
run: |
74-
python -Im coverage combine
75-
python -Im coverage html --skip-covered --skip-empty
76-
python -Im coverage json
69+
uv run --group test coverage combine
70+
uv run --group test coverage html
71+
uv run --group test coverage json
7772
7873
# Report and write to summary.
79-
python -Im coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
74+
uv run --group test coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
8075
81-
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
76+
export TOTAL=$(uv run python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
8277
echo "total=$TOTAL" >> $GITHUB_ENV
8378
8479
# Report again and fail if under the threshold.
85-
python -Im coverage report --fail-under=97
80+
uv run --group test coverage report --fail-under=98
8681
8782
- name: "Upload HTML report."
8883
uses: "actions/upload-artifact@v4"
@@ -105,28 +100,40 @@ jobs:
105100
maxColorRange: 90
106101
valColorRange: ${{ env.total }}
107102

103+
lint:
104+
name: "Run linters"
105+
runs-on: "ubuntu-latest"
106+
steps:
107+
- uses: "actions/checkout@v4"
108+
with:
109+
persist-credentials: false
110+
111+
- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3.0.0
112+
- uses: hynek/setup-cached-uv@757bedc3f972eb7227a1aa657651f15a8527c817 # v2.3.0
113+
114+
- name: "Run linters"
115+
run: |
116+
just lint
117+
108118
package:
109119
name: "Build & verify package"
110120
runs-on: "ubuntu-latest"
111121

112122
steps:
113-
- uses: "actions/checkout@v3"
114-
115-
- uses: "actions/setup-python@v4"
123+
- uses: "actions/checkout@v4"
116124
with:
117-
python-version: "3.11"
125+
persist-credentials: false
118126

119-
- name: "Install tools"
120-
run: "python -m pip install twine check-wheel-contents build"
127+
- uses: hynek/setup-cached-uv@757bedc3f972eb7227a1aa657651f15a8527c817
121128

122129
- name: "Build package"
123-
run: "python -m build"
130+
run: "uvx --from build pyproject-build"
124131

125132
- name: "List result"
126133
run: "ls -l dist"
127134

128135
- name: "Check wheel contents"
129-
run: "check-wheel-contents dist/*.whl"
136+
run: "uvx check-wheel-contents dist/*.whl"
130137

131138
- name: "Check long_description"
132-
run: "python -m twine check dist/*"
139+
run: "uvx twine check dist/*"

.github/workflows/pypi-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
path: dist
4444

4545
- name: Upload package to Test PyPI
46-
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
46+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
4747
with:
4848
repository-url: https://test.pypi.org/legacy/
4949

@@ -65,4 +65,4 @@ jobs:
6565
path: dist
6666

6767
- name: Upload package to PyPI
68-
uses: pypa/gh-action-pypi-publish@release/v1
68+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

.readthedocs.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ build:
88
tools:
99
python: "3.13"
1010
jobs:
11+
create_environment:
12+
- asdf plugin add uv
13+
- asdf plugin add just
14+
- asdf install uv latest
15+
- asdf global uv latest
16+
- asdf install just latest
17+
- asdf global just latest
18+
install:
19+
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --group docs --all-extras --link-mode=copy
1120
post_install:
12-
- "curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -"
13-
- "VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH ~/.local/bin/pdm sync -dG docs"
21+
# Need the tags to calculate the version
22+
- git fetch --tags
23+
build:
24+
html:
25+
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH just docs $READTHEDOCS_OUTPUT

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The **third number** is for emergencies when we need to start branches for older
1010

1111
<!-- changelog follows -->
1212

13-
## [v24.1.0](https://github.com/tinche/uapi/compare/v23.3.0...HEAD) - UNRELEASED
13+
## [v25.1.0](https://github.com/tinche/uapi/compare/v23.3.0...HEAD) - UNRELEASED
1414

1515
### Added
1616

@@ -24,6 +24,8 @@ The **third number** is for emergencies when we need to start branches for older
2424
([#60](https://github.com/Tinche/uapi/pull/60) [#65](https://github.com/Tinche/uapi/pull/65))
2525
- Python 3.10 is no longer supported.
2626
([#65](https://github.com/Tinche/uapi/pull/65)
27+
- Switch to [`uv`](https://docs.astral.sh/uv/) and [`just`](https://just.systems/man/en/) in lieu of PDM, tox and Make.
28+
([#69](https://github.com/Tinche/uapi/pull/69))
2729

2830
## [v23.3.0](https://github.com/tinche/uapi/compare/v23.2.0...v23.3.0) - 2023-12-20
2931

@@ -38,6 +40,7 @@ The **third number** is for emergencies when we need to start branches for older
3840
- _uapi_ is now tested against Mypy.
3941
([#57](https://github.com/Tinche/uapi/pull/57))
4042

43+
4144
## [v23.2.0](https://github.com/tinche/uapi/compare/v23.1.0...v23.2.0) - 2023-12-10
4245

4346
### Changed

Justfile

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
1+
python := ""
2+
covcleanup := "true"
3+
4+
sync version="":
5+
uv sync {{ if python != '' { '-p ' + python } else if version != '' { '-p ' + version } else { '' } }} --all-groups --all-extras
6+
17
test *args='tests -x --ff --mypy-only-local-stub -n auto':
2-
pdm run pytest {{args}}
8+
uv run pytest {{args}}
9+
10+
lint: sync
11+
uv run mypy src/ tests/ && uv run ruff check src/ tests/ && uv run black --check src/ tests/
12+
13+
cov *args="-x --ff --mypy-only-local-stub -n auto tests":
14+
uv run {{ if python != '' { '-p ' + python } else { '' } }} --all-extras --group frameworks --group test --group lint coverage run -m pytest {{args}}
15+
{{ if covcleanup == "true" { "uv run coverage combine" } else { "" } }}
16+
{{ if covcleanup == "true" { "uv run coverage report" } else { "" } }}
17+
{{ if covcleanup == "true" { "@rm .coverage*" } else { "" } }}
18+
19+
covall:
20+
just python=python3.11 covcleanup=false cov
21+
just python=python3.12 covcleanup=false cov
22+
just python=python3.13 covcleanup=false cov
23+
just python=python3.14 covcleanup=false cov
24+
uv run coverage combine
25+
uv run coverage report
26+
@rm .coverage*
327

4-
lint:
5-
pdm run mypy src/ tests/ && pdm run ruff check src/ tests/ && pdm run black --check src/ tests/
28+
docs output_dir="_build": ## generate Sphinx HTML documentation, including API docs
29+
make -C docs -e BUILDDIR={{output_dir}} clean
30+
make -C docs -e BUILDDIR={{output_dir}} doctest
31+
make -C docs -e BUILDDIR={{output_dir}} html

docs/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# You can set these variables from the command line, and also
55
# from the environment for the first two.
66
SPHINXOPTS ?=
7-
SPHINXBUILD ?= pdm run sphinx-build -M
7+
SPHINXBUILD ?= uv run --group docs sphinx-build -M
88
SOURCEDIR = .
99
BUILDDIR = _build
1010

@@ -20,10 +20,10 @@ help:
2020
$(SPHINXBUILD) $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2121

2222
apidoc:
23-
pdm run sphinx-apidoc -o . ../src/uapi -f
23+
uv run --group docs sphinx-apidoc -o . ../src/uapi -f
2424

2525
## htmllive to rebuild and reload HTML files in your browser
2626
.PHONY: htmllive
27-
htmllive: SPHINXBUILD = pdm run sphinx-autobuild -b
27+
htmllive: SPHINXBUILD = uv run --group docs sphinx-autobuild -b
2828
htmllive: SPHINXERRORHANDLING = --re-ignore="/\.idea/|/venv/|/topic/"
29-
htmllive: html
29+
htmllive: html

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# Add any Sphinx extension module names here, as strings. They can be
3333
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3434
# ones.
35-
extensions = ["sphinx.ext.autodoc", "myst_parser", "sphinx_inline_tabs"]
35+
extensions = ["sphinx.ext.autodoc", "myst_parser", "sphinx_inline_tabs", "sphinx.ext.doctest"]
3636

3737
# Add any paths that contain templates here, relative to this directory.
3838
templates_path = ["_templates"]

0 commit comments

Comments
 (0)