Switch to build-and-inspect-python-package (#1307)
* Switch to build-and-inspect-python-package Use the occasion to factor out PyPy jobs which simplifies everthing. * Only install pytest-codspeed when benchmarking * No need to build twice on PRs * No coverage on PyPy * Still require PyPy to pass * Actually remove codspeed from tests * Separate glacial CodSpeed into own workflow Might switch to on-demand/cron if we don't find a way for it to run under 5 minutes. * Get rid of version override * Add missing needs * Test should pass without src * oops * Make PyPy wheel-only, too * Clarify * Explain how the matrix works since everybody steals my stuff
This commit is contained in:
parent
e4bffa0a74
commit
5f93a31aff
|
@ -10,36 +10,48 @@ on:
|
|||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
FORCE_COLOR: "1" # Make tools pretty.
|
||||
FORCE_COLOR: "1"
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
PIP_NO_PYTHON_VERSION_WARNING: "1"
|
||||
# Use oldest version used in doctests / examples.
|
||||
SETUPTOOLS_SCM_PRETEND_VERSION: "19.2.0"
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
build-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:
|
||||
# Used to define the matrix for tests below. The value is based on
|
||||
# packaging metadata (trove classifiers).
|
||||
supported-python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}
|
||||
|
||||
tests:
|
||||
name: Tests & Mypy on ${{ matrix.python-version }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-package
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version:
|
||||
- "3.7"
|
||||
- "3.8"
|
||||
- "3.9"
|
||||
- "3.10"
|
||||
- "3.11"
|
||||
- "3.12"
|
||||
- "3.13"
|
||||
- "pypy-3.8"
|
||||
- "pypy-3.9"
|
||||
- "pypy-3.10"
|
||||
# Created by the build-and-inspect-python-package action above.
|
||||
python-version: ${{ fromJson(needs.build-package.outputs.supported-python-versions) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download pre-built packages
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Packages
|
||||
path: dist
|
||||
- run: tar xf dist/*.tar.gz --strip-components=1
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
@ -51,33 +63,30 @@ jobs:
|
|||
V=${{ matrix.python-version }}
|
||||
DO_MYPY=1
|
||||
|
||||
if [[ "$V" = pypy-* ]]; then
|
||||
if [[ "$V" == "3.7" || "$V" == "3.8" ]]; then
|
||||
DO_MYPY=0
|
||||
|
||||
V=pypy3
|
||||
else
|
||||
if [[ "$V" == "3.7" || "$V" == "3.8" ]]; then
|
||||
DO_MYPY=0
|
||||
echo "skipping $V"
|
||||
else
|
||||
echo "not skipping $V"
|
||||
fi
|
||||
|
||||
V=py$(echo $V | tr -d .)
|
||||
fi
|
||||
|
||||
echo DO_MYPY=$DO_MYPY >>$GITHUB_ENV
|
||||
echo TOX_PYTHON=$V >>$GITHUB_ENV
|
||||
echo TOX_PYTHON=py$(echo $V | tr -d .) >>$GITHUB_ENV
|
||||
|
||||
python -Im pip install tox
|
||||
|
||||
- run: python -Im pip install tox-uv
|
||||
if: matrix.python-version != '3.7'
|
||||
|
||||
- run: python -Im tox run -e ${{ env.TOX_PYTHON }}-tests
|
||||
- run: python -Im tox run -e ${{ env.TOX_PYTHON }}-mypy
|
||||
if: env.DO_MYPY == '1'
|
||||
|
||||
- name: Remove src to ensure tests run against wheel
|
||||
run: rm -rf src
|
||||
|
||||
- run: >
|
||||
python -Im
|
||||
tox run
|
||||
--installpkg dist/*.whl
|
||||
-e ${{ env.TOX_PYTHON }}-tests
|
||||
|
||||
- name: Upload coverage data
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
@ -85,13 +94,54 @@ jobs:
|
|||
path: .coverage.*
|
||||
if-no-files-found: ignore
|
||||
|
||||
tests-pypy:
|
||||
name: Tests on ${{ matrix.python-version }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-package
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version:
|
||||
- pypy-3.8
|
||||
- pypy-3.9
|
||||
- pypy-3.10
|
||||
|
||||
steps:
|
||||
- name: Download pre-built packages
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Packages
|
||||
path: dist
|
||||
- run: |
|
||||
tar xf dist/*.tar.gz --strip-components=1
|
||||
rm -rf src # ensure tests run against wheel
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
allow-prereleases: true
|
||||
cache: pip
|
||||
|
||||
- run: python -Im pip install tox-uv
|
||||
|
||||
- run: >
|
||||
python -Im
|
||||
tox run
|
||||
--installpkg dist/*.whl
|
||||
-e pypy3-tests
|
||||
|
||||
coverage:
|
||||
name: Combine & check coverage.
|
||||
runs-on: ubuntu-latest
|
||||
needs: tests
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download pre-built packages
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Packages
|
||||
path: dist
|
||||
- run: tar xf dist/*.tar.gz --strip-components=1
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version-file: .python-version-default
|
||||
|
@ -123,32 +173,17 @@ jobs:
|
|||
path: htmlcov
|
||||
if: ${{ failure() }}
|
||||
|
||||
|
||||
codspeed:
|
||||
name: Run CodSpeed benchmarks
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'merge_group'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version-file: .python-version-default
|
||||
cache: pip
|
||||
- run: python -Im pip install tox-uv
|
||||
|
||||
- name: Run CodSpeed benchmarks
|
||||
uses: CodSpeedHQ/action@v2
|
||||
with:
|
||||
token: ${{ secrets.CODSPEED_TOKEN }}
|
||||
run: tox run -e codspeed
|
||||
|
||||
|
||||
docs:
|
||||
name: Build docs & run doctests
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-package
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download pre-built packages
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Packages
|
||||
path: dist
|
||||
- run: tar xf dist/*.tar.gz --strip-components=1
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
# Keep in sync with tox/docs and .readthedocs.yaml.
|
||||
|
@ -197,6 +232,7 @@ jobs:
|
|||
|
||||
needs:
|
||||
- coverage
|
||||
- tests-pypy
|
||||
- docs
|
||||
- install-dev
|
||||
- pyright
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
name: CodSpeed Benchmarks
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["*"]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
env:
|
||||
FORCE_COLOR: "1"
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
PIP_NO_PYTHON_VERSION_WARNING: "1"
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
codspeed:
|
||||
name: Run CodSpeed benchmarks
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version-file: .python-version-default
|
||||
cache: pip
|
||||
- run: python -Im pip install tox-uv
|
||||
|
||||
- name: Run CodSpeed benchmarks
|
||||
uses: CodSpeedHQ/action@v2
|
||||
with:
|
||||
token: ${{ secrets.CODSPEED_TOKEN }}
|
||||
run: tox run -e codspeed
|
|
@ -5,8 +5,6 @@ on:
|
|||
push:
|
||||
branches: [main]
|
||||
tags: ["*"]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
|
|
@ -9,7 +9,7 @@ repos:
|
|||
- id: black
|
||||
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.5.2
|
||||
rev: v0.5.3
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
|
|
|
@ -43,8 +43,6 @@ tests = [
|
|||
"pympler",
|
||||
# 4.3.0 dropped last use of `convert`
|
||||
"pytest>=4.3.0",
|
||||
# CodSpeed needs CFFI, and CFFI doesn't speak 3.13.
|
||||
'pytest-codspeed; python_version < "3.13"',
|
||||
"pytest-xdist[psutil]",
|
||||
"attrs[tests-mypy]",
|
||||
]
|
||||
|
@ -53,6 +51,11 @@ cov = [
|
|||
# Ensure coverage is new enough for `source_pkgs`.
|
||||
"coverage[toml]>=5.3",
|
||||
]
|
||||
benchmark = [
|
||||
"pytest-codspeed",
|
||||
"pytest-xdist[psutil]",
|
||||
"attrs[tests]",
|
||||
]
|
||||
docs = [
|
||||
"cogapp",
|
||||
"furo",
|
||||
|
|
Loading…
Reference in New Issue