Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 40 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
name: CI

permissions: {}

on:
push:
branches: ["main"]
Expand All @@ -17,28 +19,24 @@ jobs:
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
redis-version: [6]
fail-fast: false

steps:
- uses: "actions/checkout@v4"

- uses: "pdm-project/setup-pdm@v4"
with:
python-version: "${{ matrix.python-version }}"
allow-python-prereleases: true
cache: true
version: "2.25.9"
persist-credentials: false

- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3.0.0
- uses: hynek/setup-cached-uv@757bedc3f972eb7227a1aa657651f15a8527c817 # v2.3.0

- name: "Start Redis"
uses: "supercharge/redis-github-action@1.2.0"
uses: "supercharge/redis-github-action@ea9b21c6ecece47bd99595c532e481390ea0f044" # 1.8.0
with:
redis-version: "${{ matrix.redis-version }}"

- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3.0.0

- name: "Run Tox"
- name: "Run Tests"
run: |
python -Im pip install --upgrade tox tox-gh-actions
python -Im tox
just python=${{ matrix.python-version }} covcleanup="false" cov

- name: Upload coverage data
uses: actions/upload-artifact@v4
Expand All @@ -55,34 +53,31 @@ jobs:

steps:
- uses: "actions/checkout@v4"

- uses: "actions/setup-python@v5"
with:
cache: "pip"
python-version: "3.12"

- run: "python -Im pip install --upgrade coverage[toml]"
persist-credentials: false

- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true

- uses: hynek/setup-cached-uv@757bedc3f972eb7227a1aa657651f15a8527c817 # v2.3.0

- name: "Combine coverage"
run: |
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
python -Im coverage json
uv run --group test coverage combine
uv run --group test coverage html
uv run --group test coverage json

# Report and write to summary.
python -Im coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
uv run --group test coverage report --format=markdown >> $GITHUB_STEP_SUMMARY

export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
export TOTAL=$(uv run python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV

# Report again and fail if under the threshold.
python -Im coverage report --fail-under=97
uv run --group test coverage report --fail-under=98

- name: "Upload HTML report."
uses: "actions/upload-artifact@v4"
Expand All @@ -105,28 +100,40 @@ jobs:
maxColorRange: 90
valColorRange: ${{ env.total }}

lint:
name: "Run linters"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
with:
persist-credentials: false

- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3.0.0
- uses: hynek/setup-cached-uv@757bedc3f972eb7227a1aa657651f15a8527c817 # v2.3.0

- name: "Run linters"
run: |
just lint

package:
name: "Build & verify package"
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v3"

- uses: "actions/setup-python@v4"
- uses: "actions/checkout@v4"
with:
python-version: "3.11"
persist-credentials: false

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

- name: "Build package"
run: "python -m build"
run: "uvx --from build pyproject-build"

- name: "List result"
run: "ls -l dist"

- name: "Check wheel contents"
run: "check-wheel-contents dist/*.whl"
run: "uvx check-wheel-contents dist/*.whl"

- name: "Check long_description"
run: "python -m twine check dist/*"
run: "uvx twine check dist/*"
4 changes: 2 additions & 2 deletions .github/workflows/pypi-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
path: dist

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

Expand All @@ -65,4 +65,4 @@ jobs:
path: dist

- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
16 changes: 14 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ build:
tools:
python: "3.13"
jobs:
create_environment:
- asdf plugin add uv
- asdf plugin add just
- asdf install uv latest
- asdf global uv latest
- asdf install just latest
- asdf global just latest
install:
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --group docs --all-extras --link-mode=copy
post_install:
- "curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -"
- "VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH ~/.local/bin/pdm sync -dG docs"
# Need the tags to calculate the version
- git fetch --tags
build:
html:
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH just docs $READTHEDOCS_OUTPUT
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The **third number** is for emergencies when we need to start branches for older

<!-- changelog follows -->

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

### Added

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

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

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


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

### Changed
Expand Down
32 changes: 29 additions & 3 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
python := ""
covcleanup := "true"

sync version="":
uv sync {{ if python != '' { '-p ' + python } else if version != '' { '-p ' + version } else { '' } }} --all-groups --all-extras

test *args='tests -x --ff --mypy-only-local-stub -n auto':
pdm run pytest {{args}}
uv run pytest {{args}}

lint: sync
uv run mypy src/ tests/ && uv run ruff check src/ tests/ && uv run black --check src/ tests/

cov *args="-x --ff --mypy-only-local-stub -n auto tests":
uv run {{ if python != '' { '-p ' + python } else { '' } }} --all-extras --group frameworks --group test --group lint coverage run -m pytest {{args}}
{{ if covcleanup == "true" { "uv run coverage combine" } else { "" } }}
{{ if covcleanup == "true" { "uv run coverage report" } else { "" } }}
{{ if covcleanup == "true" { "@rm .coverage*" } else { "" } }}

covall:
just python=python3.11 covcleanup=false cov
just python=python3.12 covcleanup=false cov
just python=python3.13 covcleanup=false cov
just python=python3.14 covcleanup=false cov
uv run coverage combine
uv run coverage report
@rm .coverage*

lint:
pdm run mypy src/ tests/ && pdm run ruff check src/ tests/ && pdm run black --check src/ tests/
docs output_dir="_build": ## generate Sphinx HTML documentation, including API docs
make -C docs -e BUILDDIR={{output_dir}} clean
make -C docs -e BUILDDIR={{output_dir}} doctest
make -C docs -e BUILDDIR={{output_dir}} html
8 changes: 4 additions & 4 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= pdm run sphinx-build -M
SPHINXBUILD ?= uv run --group docs sphinx-build -M
SOURCEDIR = .
BUILDDIR = _build

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

apidoc:
pdm run sphinx-apidoc -o . ../src/uapi -f
uv run --group docs sphinx-apidoc -o . ../src/uapi -f

## htmllive to rebuild and reload HTML files in your browser
.PHONY: htmllive
htmllive: SPHINXBUILD = pdm run sphinx-autobuild -b
htmllive: SPHINXBUILD = uv run --group docs sphinx-autobuild -b
htmllive: SPHINXERRORHANDLING = --re-ignore="/\.idea/|/venv/|/topic/"
htmllive: html
htmllive: html
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.autodoc", "myst_parser", "sphinx_inline_tabs"]
extensions = ["sphinx.ext.autodoc", "myst_parser", "sphinx_inline_tabs", "sphinx.ext.doctest"]

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