Skip to content

Commit 76ba821

Browse files
authored
Improve the CI (#16)
1 parent e466ee2 commit 76ba821

File tree

7 files changed

+116
-134
lines changed

7 files changed

+116
-134
lines changed

.github/workflows/check.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
- "3.9"
27+
- type
28+
- dev
29+
- pkg_meta
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
- name: Install the latest version of uv
35+
uses: astral-sh/setup-uv@v3
36+
with:
37+
enable-cache: true
38+
cache-dependency-glob: "pyproject.toml"
39+
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
- name: Install tox
41+
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
42+
- name: Install Python
43+
if: startsWith(matrix.env, '3.') && matrix.env != '3.13'
44+
run: uv python install --python-preference only-managed ${{ matrix.env }}
45+
- name: Setup test suite
46+
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.env }}
47+
- name: Run test suite
48+
run: tox run --skip-pkg-install -e ${{ matrix.env }}
49+
env:
50+
PYTEST_ADDOPTS: "-vv --durations=5"

.github/workflows/check.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 48 additions & 0 deletions
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/pre-commit-uv/${{ 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/gh-action-pypi-publish@v1.10.1
47+
with:
48+
attestations: true

.github/workflows/release.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
66
[![Downloads](https://static.pepy.tech/badge/pre-commit-uv/month)](https://pepy.tech/project/pre-commit-uv)
77
[![PyPI - License](https://img.shields.io/pypi/l/pre-commit-uv?style=flat-square)](https://opensource.org/licenses/MIT)
8-
[![check](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yml/badge.svg)](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yml)
8+
[![check](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yaml/badge.svg)](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yaml)
99

1010
Use `uv` to create virtual environments and install packages for `pre-commit`.
1111

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies = [
3636
"pre-commit>=3.8",
3737
"uv>=0.4.7",
3838
]
39-
optional-dependencies.test = [
39+
optional-dependencies.testing = [
4040
"covdefaults>=2.3",
4141
"pytest>=8.3.2",
4242
"pytest-cov>=5",

tox.ini

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,68 +9,61 @@ env_list =
99
3.11
1010
3.10
1111
3.9
12+
3.8
1213
type
13-
readme
14+
pkg_meta
1415
skip_missing_interpreters = true
1516

1617
[testenv]
17-
description = run the unit tests with pytest under {basepython}
18+
description = run the unit tests with pytest under {base_python}
1819
package = wheel
1920
wheel_build_env = .pkg
2021
extras =
21-
test
22+
testing
2223
pass_env =
23-
PYTEST_ADDOPTS
24+
PYTEST_*
2425
set_env =
25-
COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
26+
COVERAGE_FILE = {work_dir}/.coverage.{env_name}
2627
FORCE_PRE_COMMIT_UV_PATCH = true
2728
commands =
2829
python -m pytest {tty:--color=yes} {posargs: \
29-
--junitxml {toxworkdir}{/}junit.{envname}.xml --cov {envsitepackagesdir}{/}pre_commit_uv \
30-
--cov {toxinidir}{/}tests \
30+
--cov {env_site_packages_dir}{/}pre_commit_uv --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}
3435

3536
[testenv:fix]
36-
description = run static analysis and style check using flake8
37+
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
3738
skip_install = true
3839
deps =
39-
pre-commit-uv>=4.1
40+
pre-commit-uv>=4.1.1
4041
commands =
4142
pre-commit run --all-files --show-diff-on-failure
42-
python -c 'print("hint: run {envdir}/bin/pre-commit install to add checks as pre-commit hook")'
4343

4444
[testenv:type]
4545
description = run type check on code base
4646
deps =
4747
mypy==1.11.2
48-
set_env =
49-
{tty:MYPY_FORCE_COLOR = 1}
5048
commands =
5149
mypy src
5250
mypy tests
5351

54-
[testenv:readme]
52+
[testenv:pkg_meta]
5553
description = check that the long description is valid
5654
skip_install = true
5755
deps =
58-
build[uv]>=1.2.2
5956
check-wheel-contents>=0.6
6057
twine>=5.1.1
58+
uv>=0.4.10
6159
commands =
62-
pyproject-build --installer uv --outdir {envtmpdir} --sdist --wheel .
63-
twine check {envtmpdir}{/}*
64-
check-wheel-contents --no-config {envtmpdir}
60+
uv build --sdist --wheel --out-dir {env_tmp_dir} .
61+
twine check {env_tmp_dir}{/}*
62+
check-wheel-contents --no-config {env_tmp_dir}
6563

6664
[testenv:dev]
6765
description = generate a DEV environment
6866
package = editable
69-
extras =
70-
docs
71-
test
72-
set_env =
73-
FORCE_PRE_COMMIT_UV_PATCH = true
7467
commands =
7568
uv tree
7669
python -c 'import sys; print(sys.executable)'

0 commit comments

Comments
 (0)