From 56d9a84703800b8a9653c8443bdfc6242894c434 Mon Sep 17 00:00:00 2001 From: TimMonko <47310455+TimMonko@users.noreply.github.com> Date: Wed, 5 Mar 2025 22:28:55 -0600 Subject: [PATCH 1/4] tox-uv and cov --- .github/workflows/test_and_deploy.yml | 57 +++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 3c4f138..b43df92 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -34,6 +34,8 @@ jobs: with: python-version: ${{ matrix.python-version }} + - uses: hynek/setup-cached-uv@v2 + # these libraries enable testing on Qt on linux - uses: tlambert03/setup-qt-libs@v1 @@ -57,12 +59,61 @@ jobs: - name: Test with tox uses: aganders3/headless-gui@v2 with: - run: python -m tox + run: > + uvx --with tox-uv tox run env: PLATFORM: ${{ matrix.platform }} - - name: Coverage - uses: codecov/codecov-action@v3 + # - 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-default + - uses: hynek/setup-cached-uv@v2 + + - 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*" From a265c231af0d9f3068bb986ceb89986cf8f0d366 Mon Sep 17 00:00:00 2001 From: TimMonko <47310455+TimMonko@users.noreply.github.com> Date: Wed, 5 Mar 2025 22:41:08 -0600 Subject: [PATCH 2/4] switch to hynek ci --- .github/workflows/test_and_deploy.yml | 42 ++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index b43df92..8e150cd 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -16,7 +16,25 @@ 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 }} @@ -24,16 +42,24 @@ jobs: 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 @@ -61,8 +87,8 @@ jobs: with: run: > uvx --with tox-uv tox run - env: - PLATFORM: ${{ matrix.platform }} + --installpkg dist/*.whl + -f py${PYTHON//./}-tests # - name: Coverage # uses: codecov/codecov-action@v3 From 035ea4bf81bda2998002495ef3b8d507ae3559b2 Mon Sep 17 00:00:00 2001 From: TimMonko <47310455+TimMonko@users.noreply.github.com> Date: Wed, 5 Mar 2025 23:27:41 -0600 Subject: [PATCH 3/4] add wheel build to tox --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 51b38c3..bcf29ba 100644 --- a/tox.ini +++ b/tox.ini @@ -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] @@ -17,6 +17,8 @@ PLATFORM = windows-latest: windows [testenv] +package = wheel +wheel_build_env = .pkg platform = macos: darwin linux: linux From 48e0d2a69a746a4d7f0ed5e7c8d4abbc7fb44689 Mon Sep 17 00:00:00 2001 From: TimMonko <47310455+TimMonko@users.noreply.github.com> Date: Wed, 5 Mar 2025 23:29:48 -0600 Subject: [PATCH 4/4] python version default --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 8e150cd..bbeb956 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -113,7 +113,7 @@ jobs: persist-credentials: true - uses: actions/setup-python@v5 with: - python-version-file: .python-version-default + python-version-file: .python-version - uses: hynek/setup-cached-uv@v2 - name: Download coverage data