Skip to content

Commit e0929c6

Browse files
authored
Improve the CI (#152)
1 parent 302f383 commit e0929c6

File tree

7 files changed

+149
-147
lines changed

7 files changed

+149
-147
lines changed

.github/workflows/check.yaml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
name: test ${{ matrix.env }} - ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
env:
23+
- "3.13"
24+
- "3.12"
25+
- "3.11"
26+
- "3.10"
27+
- "3.9"
28+
- "3.8"
29+
- type
30+
- dev
31+
- pkg_meta
32+
os:
33+
- ubuntu-latest
34+
- windows-latest
35+
- macos-latest
36+
exclude:
37+
- { os: macos-latest, env: "type" }
38+
- { os: macos-latest, env: "dev" }
39+
- { os: macos-latest, env: "pkg_meta" }
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
- name: Install the latest version of uv
45+
uses: astral-sh/setup-uv@v3
46+
with:
47+
enable-cache: true
48+
cache-dependency-glob: "pyproject.toml"
49+
github-token: ${{ secrets.GITHUB_TOKEN }}
50+
- name: Add .local/bin to Windows PATH
51+
if: runner.os == 'Windows'
52+
shell: bash
53+
run: echo "$USERPROFILE/.local/bin" >> $GITHUB_PATH
54+
- name: Install tox
55+
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
56+
- name: Install Python
57+
if: startsWith(matrix.env, '3.') && matrix.env != '3.13'
58+
run: uv python install --python-preference only-managed ${{ matrix.env }}
59+
- name: Setup test suite
60+
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.env }}
61+
- name: Run test suite
62+
run: tox run --skip-pkg-install -e ${{ matrix.env }}
63+
env:
64+
PYTEST_ADDOPTS: "-vv --durations=20"
65+
DIFF_AGAINST: HEAD

.github/workflows/check.yml

-82
This file was deleted.

.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/pyproject-api/${{ 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

.github/workflows/release.yml

-32
This file was deleted.

.pre-commit-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ repos:
2323
rev: "2.2.3"
2424
hooks:
2525
- id: pyproject-fmt
26-
additional_dependencies: ["tox>=4.18.1"]
2726
- repo: https://github.com/astral-sh/ruff-pre-commit
2827
rev: "v0.6.5"
2928
hooks:

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44
[![Supported Python
55
versions](https://img.shields.io/pypi/pyversions/pyproject-api.svg)](https://pypi.org/project/pyproject-api/)
66
[![Downloads](https://static.pepy.tech/badge/pyproject-api/month)](https://pepy.tech/project/pyproject-api)
7-
[![check](https://github.com/tox-dev/pyproject-api/actions/workflows/check.yml/badge.svg)](https://github.com/tox-dev/pyproject-api/actions/workflows/check.yml)
8-
[![Code style:
9-
black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
7+
[![check](https://github.com/tox-dev/pyproject-api/actions/workflows/check.yaml/badge.svg)](https://github.com/tox-dev/pyproject-api/actions/workflows/check.yaml)
108
[![Documentation Status](https://readthedocs.org/projects/pyproject-api/badge/?version=latest)](https://pyproject-api.readthedocs.io/en/latest/?badge=latest)

tox.ini

+35-29
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
requires =
3-
tox>=4.18.1
4-
tox-uv>=1.11.3
3+
tox>=4.2
4+
tox-uv>=1.11
55
env_list =
66
fix
77
3.13
@@ -10,46 +10,43 @@ env_list =
1010
3.10
1111
3.9
1212
3.8
13-
type
1413
docs
15-
readme
14+
type
15+
pkg_meta
1616
skip_missing_interpreters = true
1717

1818
[testenv]
19-
description = run the tests with pytest under {env_name}
19+
description = run the unit tests with pytest under {base_python}
2020
package = wheel
2121
wheel_build_env = .pkg
2222
extras =
2323
testing
2424
pass_env =
25-
PYTEST_*
25+
DIFF_AGAINST
26+
PYTES_*
2627
set_env =
27-
COVERAGE_FILE = {env:COVERAGE_FILE:{work_dir}{/}.coverage.{env_name}}
28+
COVERAGE_FILE = {work_dir}/.coverage.{env_name}
29+
COVERAGE_PROCESS_START = {tox_root}/pyproject.toml
30+
_COVERAGE_SRC = {env_site_packages_dir}/sphinx_argparse_cli
2831
commands =
29-
pytest {tty:--color=yes} {posargs: --no-cov-on-fail --cov-context=test \
30-
--cov={env_site_packages_dir}{/}pyproject_api --cov={tox_root}{/}tests --cov-config={tox_root}{/}pyproject.toml \
31-
--cov-report=term-missing:skip-covered --cov-report=html:{env_tmp_dir}{/}htmlcov \
32-
--cov-report=xml:{work_dir}{/}coverage.{env_name}.xml --junitxml={work_dir}{/}junit.{env_name}.xml \
32+
pytest {tty:--color=yes} {posargs: \
33+
--junitxml {work_dir}{/}junit.{env_name}.xml --cov {env_site_packages_dir}{/}pyproject_api \
34+
--cov {tox_root}{/}tests --cov-fail-under=100 \
35+
--cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \
36+
--cov-report html:{env_tmp_dir}{/}htmlcov --cov-report xml:{work_dir}{/}coverage.{env_name}.xml \
3337
tests}
34-
labels = test
3538

3639
[testenv:fix]
37-
description = run formatter and linters
38-
skip_install = true
40+
description = run static analysis and style check using flake8
41+
package = skip
3942
deps =
4043
pre-commit-uv>=4.1.1
44+
pass_env =
45+
HOMEPATH
46+
PROGRAMDATA
4147
commands =
42-
pre-commit run --all-files --show-diff-on-failure {tty:--color=always} {posargs}
43-
44-
[testenv:type]
45-
description = run type check on code base
46-
deps =
47-
mypy==1.11.2
48-
set_env =
49-
{tty:MYPY_FORCE_COLOR = 1}
50-
commands =
51-
mypy src/pyproject_api --strict
52-
mypy tests --strict
48+
pre-commit run --all-files --show-diff-on-failure
49+
python -c 'print("hint: run {envdir}/bin/pre-commit install to add checks as pre-commit hook")'
5350

5451
[testenv:docs]
5552
description = build documentation
@@ -59,7 +56,17 @@ commands =
5956
sphinx-build -d "{env_tmp_dir}{/}doc_tree" docs "{work_dir}{/}docs_out" --color -b html {posargs} -W
6057
python -c 'print(r"documentation available under file://{work_dir}{/}docs_out{/}index.html")'
6158

62-
[testenv:readme]
59+
[testenv:type]
60+
description = run type check on code base
61+
deps =
62+
mypy==1.11.2
63+
set_env =
64+
{tty:MYPY_FORCE_COLOR = 1}
65+
commands =
66+
mypy src
67+
mypy tests
68+
69+
[testenv:pkg_meta]
6370
description = check that the long description is valid
6471
skip_install = true
6572
deps =
@@ -72,11 +79,10 @@ commands =
7279
check-wheel-contents --no-config {env_tmp_dir}
7380

7481
[testenv:dev]
75-
description = dev environment with all deps at {envdir}
82+
description = generate a DEV environment
7683
package = editable
7784
extras =
78-
docs
7985
testing
8086
commands =
8187
uv pip tree
82-
python -c "print(r'{env_python}')"
88+
python -c 'import sys; print(sys.executable)'

0 commit comments

Comments
 (0)