Skip to content

Commit 4d28e1d

Browse files
committed
Modernize tox config and switch to tox-gh
1 parent 93e4f0a commit 4d28e1d

File tree

4 files changed

+83
-71
lines changed

4 files changed

+83
-71
lines changed

.github/workflows/test-libmaxminddb.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,33 @@ jobs:
1313

1414
strategy:
1515
matrix:
16+
env: [3.9, "3.10", 3.11, 3.12, 3.13]
1617
# We don't test on Windows currently due to issues
1718
# build libmaxminddb there.
18-
platform: [macos-latest, ubuntu-latest]
19-
python-version: [3.9, "3.10", 3.11, 3.12, 3.13]
19+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
2020

21-
name: Python ${{ matrix.python-version }} on ${{ matrix.platform }}
22-
runs-on: ${{ matrix.platform }}
21+
name: Python ${{ matrix.env }} on ${{ matrix.os }}
22+
runs-on: ${{ matrix.os }}
2323
env:
2424
MAXMINDDB_REQUIRE_EXTENSION: 1
2525
MAXMINDDB_USE_SYSTEM_LIBMAXMINDDB: 1
2626
MM_FORCE_EXT_TESTS: 1
2727

2828
steps:
29-
- name: Checkout
30-
uses: actions/checkout@v4
29+
- uses: actions/checkout@v4
3130
with:
3231
submodules: true
3332
persist-credentials: false
3433

35-
- name: Set up Python ${{ matrix.python-version }}
36-
uses: actions/setup-python@v5
37-
with:
38-
python-version: ${{ matrix.python-version }}
34+
- name: Install the latest version of uv
35+
uses: astral-sh/setup-uv@v3
3936

40-
- name: Install dependencies
41-
run: |
42-
python -m pip install --upgrade pip
43-
pip install setuptools tox tox-gh-actions uv wheel
37+
- name: Install tox
38+
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv --with tox-gh
4439

40+
- name: Install Python
41+
if: matrix.env != '3.13'
42+
run: uv python install --python-preference only-managed ${{ matrix.env }}
4543

4644
- name: Install libmaxminddb
4745
run: sudo apt install libmaxminddb-dev
@@ -62,5 +60,12 @@ jobs:
6260
env:
6361
CFLAGS: "${{ env.CFLAGS }} -Werror -Wall -Wextra"
6462

65-
- name: Test with tox (system libmaxminddb)
66-
run: tox
63+
- name: Setup test suite
64+
run: tox run -vv --notest --skip-missing-interpreters false
65+
env:
66+
TOX_GH_MAJOR_MINOR: ${{ matrix.env }}
67+
68+
- name: Run test suite
69+
run: tox run --skip-pkg-install
70+
env:
71+
TOX_GH_MAJOR_MINOR: ${{ matrix.env }}

.github/workflows/test.yml

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,33 @@ on:
99
permissions: {}
1010

1111
jobs:
12-
build:
13-
12+
test:
13+
name: test with ${{ matrix.env }} on ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
1415
strategy:
16+
fail-fast: false
1517
matrix:
16-
platform: [macos-latest, ubuntu-24.04-arm, ubuntu-latest, windows-latest]
17-
python-version: [3.9, "3.10", 3.11, 3.12, 3.13]
18-
19-
name: Python ${{ matrix.python-version }} on ${{ matrix.platform }}
20-
runs-on: ${{ matrix.platform }}
21-
18+
env: [3.9, "3.10", 3.11, 3.12, 3.13]
19+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
2220
steps:
23-
- name: Checkout
24-
uses: actions/checkout@v4
21+
- uses: actions/checkout@v4
2522
with:
2623
submodules: true
2724
persist-credentials: false
28-
29-
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v5
31-
with:
32-
python-version: ${{ matrix.python-version }}
33-
34-
- name: Install dependencies
35-
run: |
36-
python -m pip install --upgrade pip
37-
pip install tox tox-gh-actions
38-
39-
- name: Test with tox (vendored libmaxminddb)
40-
run: tox
25+
- name: Install the latest version of uv
26+
uses: astral-sh/setup-uv@v3
27+
- name: Install tox
28+
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv --with tox-gh
29+
- name: Install Python
30+
if: matrix.env != '3.13'
31+
run: uv python install --python-preference only-managed ${{ matrix.env }}
32+
- name: Setup test suite
33+
run: tox run -vv --notest --skip-missing-interpreters false
34+
env:
35+
TOX_GH_MAJOR_MINOR: ${{ matrix.env }}
36+
- name: Run test suite
37+
run: tox run --skip-pkg-install
4138
env:
4239
MAXMINDDB_REQUIRE_EXTENSION: 1
4340
MM_FORCE_EXT_TESTS: 1
41+
TOX_GH_MAJOR_MINOR: ${{ matrix.env }}

pyproject.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dev = [
3636
]
3737
lint = [
3838
"black>=25.1.0",
39+
"flake8>=7.2.0",
3940
"mypy>=1.15.0",
4041
"pylint>=3.3.6",
4142
"ruff>=0.11.6",
@@ -82,3 +83,43 @@ ignore = [
8283

8384
[tool.ruff.lint.per-file-ignores]
8485
"tests/*" = ["ANN201", "D"]
86+
87+
[tool.tox]
88+
env_list = [
89+
"3.9",
90+
"3.10",
91+
"3.11",
92+
"3.12",
93+
"3.13",
94+
"lint",
95+
]
96+
skip_missing_interpreters = false
97+
98+
[tool.tox.env_run_base]
99+
dependency_groups = [
100+
"dev",
101+
]
102+
commands = [
103+
["pytest", "tests"],
104+
]
105+
106+
[tool.tox.env.lint]
107+
description = "Code linting"
108+
python = "3.13"
109+
dependency_groups = [
110+
"dev",
111+
"lint",
112+
]
113+
commands = [
114+
["black", "--check", "--diff", "."],
115+
["flake8", "maxminddb"],
116+
["mypy", "maxminddb", "tests"],
117+
["pylint", "maxminddb"],
118+
]
119+
120+
[tool.tox.gh.python]
121+
"3.13" = ["3.13", "lint"]
122+
"3.12" = ["3.12"]
123+
"3.11" = ["3.11"]
124+
"3.10" = ["3.10"]
125+
"3.9" = ["3.9"]

setup.cfg

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,3 @@ python_requires = >=3.9
1313

1414
[options.package_data]
1515
maxminddb = extension.pyi; py.typed
16-
17-
[tox:tox]
18-
envlist = {py39,py310,py311,py312,py313}-test,py313-{black,lint,flake8,mypy}
19-
20-
[gh-actions]
21-
python =
22-
3.9: py39
23-
3.10: py310
24-
3.11: py311
25-
3.12: py312
26-
3.13: py313,black,lint,flake8,mypy
27-
28-
[testenv:{py39,py310,py311,py312,py313}-test]
29-
deps = pytest
30-
commands = pytest tests
31-
passenv = *
32-
33-
[testenv:py313-black]
34-
deps = black
35-
commands = black --check --diff .
36-
37-
[testenv:py313-lint]
38-
deps = pylint
39-
commands = pylint maxminddb
40-
41-
[testenv:py313-flake8]
42-
deps = flake8
43-
commands = flake8 maxminddb
44-
45-
[testenv:py313-mypy]
46-
deps = mypy
47-
commands = mypy maxminddb tests

0 commit comments

Comments
 (0)