Skip to content

Commit 7db97c8

Browse files
committed
Update Makefile and GitHub Actions to use pixi for testing and linting
1 parent a801100 commit 7db97c8

File tree

4 files changed

+104
-61
lines changed

4 files changed

+104
-61
lines changed

.github/workflows/python-app.yml

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This workflow will install Python dependencies, run tests and lint with a single version of Python
1+
# This workflow will install Python dependencies, run tests and lint using pixi
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

44
name: Python application
@@ -14,34 +14,40 @@ on:
1414

1515
jobs:
1616
test:
17-
name: Run tests on ${{ matrix.py }}
18-
runs-on: ubuntu-latest
17+
name: Run tests on Python ${{ matrix.python-version }}
18+
runs-on: ${{ matrix.os }}
1919
strategy:
20+
fail-fast: false
2021
matrix:
21-
py:
22-
- "3.13"
23-
- "3.12"
24-
- "3.11"
25-
- "3.10"
26-
- "3.9"
27-
- "3.8"
28-
- "pypy-3.10"
29-
- "pypy-3.9"
22+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
23+
os: [ubuntu-latest]
24+
include:
25+
# Test on additional platforms for latest Python
26+
- python-version: "3.11"
27+
os: macos-latest
28+
- python-version: "3.11"
29+
os: windows-latest
3030

3131
steps:
3232
- uses: actions/checkout@v4
33-
- name: Set up Python ${{ matrix.py }}
34-
uses: actions/setup-python@v5
33+
34+
- name: Setup pixi
35+
uses: prefix-dev/setup-pixi@v0.8.1
3536
with:
36-
python-version: ${{ matrix.py }}
37-
allow-prereleases: true
38-
check-latest: true
39-
- name: Install dependencies
40-
run: |
41-
python -m pip install --upgrade pip hatch
42-
- name: Lint with flake8
43-
run: hatch run flake8
44-
- name: Test with pytest and coverage
45-
run: hatch run cov
37+
pixi-version: v0.55.0
38+
cache: true
39+
40+
- name: Install dependencies and run tests
41+
run: pixi run test-py${{ matrix.python-version | replace('.', '') }}
42+
43+
- name: Run lint (Python 3.11 only)
44+
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
45+
run: pixi run lint
46+
47+
- name: Generate coverage report (Python 3.11 only)
48+
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
49+
run: pixi run -e py311 coverage && pixi run -e py311 coverage-combine && pixi run -e py311 coverage-xml
50+
4651
- name: Publish to codecov
52+
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
4753
uses: codecov/codecov-action@v4

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ MANIFEST
77
.cache/
88
*.egg-info/
99
htmlcov/
10-
.pytest_cache
10+
.pytest_cache# pixi environments
11+
.pixi/*
12+
!.pixi/config.toml

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@ help:
1010
@sed -n '/^[a-zA-Z0-9_.]*:/s/:.*//p' <Makefile | sort
1111

1212
test:
13-
tox
13+
pixi run test-all
14+
15+
lint:
16+
pixi run lint
1417

1518
coverage:
16-
pytest --cov=sqlparse --cov-report=html --cov-report=term
19+
pixi run -e py311 coverage
20+
pixi run -e py311 coverage-combine
21+
pixi run -e py311 coverage-report
22+
23+
coverage-xml:
24+
pixi run -e py311 coverage
25+
pixi run -e py311 coverage-combine
26+
pixi run -e py311 coverage-xml
1727

1828
clean:
1929
$(PYTHON) setup.py clean

pyproject.toml

Lines changed: 59 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ sqlformat = "sqlparse.__main__:main"
4141

4242
[project.optional-dependencies]
4343
dev = [
44-
"hatch",
4544
"build",
4645
]
4746
doc = [
@@ -51,39 +50,6 @@ doc = [
5150
[tool.hatch.version]
5251
path = "sqlparse/__init__.py"
5352

54-
[tool.hatch.envs.default]
55-
dependencies = [
56-
"coverage[toml]>=6.5",
57-
"pytest",
58-
# switch to ruff, but fix problems first
59-
# but check defaults!
60-
# https://hatch.pypa.io/1.9/config/static-analysis/#default-settings
61-
"flake8",
62-
]
63-
[tool.hatch.envs.default.scripts]
64-
unittest = "pytest {args:tests}"
65-
test-cov = "coverage run -m pytest {args:tests}"
66-
cov-report = [
67-
"- coverage combine",
68-
"coverage report",
69-
]
70-
cov = [
71-
"test-cov",
72-
"cov-report",
73-
]
74-
check = "flake8 sqlparse/"
75-
test = ["check", "unittest"]
76-
77-
[[tool.hatch.envs.all.matrix]]
78-
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
79-
80-
[tool.hatch.envs.types]
81-
dependencies = [
82-
"mypy>=1.0.0",
83-
]
84-
[tool.hatch.envs.types.scripts]
85-
check = "mypy --install-types --non-interactive {args:sqlparse tests}"
86-
8753
[tool.coverage.run]
8854
source_pkgs = ["sqlparse", "tests"]
8955
branch = true
@@ -102,3 +68,62 @@ exclude_lines = [
10268
"if __name__ == .__main__.:",
10369
"if TYPE_CHECKING:",
10470
]
71+
72+
[tool.pixi.workspace]
73+
channels = ["conda-forge"]
74+
platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"]
75+
76+
[tool.pixi.pypi-dependencies]
77+
sqlparse = { path = ".", editable = true }
78+
79+
[tool.pixi.feature.test.dependencies]
80+
pytest = "*"
81+
coverage = "*"
82+
flake8 = "*"
83+
84+
[tool.pixi.feature.test.pypi-dependencies]
85+
sqlparse = { path = ".", editable = true }
86+
87+
[tool.pixi.feature.py38.dependencies]
88+
python = "3.8.*"
89+
90+
[tool.pixi.feature.py39.dependencies]
91+
python = "3.9.*"
92+
93+
[tool.pixi.feature.py310.dependencies]
94+
python = "3.10.*"
95+
96+
[tool.pixi.feature.py311.dependencies]
97+
python = "3.11.*"
98+
99+
[tool.pixi.feature.py312.dependencies]
100+
python = "3.12.*"
101+
102+
[tool.pixi.feature.py313.dependencies]
103+
python = "3.13.*"
104+
105+
106+
[tool.pixi.environments]
107+
default = { solve-group = "default" }
108+
dev = { features = ["dev"], solve-group = "default" }
109+
doc = { features = ["doc"], solve-group = "default" }
110+
py38 = { features = ["test", "py38"], solve-group = "py38" }
111+
py39 = { features = ["test", "py39"], solve-group = "py39" }
112+
py310 = { features = ["test", "py310"], solve-group = "py310" }
113+
py311 = { features = ["test", "py311"], solve-group = "py311" }
114+
py312 = { features = ["test", "py312"], solve-group = "py312" }
115+
py313 = { features = ["test", "py313"], solve-group = "py313" }
116+
117+
[tool.pixi.tasks]
118+
test-py38 = "pixi run -e py38 pytest tests/"
119+
test-py39 = "pixi run -e py39 pytest tests/"
120+
test-py310 = "pixi run -e py310 pytest tests/"
121+
test-py311 = "pixi run -e py311 pytest tests/"
122+
test-py312 = "pixi run -e py312 pytest tests/"
123+
test-py313 = "pixi run -e py313 pytest tests/"
124+
test-all = { depends-on = ["test-py38", "test-py39", "test-py310", "test-py311", "test-py312", "test-py313"] }
125+
lint = "pixi run -e py311 flake8 sqlparse/"
126+
coverage = "coverage run -m pytest tests/"
127+
coverage-combine = "coverage combine"
128+
coverage-report = "coverage report"
129+
coverage-xml = "coverage xml"

0 commit comments

Comments
 (0)