Skip to content

Commit

Permalink
refactor: Convert from poetry to uv.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCardin committed Oct 9, 2024
1 parent 62cb948 commit 5432c4c
Show file tree
Hide file tree
Showing 13 changed files with 2,532 additions and 3,102 deletions.
24 changes: 8 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -19,18 +19,10 @@ jobs:
publish-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Run image
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: 1.2.0

- name: Publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build
- uses: actions/checkout@v4
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Build dist
run: uvx --from build pyproject-build --installer uv
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
31 changes: 12 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,31 @@ jobs:
python-version: ${{ matrix.python-version }}
architecture: x64

- 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: poetry install -E parse

- name: Install snowflake
if: ${{ matrix.sqlalchemy-version == '1.4.0' && matrix.python-version != '3.8.0' }}
run: |
poetry run pip install 'snowflake-sqlalchemy'
run: make install

- name: Install specific sqlalchemy version
run: |
poetry run pip install 'sqlalchemy~=${{ matrix.sqlalchemy-version }}'
uv pip install 'sqlalchemy~=${{ matrix.sqlalchemy-version }}'
- if: ${{ matrix.sqlalchemy-version == '1.4.0' }}
run: poetry run make lint
run: make lint

- env:
PMR_POSTGRES_DRIVERNAME: ${{ matrix.postgres-drivername }}
SQLALCHEMY_WARN_20: 1
run: poetry run make test
run: make test

- name: Store test result artifacts
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: "3.9"
python: "3.10"

python:
install:
Expand Down
26 changes: 12 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
.PHONY: install build test lint format
.PHONY: install test lint format
.DEFAULT_GOAL := help

WORKER_COUNT ?= 4

install:
poetry install -E parse -E alembic

build:
poetry build
uv sync --all-extras

test:
SQLALCHEMY_WARN_20=1 \
COVERAGE_PROCESS_START="$(PWD)/pyproject.toml" \
uv run \
coverage run -m pytest -n $(WORKER_COUNT) -vv src tests
coverage combine
coverage report -i
coverage xml
uv run coverage combine
uv run coverage report -i
uv run coverage xml

lint:
ruff check --fix src tests || exit 1
ruff format -q src tests || exit 1
mypy src tests || exit 1
ruff format --check src tests
uv run ruff check --fix src tests || exit 1
uv run ruff format -q src tests || exit 1
uv run mypy src tests || exit 1
uv run ruff format --check src tests

format:
ruff check src tests --fix
ruff format src tests
uv run ruff check src tests --fix
uv run ruff format src tests
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 --with sphinx-autobuild sphinx-autobuild source build/html
Loading

0 comments on commit 5432c4c

Please sign in to comment.