Skip to content

Commit

Permalink
Modernize CI (#54)
Browse files Browse the repository at this point in the history
* Modernize CI

* Drop 3.7

* Add missing actions

* Fix uvx

* Add 3.13

* Fix tox.ini

* Make errors debugable

* lol colors in exceptions
  • Loading branch information
hynek authored Oct 8, 2024
1 parent 6cf54be commit 899be3a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 49 deletions.
53 changes: 27 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
branches: [main]
tags: ["*"]
pull_request:
branches: [main]
workflow_dispatch:

env:
Expand All @@ -15,6 +14,9 @@ env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"

permissions: {}


jobs:
build-package:
name: Build & verify package
Expand All @@ -26,6 +28,12 @@ jobs:
fetch-depth: 0

- uses: hynek/build-and-inspect-python-package@v2
id: baipp

outputs:
# Used to define the matrix for tests below. The value is based on
# packaging metadata (trove classifiers).
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}

tests:
name: Tests on ${{ matrix.python-version }}
Expand All @@ -35,13 +43,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
# Created by the build-and-inspect-python-package action above.
python-version: ${{ fromJson(needs.build-package.outputs.python-versions) }}

steps:
- name: Download pre-built packages
Expand All @@ -52,16 +55,15 @@ jobs:
- run: tar xf dist/*.tar.gz --strip-components=1 # needed for config files
- uses: actions/setup-python@v5
with:
cache: pip
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: hynek/setup-cached-uv@v2

- run: python -Im pip install tox

- run: |
python -Im tox run \
--installpkg dist/*.whl \
-f py$(echo ${{ matrix.python-version }} | tr -d .)
- run: >
uvx --with tox-uv
tox run
--installpkg dist/*.whl
-f py$(echo ${{ matrix.python-version }} | tr -d .)
- name: Upload coverage data
uses: actions/upload-artifact@v4
Expand All @@ -80,8 +82,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: pip
python-version-file: .python-version-default
- uses: hynek/setup-cached-uv@v2

- name: Download coverage data
uses: actions/download-artifact@v4
Expand All @@ -91,17 +93,16 @@ jobs:

- name: Combine coverage and fail if it's <100%.
run: |
python -Im pip install --upgrade coverage[toml]
uv tool install coverage[toml]
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
coverage combine
coverage html --skip-covered --skip-empty
# Report and write to summary.
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
# Report again and fail if under 100%.
python -Im coverage report --fail-under=100
coverage report --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v4
Expand All @@ -124,12 +125,12 @@ jobs:
- run: tar xf dist/*.tar.gz --strip-components=1 # needed for config files
- uses: actions/setup-python@v5
with:
cache: pip
python-version-file: .python-version-default
- uses: hynek/setup-cached-uv@v2

- run: python -Im pip install tox

- run: python -Im tox run -e mypy
- run: >
uvx --with tox-uv
tox run -e mypy
install-dev:
name: Verify dev env
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ The **third number** is for emergencies when we need to start branches for older

## [Unreleased](https://github.com/hynek/hatch-fancy-pypi-readme/compare/24.1.0...HEAD)

### Removed

- Support for Python 3.7.


## [24.1.0](https://github.com/hynek/hatch-fancy-pypi-readme/compare/23.2.0...24.1.0) - 2024-01-01

Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "hatchling.build"
name = "hatch-fancy-pypi-readme"
version = "24.2.0.dev0"
description = "Fancy PyPI READMEs with Hatch"
requires-python = ">=3.7"
requires-python = ">=3.8"
keywords = ["hatch", "pypi", "readme", "documentation"]
authors = [{ name = "Hynek Schlawack", email = "hs@ox.cx" }]
license = "MIT"
Expand All @@ -18,17 +18,16 @@ classifiers = [
"Operating System :: OS Independent",
"Topic :: Software Development :: Build Tools",

"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"hatchling",
"tomli; python_version<'3.11'",
"typing-extensions; python_version<'3.8'",
]

[project.entry-points.hatch]
Expand Down
9 changes: 1 addition & 8 deletions src/hatch_fancy_pypi_readme/_fragments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@
from __future__ import annotations

import re
import sys

from dataclasses import dataclass
from pathlib import Path
from typing import ClassVar, Iterable


if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol
from typing import ClassVar, Iterable, Protocol

from .exceptions import ConfigurationError

Expand Down
14 changes: 7 additions & 7 deletions tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ def test_invalid_config(new_project):

out = build_project(check=False)

assert "hatch_fancy_pypi_readme.exceptions.ConfigurationError:" in out
assert "hatch_fancy_pypi_readme.exceptions.ConfigurationError" in out, out
assert (
"tool.hatch.metadata.hooks.fancy-pypi-readme.content-type "
"is missing." in out
)
"tool.hatch.metadata.hooks.fancy-pypi-readme.content-type is missing."
in out
), out
assert (
"tool.hatch.metadata.hooks.fancy-pypi-readme.fragments "
"is missing." in out
)
"tool.hatch.metadata.hooks.fancy-pypi-readme.fragments is missing."
in out
), out
14 changes: 9 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ min_version = 4
env_list =
pre-commit,
mypy,
py3{7,8,9,10,11,12},
py3{7,10,11,12}-cli,
py3{8,9,10,11,12,13},
py3{8,9,10,11,12,13}-cli,
coverage-report


[pkgenv]
pass_env = SETUPTOOLS_SCM_PRETEND_VERSION


[testenv]
package = wheel
wheel_build_env = .pkg
Expand All @@ -18,7 +22,7 @@ pass_env =
commands = pytest {posargs}


[testenv:py3{7,10,12}-cli]
[testenv:py3{8,10,13}-cli]
deps = coverage[toml]
commands =
# Use -o only once, so we exercise both code paths.
Expand All @@ -38,7 +42,7 @@ deps = mypy
commands = mypy src


[testenv:py31{0,2}]
[testenv:py31{0,3}]
deps = coverage[toml]
commands = coverage run -m pytest {posargs}

Expand All @@ -54,7 +58,7 @@ commands =


[testenv:svg]
description = Refresh SVG, test running using pipx.
description = Refresh SVG, test running using Pipx.
deps = pipx
skip_install = true
allowlist_externals = npx
Expand Down

0 comments on commit 899be3a

Please sign in to comment.