diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 3c4f138..bbeb956 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,15 +42,25 @@ 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 - uses: tlambert03/setup-qt-libs@v1 @@ -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*" 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