Skip to content

Commit

Permalink
Improve the CI
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Sep 17, 2024
1 parent 3545c59 commit 708b55e
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 164 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: check
on:
workflow_dispatch:
push:
branches: ["main"]
tags-ignore: ["**"]
pull_request:
schedule:
- cron: "0 8 * * *"

concurrency:
group: check-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
env:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
- "3.9"
- "3.8"
- type
- dev
- pkg_meta
steps:
- name: Install OS dependencies
run: sudo apt-get install graphviz -y
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
- name: Install Python
if: startsWith(matrix.env, '3.') && matrix.env != '3.13'
run: uv python install --python-preference only-managed ${{ matrix.env }}
- name: Setup test suite
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.env }}
- name: Run test suite
run: tox run --skip-pkg-install -e ${{ matrix.env }}
env:
PYTEST_ADDOPTS: "-vv --durations=20"
DIFF_AGAINST: HEAD
104 changes: 0 additions & 104 deletions .github/workflows/check.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release to PyPI
on:
push:
tags: ["*"]

env:
dists-artifact-name: python-package-distributions

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build package
run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: ${{ env.dists-artifact-name }}
path: dist/*

release:
needs:
- build
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/project/tox-uv/${{ github.ref_name }}
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: ${{ env.dists-artifact-name }}
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.10.1
with:
attestations: true
29 changes: 0 additions & 29 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![PyPI version](https://badge.fury.io/py/tox-uv.svg)](https://badge.fury.io/py/tox-uv)
[![PyPI Supported Python Versions](https://img.shields.io/pypi/pyversions/tox-uv.svg)](https://pypi.python.org/pypi/tox-uv/)
[![check](https://github.com/tox-dev/tox-uv/actions/workflows/check.yml/badge.svg)](https://github.com/tox-dev/tox-uv/actions/workflows/check.yml)
[![check](https://github.com/tox-dev/tox-uv/actions/workflows/check.yaml/badge.svg)](https://github.com/tox-dev/tox-uv/actions/workflows/check.yaml)
[![Downloads](https://static.pepy.tech/badge/tox-uv/month)](https://pepy.tech/project/tox-uv)

**tox-uv** is a tox plugin which replaces virtualenv and pip with uv in your tox environments.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies = [
"typing-extensions>=4.12.2; python_version<'3.10'",
"uv<1,>=0.4.7",
]
optional-dependencies.test = [
optional-dependencies.testing = [
"covdefaults>=2.3",
"devpi-process>=1",
"pytest>=8.3.2",
Expand Down
54 changes: 25 additions & 29 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
requires =
tox>=4.2
tox-uv>=1.11.2
tox-uv>=1.11.3
env_list =
fix
3.13
Expand All @@ -11,64 +11,60 @@ env_list =
3.9
3.8
type
readme
pkg_meta
skip_missing_interpreters = true

[testenv]
description = run the unit tests with pytest under {basepython}
description = run the unit tests with pytest under {base_python}
package = wheel
wheel_build_env = .pkg
extras =
test
testing
pass_env =
DIFF_AGAINST
PYTEST_*
set_env =
COVERAGE_FILE = {toxworkdir}{/}.coverage.{envname}
COVERAGE_FILE = {work_dir}/.coverage.{env_name}
commands =
pytest {tty:--color=yes} {posargs: \
--cov {envsitepackagesdir}{/}tox_uv --cov {toxinidir}{/}tests --cov-context=test \
--no-cov-on-fail --cov-config {toxinidir}{/}pyproject.toml \
--cov-report term-missing:skip-covered --junitxml {toxworkdir}{/}junit.{envname}.xml \
--cov-report html:{envtmpdir}{/}htmlcov --durations=5 \
python -m pytest {tty:--color=yes} {posargs: \
--cov {env_site_packages_dir}{/}tox_uv --cov {tox_root}{/}tests \
--cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \
--cov-report html:{env_tmp_dir}{/}htmlcov --cov-report xml:{work_dir}{/}coverage.{env_name}.xml \
--junitxml {work_dir}{/}junit.{env_name}.xml \
tests}
diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {work_dir}{/}coverage.{env_name}.xml --fail-under 100

[testenv:fix]
description = run static analysis and style check using flake8
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
skip_install = true
deps =
pre-commit-uv>=4.1
pass_env =
HOMEPATH
PROGRAMDATA
pre-commit-uv>=4.1.1
commands =
pre-commit run --all-files --show-diff-on-failure

[testenv:type]
description = run type check on code base
deps =
mypy==1.11.2
set_env =
{tty:MYPY_FORCE_COLOR = 1}
commands =
mypy src {posargs}
mypy tests {posargs}
mypy src
mypy tests

[testenv:readme]
description = check that the package metadata is correct
[testenv:pkg_meta]
description = check that the long description is valid
skip_install = true
deps =
build[virtualenv]>=1.2.2
check-wheel-contents>=0.6
twine>=5.1.1
set_env =
{tty:FORCE_COLOR = 1}
change_dir = {toxinidir}
uv>=0.4.10
commands =
python -m build --sdist --wheel -o {envtmpdir} .
twine check {envtmpdir}{/}*
uv build --sdist --wheel --out-dir {env_tmp_dir} .
twine check {env_tmp_dir}{/}*
check-wheel-contents --no-config {env_tmp_dir}

[testenv:dev]
description = generate a DEV environment
package = editable
extras =
test
commands =
uv pip tree
python -c 'import sys; print(sys.executable)'

0 comments on commit 708b55e

Please sign in to comment.