Skip to content

Commit

Permalink
Try building and testing Python package with tox
Browse files Browse the repository at this point in the history
  • Loading branch information
jeancochrane committed Dec 2, 2024
1 parent df3af62 commit 35e11f0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 80 deletions.
77 changes: 0 additions & 77 deletions .github/workflows/pytest-coverage.yaml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/python-build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on:
pull_request:
push:
branches: [main, master]

name: python-build-and-test

env:
PYTHONUNBUFFERED: "1"

jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: python/pyproject.toml
cache-suffix: test

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

- name: Install tox
shell: bash
run: |
uv tool install tox --with tox-uv,tox-gh-actions
tox --version
- name: Build and test with tox
shell: bash
working-directory: python
run: tox r
37 changes: 34 additions & 3 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ authors = [
{name = "Dan Snow", email="[email protected]"},
]
dependencies = [
"pandas>=1.4.0,<=2.3.0",
"numpy>=1.23.0,<=2.2.0"
"pandas>=1.4.3",
"numpy>=1.23.1"
]

[project.optional-dependencies]
dev = [
"mypy",
"pytest",
"pytest>=7.0.0",
"ruff",
]
docs = [
Expand Down Expand Up @@ -57,3 +57,34 @@ highlight_language = "none"
html_theme = "pydata_sphinx_theme"
html_logo = "../images/logo.png"
html_show_copyright = false

[tool.pytest.ini_options]
minversion = "7.0"
addopts = "-v --cache-clear -rf --doctest-modules"
console_output_style = "count"

[tool.tox]
legacy_tox_ini = """
[tox]
min_version = 4.0
envlist =
py{39, 310, 311, 312, 313}-lowest
[gh-actions]
python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313
[testenv]
extras = dev
commands = pytest
[testenv:py{39, 310, 311, 312, 313}-lowest]
uv_resolution = lowest-direct
[testenv:py{39, 310, 311, 312, 313}]
uv_resolution = highest
"""

0 comments on commit 35e11f0

Please sign in to comment.