Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 87 additions & 10 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,51 @@ on:
- npe2
workflow_dispatch:

env:
FORCE_COLOR: "1"

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

steps:
- uses: actions/checkout@v4

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

ouputs:
# 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 }}

test:
name: ${{ matrix.platform }} py${{ matrix.python-version }}
runs-on: ${{ matrix.platform }}
timeout-minutes: 30
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ${{ fromJson(needs.build-package.outputs.python-versions) }}

steps:
- uses: actions/checkout@v4
env:
PYTHON: ${{ matrix.python-version }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
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
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: hynek/setup-cached-uv@v2

# these libraries enable testing on Qt on linux
- uses: tlambert03/setup-qt-libs@v1
Expand All @@ -57,12 +85,61 @@ jobs:
- name: Test with tox
uses: aganders3/headless-gui@v2
with:
run: python -m tox
env:
PLATFORM: ${{ matrix.platform }}
run: >
uvx --with tox-uv tox run
--installpkg dist/*.whl
-f py${PYTHON//./}-tests

# - name: Coverage
# uses: codecov/codecov-action@v3

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.python-version }}
path: .coverage.*
include-hidden-files: true
if-no-files-found: ignore

coverage:
name: Ensure 90% test coverage
runs-on: ubuntu-latest
needs: test
if: always()

steps:
- uses: actions/checkout@v4
with:
persist-credentials: true
- uses: actions/setup-python@v5
with:
python-version-file: .python-version
- uses: hynek/setup-cached-uv@v2

- name: Coverage
uses: codecov/codecov-action@v3
- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage and fail if it's below 90%
run: |
uv tool install 'coverage[toml]'

coverage combine
coverage html --skip-covered --skip-empty

# Report and write to summary
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY

# Report again and fail if under 90%
coverage report --fail-under=90

- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov

deploy:
# this will run when you have tagged a commit, starting with "v*"
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# For more information about tox, see https://tox.readthedocs.io/en/latest/
[tox]
envlist = py{39,310,311,312}-{linux,macos,windows}
envlist = py{39,310,311,312,313}-{linux,macos,windows}
isolated_build=true

[gh-actions]
Expand All @@ -17,6 +17,8 @@ PLATFORM =
windows-latest: windows

[testenv]
package = wheel
wheel_build_env = .pkg
platform =
macos: darwin
linux: linux
Expand Down