Skip to content

Commit 570d4da

Browse files
committed
refactor: Trim tox configuration
- Run mypy through pre-commit - Run Python test workflow through uv - Use Python dependency groups standard
1 parent 25e843c commit 570d4da

File tree

3 files changed

+412
-70
lines changed

3 files changed

+412
-70
lines changed

.github/workflows/test-python.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,33 @@ on:
2121

2222
jobs:
2323
build:
24-
2524
runs-on: ${{ matrix.os }}
2625
strategy:
2726
matrix:
2827
include:
29-
# Test latest python on Windows / macOS
28+
# Test latest python on Windows and macOS
3029
- { os: 'windows-latest', python-version: '3.13' }
3130
- { os: 'macos-latest', python-version: '3.13' }
3231
os: ['ubuntu-latest']
3332
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', 'pypy3.9', 'pypy3.10']
34-
33+
defaults:
34+
run:
35+
working-directory: python
3536
steps:
3637
- uses: actions/checkout@v5
37-
- name: Set up Python ${{ matrix.python-version }}
38-
uses: actions/setup-python@v6
38+
39+
- name: Install uv and set the python version
40+
uses: astral-sh/setup-uv@v6
3941
with:
42+
enable-cache: true
4043
python-version: ${{ matrix.python-version }}
41-
- name: Install dependencies
42-
run: |
43-
python -m pip install --upgrade pip
44-
pip install tox tox-gh-actions codecov
45-
- name: Test with tox
46-
working-directory: ./python
47-
run: |
48-
tox
44+
version: "0.8.17"
45+
46+
- name: Linting and testing
47+
run: uv run tox -e="lint,${{ matrix.python-version }}"
48+
4949
- name: Gather codecov report
50-
working-directory: ./python
51-
run: |
52-
codecov
50+
run: uvx codecov
51+
52+
- name: Build package
53+
run: uv build

python/pyproject.toml

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
build-backend = "uv_build"
33
requires = ["uv_build>=0.8.4,<0.9.0"]
44

5+
[dependency-groups]
6+
dev = [
7+
"coverage>=7.2",
8+
"pytest>=6.1",
9+
"GitPython",
10+
"packaging",
11+
"tox>=4.22"
12+
]
13+
514
[project]
615
authors = [
716
{name = "Cucumber Limited", email = "[email protected]"}
@@ -37,20 +46,6 @@ readme = "README.md"
3746
requires-python = ">=3.9"
3847
version = "29.0.1"
3948

40-
[project.optional-dependencies]
41-
test = [
42-
# local
43-
"cucumber-messages[test-coverage]",
44-
# external; Must be in sync with [tool.tox]
45-
"tox>=4.2"
46-
]
47-
test-coverage = [
48-
"coverage",
49-
"GitPython",
50-
"packaging",
51-
"pytest"
52-
]
53-
5449
[project.urls]
5550
Changelog = "https://github.com/cucumber/messages/releases"
5651
Download = "https://pypi.org/project/cucumber-messages"
@@ -88,46 +83,17 @@ extend-select = [
8883
# TODO: Evaluate whether to use wildcard (removing need for updates) or explicit imports
8984
"src/cucumber_messages/__init__.py" = ["F403"]
9085

91-
# Once https://github.com/tox-dev/tox/issues/999 is released and available, migrate to the new tox approach
9286
[tool.tox]
93-
# language=INI
94-
legacy_tox_ini = """
95-
[tox]
96-
requires =
97-
tox>=4.2
98-
env_list =
99-
py{313, 312, 311, 310, 39}-lint-lin
100-
py{py310, py39, 313, 312, 311, 310, 39}-pytest-coverage-lin
101-
py313-pytest-coverage-{win, mac}
102-
distshare = {homedir}/.tox/distshare
87+
env_list = ["lint", "3.13", "3.12", "3.11", "3.10", "3.9", "pypy310", "pypy39"]
88+
requires = ["tox>=4.22"]
10389

104-
[testenv]
105-
platform =
106-
lin: linux
107-
mac: darwin
108-
win: win32
90+
[tool.tox.env.lint]
91+
commands = [["pre-commit", "run", "--all-files", "--show-diff-on-failure"]]
92+
deps = ["pre-commit-uv>=4.1.1"]
93+
description = "Run linting and formatting checks (and auto-fixes)"
10994

110-
[testenv:py{313, 312, 311, 310, 39}-lint-lin]
111-
skip_install = true
112-
description = run code formatter and linter (auto-fix)
113-
deps =
114-
pre-commit-uv>=4.1.1
115-
commands =
116-
pre-commit run --all-files --show-diff-on-failure
117-
118-
[testenv:py{py310, py39, 313, 312, 311, 310, 39}-pytest-coverage-{lin, win, mac}]
119-
deps =
120-
.[test-coverage]
121-
commands =
122-
coverage run --append -m pytest -vvl
123-
124-
[gh-actions]
125-
python =
126-
3.9: py39
127-
3.10: py310
128-
3.11: py311
129-
3.12: py312
130-
3.13: py313
131-
pypy-3.9: pypy39
132-
pypy-3.10: pypy310
133-
"""
95+
[tool.tox.env_run_base]
96+
commands = [["coverage", "run", "--append", "-m", "pytest", "-vvl"]]
97+
dependency_groups = [
98+
"dev"
99+
]

0 commit comments

Comments
 (0)