Skip to content

Commit

Permalink
Improve the CI (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat authored Sep 17, 2024
1 parent 302f383 commit e0929c6
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 147 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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:
name: test ${{ matrix.env }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
env:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
- "3.9"
- "3.8"
- type
- dev
- pkg_meta
os:
- ubuntu-latest
- windows-latest
- macos-latest
exclude:
- { os: macos-latest, env: "type" }
- { os: macos-latest, env: "dev" }
- { os: macos-latest, env: "pkg_meta" }
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: Add .local/bin to Windows PATH
if: runner.os == 'Windows'
shell: bash
run: echo "$USERPROFILE/.local/bin" >> $GITHUB_PATH
- 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
82 changes: 0 additions & 82 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/pyproject-api/${{ 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
32 changes: 0 additions & 32 deletions .github/workflows/release.yml

This file was deleted.

1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ repos:
rev: "2.2.3"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.18.1"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.5"
hooks:
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
[![Supported Python
versions](https://img.shields.io/pypi/pyversions/pyproject-api.svg)](https://pypi.org/project/pyproject-api/)
[![Downloads](https://static.pepy.tech/badge/pyproject-api/month)](https://pepy.tech/project/pyproject-api)
[![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)
[![Code style:
black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![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)
[![Documentation Status](https://readthedocs.org/projects/pyproject-api/badge/?version=latest)](https://pyproject-api.readthedocs.io/en/latest/?badge=latest)
64 changes: 35 additions & 29 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
requires =
tox>=4.18.1
tox-uv>=1.11.3
tox>=4.2
tox-uv>=1.11
env_list =
fix
3.13
Expand All @@ -10,46 +10,43 @@ env_list =
3.10
3.9
3.8
type
docs
readme
type
pkg_meta
skip_missing_interpreters = true

[testenv]
description = run the tests with pytest under {env_name}
description = run the unit tests with pytest under {base_python}
package = wheel
wheel_build_env = .pkg
extras =
testing
pass_env =
PYTEST_*
DIFF_AGAINST
PYTES_*
set_env =
COVERAGE_FILE = {env:COVERAGE_FILE:{work_dir}{/}.coverage.{env_name}}
COVERAGE_FILE = {work_dir}/.coverage.{env_name}
COVERAGE_PROCESS_START = {tox_root}/pyproject.toml
_COVERAGE_SRC = {env_site_packages_dir}/sphinx_argparse_cli
commands =
pytest {tty:--color=yes} {posargs: --no-cov-on-fail --cov-context=test \
--cov={env_site_packages_dir}{/}pyproject_api --cov={tox_root}{/}tests --cov-config={tox_root}{/}pyproject.toml \
--cov-report=term-missing:skip-covered --cov-report=html:{env_tmp_dir}{/}htmlcov \
--cov-report=xml:{work_dir}{/}coverage.{env_name}.xml --junitxml={work_dir}{/}junit.{env_name}.xml \
pytest {tty:--color=yes} {posargs: \
--junitxml {work_dir}{/}junit.{env_name}.xml --cov {env_site_packages_dir}{/}pyproject_api \
--cov {tox_root}{/}tests --cov-fail-under=100 \
--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 \
tests}
labels = test

[testenv:fix]
description = run formatter and linters
skip_install = true
description = run static analysis and style check using flake8
package = skip
deps =
pre-commit-uv>=4.1.1
pass_env =
HOMEPATH
PROGRAMDATA
commands =
pre-commit run --all-files --show-diff-on-failure {tty:--color=always} {posargs}

[testenv:type]
description = run type check on code base
deps =
mypy==1.11.2
set_env =
{tty:MYPY_FORCE_COLOR = 1}
commands =
mypy src/pyproject_api --strict
mypy tests --strict
pre-commit run --all-files --show-diff-on-failure
python -c 'print("hint: run {envdir}/bin/pre-commit install to add checks as pre-commit hook")'

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

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

[testenv:pkg_meta]
description = check that the long description is valid
skip_install = true
deps =
Expand All @@ -72,11 +79,10 @@ commands =
check-wheel-contents --no-config {env_tmp_dir}

[testenv:dev]
description = dev environment with all deps at {envdir}
description = generate a DEV environment
package = editable
extras =
docs
testing
commands =
uv pip tree
python -c "print(r'{env_python}')"
python -c 'import sys; print(sys.executable)'

0 comments on commit e0929c6

Please sign in to comment.