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

improve test ci with uv #38

Merged
merged 2 commits into from
Oct 17, 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
24 changes: 10 additions & 14 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,24 @@ jobs:
submodules: recursive
token: ${{ github.token }}

- name: Set up CPython 3.12
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"
version: "0.4.22"

- name: Set up Python
run: uv python install 3.13

- name: Install dependencies
run: |
pip install uv
uv venv
source ./.venv/bin/activate
uv pip install --upgrade setuptools wheel pytest setuptools-rust
uv pip install -U -r requirements_dev.txt
- name: Installing distribution (dev mode)
# this adds the .so to the inner lib files so we can test
run: |
source ./.venv/bin/activate
python ./setup.py develop
uv run --no-project ./setup.py develop
- name: Run tests
shell: bash
run: |
source ./.venv/bin/activate
PYTHONPATH="$(pwd)" coverage run -m pytest
uv venv
uv pip install pytest coverage
uv run --no-project coverage run -m pytest

- name: Coverage comment
id: coverage_comment
Expand Down
31 changes: 16 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.x"]
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"

name: pytest ${{ matrix.python-version }}
steps:
Expand All @@ -21,25 +26,21 @@ jobs:
submodules: recursive
token: ${{ github.token }}

- name: Set up CPython ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
version: "0.4.22"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install uv
uv venv
source ./.venv/bin/activate
uv pip install --upgrade setuptools wheel pytest setuptools-rust
uv pip install -U -r requirements_dev.txt
- name: Installing distribution (dev mode)
# this adds the .so to the inner lib files so we can test
run: |
source ./.venv/bin/activate
python ./setup.py develop
uv run --no-project ./setup.py develop
- name: Run tests
shell: bash
run: |
source ./.venv/bin/activate
PYTHONPATH="$(pwd)" pytest
uv venv
uv pip install pytest
uv run --no-project pytest
24 changes: 13 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# /// script
# requires-python = ">=3.9"
# dependencies = [
# "setuptools-rust",
# ]
# ///
import contextlib
import re
from pathlib import Path

from setuptools import setup
from setuptools_rust import Binding, RustExtension

requirements = []
with open("requirements.txt") as f:
requirements = f.read().splitlines()

version = ""
with open("neofoodclub/__init__.py") as f:
version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
f.read(),
re.MULTILINE,
)
version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
Path("neofoodclub/__init__.py").read_text(),
re.MULTILINE,
)

if not version:
raise RuntimeError("version is not set")
Expand Down Expand Up @@ -70,6 +71,7 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Typing :: Typed",
],
zip_safe=False,
Expand Down
Loading