Skip to content

Commit

Permalink
Use baipp for building the CI matrix (#73)
Browse files Browse the repository at this point in the history
* Use baipp for building the matrix

* fix

* Better name

* Don't run pypi-package on PRs

It already runs as part of ci.yml anyways.

* fix

* Explicitly forbid pytest to enter typing test dir
  • Loading branch information
hynek authored Oct 26, 2024
1 parent a2ddfef commit 8ee0094
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 31 deletions.
97 changes: 68 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name: CI
on:
push:
branches: [main]
tags: ["*"]
pull_request:
workflow_dispatch:

Expand All @@ -14,6 +15,7 @@ env:

permissions: {}


jobs:
lint:
name: Run linters
Expand All @@ -29,45 +31,55 @@ jobs:
uvx --with tox-uv
tox run -e lint -- --show-diff-on-failure
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).
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}


tests:
name: Tests on ${{ matrix.python-version }}
name: Tests & Mypy API on ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: build-package
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy-3.9"
- "pypy-3.10"
# Created by the build-and-inspect-python-package action above.
python-version: ${{ fromJson(needs.build-package.outputs.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
rm -rf src
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: hynek/setup-cached-uv@v2

- name: Prepare tox & run tests
run: |
V=${{ matrix.python-version }}
if [[ "$V" = pypy-* ]]; then
V=pypy3
else
V=py$(echo $V | tr -d .)
fi
uvx --with tox-uv \
tox run -f "$V"
- name: Run Mypy on API
- name: Run tests
run: >
uvx --with tox-uv
tox run -e mypy-api
tox run
--installpkg dist/*.whl
-f py$(echo ${{ matrix.python-version }} | tr -d .)
- name: Upload coverage data
uses: actions/upload-artifact@v4
Expand All @@ -77,8 +89,16 @@ jobs:
include-hidden-files: true
if-no-files-found: ignore

- name: Check public API with Mypy
run: >
uvx --with tox-uv
tox run
--installpkg dist/*.whl
-e mypy-api
coverage:
name: Combine & check coverage
name: Ensure 100% test coverage
needs: tests
runs-on: ubuntu-latest

Expand Down Expand Up @@ -114,12 +134,19 @@ jobs:
path: htmlcov
if: ${{ failure() }}


mypy-pkg:
name: Type-check package
name: Mypy Codebase
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:
python-version-file: .python-version-default
Expand All @@ -129,6 +156,7 @@ jobs:
uvx --with tox-uv
tox run -e mypy-pkg
install-dev:
strategy:
matrix:
Expand All @@ -148,12 +176,22 @@ jobs:
run: |
python -Im pip install -e .[dev]
python -Ic 'import service_identity; print(service_identity.__version__)'
python -Ic 'import service_identity.pyopenssl'
python -Ic 'import service_identity.cryptography'
docs:
name: Build docs & run doctests
needs: build-package
runs-on: ubuntu-latest

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.ini/docs & .readthedocs.yaml
Expand All @@ -164,6 +202,7 @@ jobs:
uvx --with tox-uv
tox run -e docs
required-checks-pass:
name: Ensure everything required is passing for branch protection
if: always()
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pypi-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
push:
branches: [main]
tags: ["*"]
pull_request:
release:
types:
- published
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ addopts = ["-ra", "--strict-markers", "--strict-config"]
xfail_strict = true
testpaths = "tests"
filterwarnings = ["once::Warning"]
norecursedirs = ["tests/typing"]


[tool.coverage.run]
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ env_list =
lint,
mypy-{api,pkg},
docs,
pypy3{,-pyopenssl-latest-idna},
py3{8,9,10,11,12}{,-pyopenssl}{,-oldest}{,-idna},
coverage-report

Expand Down

0 comments on commit 8ee0094

Please sign in to comment.