Skip to content

Commit 8dfdc63

Browse files
committed
chore: simplify tox and ci pipelines
1 parent 9af9e7b commit 8dfdc63

File tree

5 files changed

+63
-52
lines changed

5 files changed

+63
-52
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,55 +32,55 @@ jobs:
3232
- name: Install dependencies
3333
run: pip install tox
3434
- name: Run tests
35-
run: tox -e py
35+
run: tox run -e py
3636

3737
tests-misc:
3838
runs-on: ubuntu-latest
3939
strategy:
4040
matrix:
41-
env: [generate-integration-files, type, lint, format]
41+
env:
42+
- build
43+
- format
44+
- generate-integration-files
45+
- lint
46+
- type
4247
steps:
4348
- uses: actions/checkout@v5
49+
with:
50+
# build env: fetch all commits for version computation
51+
fetch-depth: ${{ matrix.env == 'build' && '0' || '1' }}
4452
- name: Setup Python
4553
uses: actions/setup-python@v6
4654
with:
4755
python-version: "3.11"
4856
- name: Install dependencies
4957
run: pip install tox
5058
- name: Run ${{ matrix.env }}
51-
run: tox -e ${{ matrix.env }}
52-
53-
build:
54-
needs: [tests-py, tests-misc]
55-
runs-on: ubuntu-latest
56-
steps:
57-
- uses: actions/checkout@v5
58-
with:
59-
# fetch all commits for setuptools_scm
60-
fetch-depth: 0
61-
- name: Setup Python
62-
uses: actions/setup-python@v6
63-
with:
64-
python-version: "3.11"
65-
- name: Build
66-
run: python setup.py sdist bdist_wheel
67-
- name: Save build artifacts
59+
run: tox run -e ${{ matrix.env }}
60+
- if: ${{ matrix.env == 'build' }}
61+
name: Save ${{ matrix.env }} artifacts
6862
uses: actions/upload-artifact@v4
6963
with:
70-
name: dist
64+
name: ${{ matrix.env }}
7165
path: dist
7266

7367
publish:
7468
if: startsWith(github.ref, 'refs/tags')
75-
needs: build
69+
needs:
70+
- tests-py
71+
- tests-misc
7672
runs-on: ubuntu-latest
73+
environment: publish
74+
permissions:
75+
id-token: write # This permission is mandatory for trusted publishing
7776
steps:
7877
- name: Restore build artifacts
7978
uses: actions/download-artifact@v5
8079
with:
81-
name: dist
80+
name: build
8281
path: dist
8382
- name: Publish to PyPI
8483
uses: pypa/gh-action-pypi-publish@release/v1
8584
with:
86-
password: ${{ secrets.pypi_password }}
85+
verbose: true
86+
print-hash: true

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ adheres to [Semantic Versioning](https://semver.org/).
1919
- Freeze dev dependencies versions
2020
- Update GitHub actions dependencies
2121
- Add tests for PyPy 3.10 and 3.11
22+
- Improve tox & CI pipelines
2223

2324
## [0.5.0] - 2023-02-27
2425

dev-requirements.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
# install + dependencies
22
-e .
33

4-
# typing
5-
mypy==1.0.1
4+
# build
5+
build==1.3.0
66

7-
# tests
8-
pytest==7.2.1
9-
pytest-cov==4.0.0
7+
# format
8+
black==23.1.0
9+
isort==5.12.0
1010

1111
# lint
1212
pylint==2.16.2
1313

14-
# format
15-
black==23.1.0
16-
isort==5.12.0
14+
# typing
15+
mypy==1.0.1
1716

18-
# publish
19-
setuptools_scm==7.1.0
20-
wheel==0.38.4
17+
# tests
18+
pytest==7.2.1
19+
pytest-cov==4.0.0

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ package_dir = =src
3232
packages = xz
3333
python_requires = >=3.9
3434
setup_requires =
35-
setuptools_scm
36-
wheel
35+
setuptools_scm==7.1.0

tox.ini

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
# for moving this file into pyproject.toml, see https://github.com/tox-dev/tox/issues/999
2+
13
[tox]
24
envlist =
35
py, py39, py310, py311, pypy3
4-
generate-integration-files, type, lint, format
6+
build, format, generate-integration-files, lint, type
57

68
[testenv]
9+
package = wheel
10+
wheel_build_env = .pkg # reuse same wheel across envs
711
deps =
812
pytest==7.2.1
913
pytest-cov==4.0.0
@@ -15,6 +19,24 @@ commands =
1519
pytest {posargs:-vv --cov-fail-under=100}
1620
py: -coverage html
1721

22+
[testenv:build]
23+
basepython = python3.11
24+
skip_install = true
25+
deps =
26+
build==1.3.0
27+
commands =
28+
python -m build
29+
30+
[testenv:format]
31+
basepython = python3.11
32+
skip_install = true
33+
deps =
34+
black==23.1.0
35+
isort==5.12.0
36+
commands =
37+
black {posargs:--check --diff} src tests
38+
isort {posargs:--check --diff} src tests
39+
1840
[testenv:generate-integration-files]
1941
basepython = python3.11
2042
deps =
@@ -26,15 +48,6 @@ setenv =
2648
PYTHONDEVMODE = 1
2749
commands = pytest -vv -m generate_integration_files --generate-integration-files
2850

29-
[testenv:type]
30-
basepython = python3.11
31-
deps =
32-
mypy==1.0.1
33-
pytest==7.2.1 # for typing
34-
commands =
35-
mypy
36-
mypy --namespace-packages --explicit-package-bases tests
37-
3851
[testenv:lint]
3952
basepython = python3.11
4053
deps =
@@ -44,12 +57,11 @@ commands =
4457
pylint src
4558
pylint -d duplicate-code,too-many-statements,use-implicit-booleaness-not-comparison tests
4659

47-
[testenv:format]
60+
[testenv:type]
4861
basepython = python3.11
49-
skip_install = true
5062
deps =
51-
black==23.1.0
52-
isort==5.12.0
63+
mypy==1.0.1
64+
pytest==7.2.1 # for typing
5365
commands =
54-
black {posargs:--check --diff} src tests
55-
isort {posargs:--check --diff} src tests
66+
mypy
67+
mypy --namespace-packages --explicit-package-bases tests

0 commit comments

Comments
 (0)