Skip to content

Commit

Permalink
Dedup Python versions (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek authored Nov 5, 2024
1 parent e014407 commit a7be10a
Showing 1 changed file with 54 additions and 20 deletions.
74 changes: 54 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,68 @@ env:

permissions: {}


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

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

- 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 API 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"
# Created by the build-and-inspect-python-package action above.
python-version: ${{ fromJson(needs.build-package.outputs.supported-python-versions) }}

env:
PYTHON: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v4
- name: Download pre-built packages
uses: actions/download-artifact@v4
with:
persist-credentials: false
name: Packages
path: dist
- run: |
rm -rf src
tar xf dist/*.tar.gz --strip-components=1
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip

- run: python -Im pip install --upgrade wheel tox
- run: python -Im pip install --upgrade tox

- run: python -Im tox run -f py$(echo $PYTHON | tr -d .)
- run: python -Im tox run -e mypy-api
- run: >
python -Im
tox run
--installpkg dist/*.whl
-f py$(echo $PYTHON | tr -d .)
- run: >
python -Im
tox run
--installpkg dist/*.whl
-e mypy-api
- name: Upload coverage data
uses: actions/upload-artifact@v4
Expand All @@ -57,6 +87,7 @@ jobs:
include-hidden-files: true
if-no-files-found: ignore


coverage:
name: Combine & check coverage
needs: tests
Expand All @@ -69,9 +100,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version-file: .python-version-default
cache: pip

- run: python -Im pip install --upgrade coverage[toml]
- uses: hynek/setup-cached-uv@v2

- uses: actions/download-artifact@v4
with:
Expand All @@ -80,14 +109,16 @@ jobs:

- name: Combine coverage & fail if it's <100%.
run: |
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
uv tool install coverage
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 @@ -96,6 +127,7 @@ jobs:
path: htmlcov
if: ${{ failure() }}


mypy-pkg:
name: Mypy Codebase
runs-on: ubuntu-latest
Expand All @@ -113,6 +145,7 @@ jobs:

- run: python -Im tox run -e mypy-pkg


docs:
name: Build docs & run doctests
runs-on: ubuntu-latest
Expand All @@ -129,6 +162,7 @@ jobs:

- run: python -Im tox run -e docs


install-dev:
name: Verify dev env
runs-on: ${{ matrix.os }}
Expand Down

0 comments on commit a7be10a

Please sign in to comment.