Skip to content

Commit ec010d0

Browse files
authored
Improve the CI (#485)
1 parent bdf5359 commit ec010d0

File tree

5 files changed

+119
-189
lines changed

5 files changed

+119
-189
lines changed

Diff for: .github/workflows/check.yaml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: check
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: ["main"]
6+
tags-ignore: ["**"]
7+
pull_request:
8+
schedule:
9+
- cron: "0 8 * * *"
10+
11+
concurrency:
12+
group: check-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
env:
22+
- "3.13"
23+
- "3.12"
24+
- "3.11"
25+
- "3.10"
26+
- type
27+
- dev
28+
- pkg_meta
29+
steps:
30+
- name: Install OS dependencies
31+
run: sudo apt-get install graphviz -y
32+
- uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
- name: Install the latest version of uv
36+
uses: astral-sh/setup-uv@v3
37+
with:
38+
enable-cache: true
39+
cache-dependency-glob: "pyproject.toml"
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Install tox
42+
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
43+
- name: Install Python
44+
if: startsWith(matrix.env, '3.') && matrix.env != '3.13'
45+
run: uv python install --python-preference only-managed ${{ matrix.env }}
46+
- name: Setup test suite
47+
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.env }}
48+
- name: Run test suite
49+
run: tox run --skip-pkg-install -e ${{ matrix.env }}
50+
env:
51+
PYTEST_ADDOPTS: "-vv --durations=20"
52+
DIFF_AGAINST: HEAD

Diff for: .github/workflows/check.yml

-114
This file was deleted.

Diff for: .github/workflows/release.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release to PyPI
2+
on:
3+
push:
4+
tags: ["*"]
5+
6+
env:
7+
dists-artifact-name: python-package-distributions
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Install the latest version of uv
17+
uses: astral-sh/setup-uv@v3
18+
with:
19+
enable-cache: true
20+
cache-dependency-glob: "pyproject.toml"
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
- name: Build package
23+
run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: ${{ env.dists-artifact-name }}
28+
path: dist/*
29+
30+
release:
31+
needs:
32+
- build
33+
runs-on: ubuntu-latest
34+
environment:
35+
name: release
36+
url: https://pypi.org/project/sphinx-autodoc-typehints/${{ github.ref_name }}
37+
permissions:
38+
id-token: write
39+
steps:
40+
- name: Download all the dists
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: ${{ env.dists-artifact-name }}
44+
path: dist/
45+
- name: Publish to PyPI
46+
uses: pypa/[email protected]
47+
with:
48+
attestations: true

Diff for: .github/workflows/release.yml

-27
This file was deleted.

Diff for: tox.ini

+19-48
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,47 @@
11
[tox]
22
requires =
33
tox>=4.2
4+
tox-uv>=1.11.3
45
env_list =
56
fix
67
3.13
78
3.12
89
3.11
910
3.10
1011
type
11-
coverage
12-
readme
12+
pkg_meta
1313
skip_missing_interpreters = true
1414

1515
[testenv]
16-
description = run tests with {basepython}
16+
description = run the unit tests with pytest under {base_python}
1717
package = wheel
1818
wheel_build_env = .pkg
1919
extras =
2020
numpy
2121
testing
2222
type-comment
2323
pass_env =
24-
PIP_*
24+
DIFF_AGAINST
2525
PYTEST_*
2626
set_env =
27-
COVERAGE_FILE = {toxworkdir}{/}.coverage.{envname}
27+
COVERAGE_FILE = {work_dir}/.coverage.{env_name}
2828
commands =
29-
pytest {tty:--color=yes} {posargs: \
30-
--junitxml {toxworkdir}{/}junit.{envname}.xml --cov {envsitepackagesdir}{/}sphinx_autodoc_typehints --cov {toxinidir}{/}tests \
29+
python -m pytest {tty:--color=yes} {posargs: \
30+
--cov {env_site_packages_dir}{/}sphinx_autodoc_typehints --cov {tox_root}{/}tests \
3131
--cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \
32-
--cov-report html:{envtmpdir}{/}htmlcov --cov-report xml:{toxworkdir}{/}coverage.{envname}.xml \
32+
--cov-report html:{env_tmp_dir}{/}htmlcov --cov-report xml:{work_dir}{/}coverage.{env_name}.xml \
33+
--junitxml {work_dir}{/}junit.{env_name}.xml \
3334
tests}
34-
diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}{/}coverage.{envname}.xml
35+
diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {work_dir}{/}coverage.{env_name}.xml --fail-under 100
3536

3637
[testenv:fix]
3738
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
3839
skip_install = true
3940
deps =
40-
pre-commit-uv>=4.1
41+
pre-commit-uv>=4.1.1
4142
commands =
4243
pre-commit run --all-files --show-diff-on-failure
4344

44-
[testenv:3.13]
45-
extras =
46-
testing
47-
type-comment
48-
4945
[testenv:type]
5046
description = run type check on code base
5147
deps =
@@ -55,46 +51,21 @@ commands =
5551
mypy src
5652
mypy tests
5753

58-
[testenv:coverage]
59-
description = combine coverage files and generate diff (against DIFF_AGAINST defaulting to origin/main)
60-
skip_install = true
61-
deps =
62-
covdefaults>=2.3
63-
coverage>=7.6.1
64-
diff-cover>=9.1.1
65-
extras =
66-
parallel_show_output = true
67-
pass_env =
68-
DIFF_AGAINST
69-
set_env =
70-
COVERAGE_FILE = {toxworkdir}/.coverage
71-
commands =
72-
coverage combine
73-
coverage report --skip-covered --show-missing
74-
coverage xml -o {toxworkdir}/coverage.xml
75-
coverage html -d {toxworkdir}/htmlcov
76-
diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml
77-
depends =
78-
3.13
79-
3.12
80-
3.11
81-
3.10
82-
83-
[testenv:readme]
84-
description = check that the long description is valid (need for PyPI)
54+
[testenv:pkg_meta]
55+
description = check that the long description is valid
8556
skip_install = true
8657
deps =
87-
build[virtualenv]>=1.2.2
58+
check-wheel-contents>=0.6
8859
twine>=5.1.1
89-
extras =
60+
uv>=0.4.10
9061
commands =
91-
pyproject-build -o {envtmpdir} --wheel --sdist .
92-
twine check {envtmpdir}/*
62+
uv build --sdist --wheel --out-dir {env_tmp_dir} .
63+
twine check {env_tmp_dir}{/}*
64+
check-wheel-contents --no-config {env_tmp_dir}
9365

9466
[testenv:dev]
9567
description = generate a DEV environment
9668
package = editable
9769
commands =
98-
python -m pip list --format=columns
70+
uv pip tree
9971
python -c 'import sys; print(sys.executable)'
100-
uv_seed = true

0 commit comments

Comments
 (0)