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 <[email protected]>
  • Loading branch information
gaborbernat committed Sep 17, 2024
1 parent e498652 commit 6637364
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 116 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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:
- 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
72 changes: 0 additions & 72 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-fmt/${{ 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/[email protected]
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 @@ -5,7 +5,7 @@
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyproject-fmt?style=flat-square)](https://pypi.org/project/pyproject-fmt)
[![Downloads](https://static.pepy.tech/badge/pyproject-fmt/month)](https://pepy.tech/project/pyproject-fmt)
[![PyPI - License](https://img.shields.io/pypi/l/pyproject-fmt?style=flat-square)](https://opensource.org/licenses/MIT)
[![check](https://github.com/tox-dev/pyproject-fmt/actions/workflows/check.yml/badge.svg)](https://github.com/tox-dev/pyproject-fmt/actions/workflows/check.yml)
[![check](https://github.com/tox-dev/pyproject-fmt/actions/workflows/check.yaml/badge.svg)](https://github.com/tox-dev/pyproject-fmt/actions/workflows/check.yaml)

Apply a consistent format to the `pyproject.toml` files.

Expand Down
29 changes: 15 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tox]
requires =
tox>=4.2
tox-uv>=1.11.3
env_list =
fix
3.13
Expand All @@ -10,7 +11,7 @@ env_list =
3.9
3.8
type
readme
pkg_meta
docs
skip_missing_interpreters = true

Expand All @@ -21,22 +22,20 @@ wheel_build_env = .pkg
extras =
test
set_env =
COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
COVERAGE_PROCESS_START = {toxinidir}/setup.cfg
_COVERAGE_SRC = {envsitepackagesdir}/sphinx_argparse_cli
COVERAGE_FILE = {work_dir}/.coverage.{env_name}
commands =
python -m pytest {tty:--color=yes} {posargs: \
--junitxml {toxworkdir}{/}junit.{envname}.xml --cov {envsitepackagesdir}{/}pyproject_fmt \
--cov {toxinidir}{/}tests --cov-fail-under=100 \
--junitxml {work_dir}{/}junit.{env_name}.xml --cov {env_site_packages_dir}{/}pyproject_fmt \
--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:{envtmpdir}{/}htmlcov --cov-report xml:{toxworkdir}{/}coverage.{envname}.xml \
--cov-report html:{env_tmp_dir}{/}htmlcov --cov-report xml:{work_dir}{/}coverage.{env_name}.xml \
tests}

[testenv:fix]
description = run static analysis and style check using flake8
skip_install = true
deps =
pre-commit>=3.8
pre-commit-uv>=4.1.1
commands =
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")'
Expand All @@ -49,24 +48,26 @@ commands =
mypy src
mypy tests

[testenv:readme]
[testenv:pkg_meta]
description = check that the long description is valid
skip_install = true
deps =
build[uv]>=1.2.2
check-wheel-contents>=0.6
twine>=5.1.1
uv>=0.4.10
commands =
pyproject-build --installer uv --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:docs]
description = build documentation
extras =
docs
set_env =
DOCS_OUT = {posargs:{toxworkdir}{/}docs_out}
DOCS_OUT = {posargs:{work_dir}{/}docs_out}
commands =
sphinx-build -d "{envtmpdir}{/}doctree" docs "{env:DOCS_OUT}" --color -b html
sphinx-build -d "{env_tmp_dir}{/}doc_tree" docs "{env:DOCS_OUT}" --color -b html
python -c 'print(r"documentation available under file://{env:DOCS_OUT}{/}index.html")'

[testenv:dev]
Expand Down

0 comments on commit 6637364

Please sign in to comment.