Skip to content

Commit

Permalink
Improve CI workflow
Browse files Browse the repository at this point in the history
- Use build-and-inspect-python-package to build the wheel/sdist
- Run tox against packaged code
- Drop support for CPython 3.7
- Drop support for PyPy 3.7, 3.8
- Test against CPython 3.11, 3.12, 3.13
- Test against PyPy 3.9, 3.10
  • Loading branch information
nickstenning committed Oct 6, 2024
1 parent 37e02cd commit 4b42f33
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 49 deletions.
91 changes: 48 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,67 @@ on:
branches: ["main"]
workflow_dispatch:

env:
FORCE_COLOR: "1"

jobs:
package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

outputs:
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}

tests:
name: "Python ${{ matrix.python-version }}"
runs-on: "ubuntu-latest"
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: package

strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7", "pypy-3.8"]
python-version:
- pypy3.9
- pypy3.10
- ${{ fromJson(needs.package.outputs.python-versions) }}

steps:
- uses: "actions/checkout@v2"
- name: Download pre-built packages
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- uses: "actions/setup-python@v2"
- run: tar xf dist/*.tar.gz --strip-components=1

- uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: "Install dependencies"
run: |
set -xe
python -VV
python -m site
python -m pip install --upgrade pip
pip install coverage tox tox-gh-actions
- uses: hynek/setup-cached-uv@v2

- name: "Run tox targets for ${{ matrix.python-version }}"
run: "tox"
- name: Run tox
run: >
uvx --with=tox-uv --with=tox-gh-actions
tox run --installpkg dist/*.whl
- name: "Coverage report"
if: "${{ matrix.python-version == '3.8' }}"
- name: Coverage report
if: ${{ matrix.python-version == '3.12' }}
run: |
coverage report
coverage xml
uvx coverage report
uvx coverage xml
- name: "Upload coverage to Codecov"
if: "${{ matrix.python-version == '3.8' }}"
uses: "codecov/codecov-action@v2"
- name: Upload coverage to Codecov
if: ${{ matrix.python-version == '3.12' }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true

package:
name: "Build & verify package"
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "3.10"

- name: "Install build, check-wheel-contents, and twine"
run: "python -m pip install build twine check-wheel-contents"
- name: "Build package"
run: "python -m build --sdist --wheel ."
- name: "List result"
run: "ls -l dist"
- name: "Check wheel contents"
run: "check-wheel-contents dist/*.whl"
- name: "Check long_description"
run: "python -m twine check dist/*"
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"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",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
'colorama; sys_platform=="win32"',
Expand Down
12 changes: 7 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py37, py38, py39, py310, pypy37, pypy38, lint
envlist = py38, py39, py310, py311, py312, py313, pypy39, pypy310, lint

[flake8]
max-line-length = 110
Expand All @@ -16,12 +16,14 @@ testpaths = tests

[gh-actions]
python =
3.7: py37
3.8: py38, lint, docs
3.8: py38
3.9: py39
3.10: py310
pypy-3.7: pypy37
pypy-3.8: pypy38
3.11: py311
3.12: py312, lint, docs
3.13: py313
pypy-3.9: pypy39
pypy-3.10: pypy310

[testenv]
extras = export
Expand Down

0 comments on commit 4b42f33

Please sign in to comment.