Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Adopt uv. #143

Merged
merged 1 commit into from
Aug 27, 2024
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
10 changes: 4 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ jobs:
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Install poetry
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: 1.2.2
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Build dist
run: poetry build
run: uvx --from build pyproject-build --installer uv
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
51 changes: 27 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,54 @@ jobs:
# No need to matrix test pydantic versions. But the matrix syntax still
# keeps the file DRY.
exclude:
- python-version: '3.8'
pydantic-version: '1.0'
- python-version: '3.9'
pydantic-version: '1.0'
- python-version: '3.11'
pydantic-version: '1.0'
- python-version: '3.12'
pydantic-version: '1.0'
- python-version: '3.13'
pydantic-version: '1.0'
- python-version: "3.8"
pydantic-version: "1.0"
- python-version: "3.9"
pydantic-version: "1.0"
- python-version: "3.11"
pydantic-version: "1.0"
- python-version: "3.12"
pydantic-version: "1.0"
- python-version: "3.13"
pydantic-version: "1.0"

env:
UV_CACHE_DIR: /tmp/.uv-cache
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
allow-prereleases: true

- name: Install poetry
uses: abatilo/actions-poetry@v2.0.0
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Restore uv cache
uses: actions/cache@v4
with:
poetry-version: 1.2.2

- name: Set up cache
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}

- name: Install dependencies
run: make install

- name: Minimize uv cache
run: uv cache prune --ci

- name: Install pydantic matrix version
run: poetry run pip install 'pydantic~=${{ matrix.pydantic-version }}'
run: uv pip install 'pydantic~=${{ matrix.pydantic-version }}'

- name: Run Linters
run: poetry run make lint
run: make lint
if: ${{ !endsWith(matrix.python-version, '-dev') }}

- name: Run tests
run: poetry run make test
run: make test

- name: Store test result artifacts
uses: actions/upload-artifact@v3
Expand Down
7 changes: 0 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,9 @@

## 0.18

### 0.18.1

- feat: Add deprecated option to command/arg.

## 0.18

## 0.18.1

- feat: Add `deprecated` option, allowing deprecation of args, options, and subcommands
> > > > > > > 142825c (feat: Implement exclusive groups.)

### 0.18.0

Expand Down
25 changes: 12 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
.PHONY: install test lint format build publish
.PHONY: install test lint format

PACKAGE_VERSION = $(shell python -c 'import importlib.metadata; print(importlib.metadata.version("responsaas"))')

install:
poetry install -E docstring
uv sync --all-extras

test:
coverage run -m pytest src tests
coverage combine
coverage report
coverage xml
uv run --all-extras coverage run -m pytest src tests
uv run coverage combine
uv run coverage report
uv run coverage xml

lint:
ruff check src tests || exit 1
mypy src tests || exit 1
ruff format --check src tests || exit 1
uv run ruff check src tests || exit 1
uv run --all-extras mypy src tests || exit 1
uv run ruff format --check src tests || exit 1

format:
ruff check src tests --fix
ruff format src tests
uv run ruff check src tests --fix
uv run ruff format src tests

readme-image:
FORCE_COLOR=true python readme.py --help | ansitoimg --title '' docs/source/_static/example.svg

FORCE_COLOR=true uv run python readme.py --help | ansitoimg --title '' docs/source/_static/example.svg
8 changes: 4 additions & 4 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@uv run $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile
.PHONY: help Makefile autobuild

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@uv run $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

autobuild:
sphinx-autobuild source build/html
uv run sphinx-autobuild source build/html
Loading
Loading