Skip to content

Commit

Permalink
deps: switch to uv as project manager (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
bossenti authored Dec 27, 2024
1 parent 18f9691 commit 5a56e23
Show file tree
Hide file tree
Showing 7 changed files with 1,049 additions and 1,359 deletions.
33 changes: 10 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.9

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
in-project: true
prefer-active-python: true
version: "0.5.13"
python-version: 3.9

- name: Install command runner
uses: taiki-e/install-action@just

- name: Install Python dependencies
run: |
just poetry-install
just install-deps
- name: Run style & code checks
run: |
Expand All @@ -46,26 +40,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python v${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: 1.6.1
virtualenvs-create: true
virtualenvs-in-project: true
version: "0.5.13"
python-version: ${{ matrix.python }}

- name: Install command runner
uses: taiki-e/install-action@just

- name: Install Python dependencies
run: |
just poetry-install
just install-deps
- name: Run unit-tests
run: |
source $VENV # see https://github.com/snok/install-poetry#running-on-windows
just unit-tests
22 changes: 9 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.8

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-in-project: true
version: "0.5.13"
python-version: 3.9

- name: Configure Git
run: |
Expand All @@ -31,16 +26,17 @@ jobs:
- name: Install dependencies
run: |
poetry install --with dev,release --all-extras
uv sync --group dev --group release --all-extras
- name: Set Package Version
run: |
poetry version ${GITHUB_REF#refs/*/}
# see https://github.com/astral-sh/uv/issues/6298#issuecomment-2335034247
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version ${GITHUB_REF#refs/*/}
- name: Build package
run: |
poetry build
poetry run twine check --strict dist/*
uv build
uv run twine check --strict dist/*
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<a href="https://beta.ruff.rs/docs/" target="_blank">
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Linting: Ruff">
</a>
<a href="https://python-poetry.org" target="_blank">
<img src="https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json" alt="Dependency & Build Management: Poetry">
<a href="https://github.com/astral-sh/uv" target="_blank">
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="Dependency & Build Management: uv">
</a>
<a href="https://pre-commit.com/" target="_blank">
<img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white" alt="pre-commit">
Expand Down
24 changes: 12 additions & 12 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# fix imports with autoflake
autoflake:
poetry run autoflake -r vistafetch tests
uv run autoflake -r vistafetch tests

# apply code formatting with black
format:
poetry run ruff format vistafetch tests
uv run ruff format vistafetch tests

# run static type checking with mypy
mypy:
poetry run mypy vistafetch
uv run mypy vistafetch

# apply linting with ruff
ruff:
poetry run ruff check vistafetch/**/*.py tests/**/*.py --fix-only
uv run ruff check vistafetch/**/*.py tests/**/*.py --fix-only

# run pre-configured poetry lock
poetry-lock:
poetry lock --no-update
# run pre-configured dependency lock
lock-deps:
uv lock --frozen

# run pre-configured poetry install
poetry-install:
poetry install --with dev --all-extras
# run pre-configured dependency install
install-deps:
uv sync --group dev --all-extras

# run a check (ideally before comitting)
check: autoflake format mypy
poetry run ruff check vistafetch/ tests/
uv run ruff check vistafetch/ tests/

# run pre-commit check
pre-commit:
Expand All @@ -35,4 +35,4 @@ pretty: autoflake ruff format

# run all unit tests
unit-tests:
export TZ="UTC"; poetry run pytest --cov=vistafetch --cov-fail-under=90 --cov-report term-missing:skip-covered --no-cov-on-fail tests/
export TZ="UTC"; uv run pytest --cov=vistafetch --cov-fail-under=90 --cov-report term-missing:skip-covered --no-cov-on-fail tests/
Loading

0 comments on commit 5a56e23

Please sign in to comment.