[pre-commit.ci] pre-commit autoupdate #141
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit Tests | |
on: | |
pull_request: | |
push: | |
branches: ["main"] | |
permissions: {} | |
jobs: | |
build-and-pytest: | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11"] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: tlambert03/setup-qt-libs@v1 | |
- uses: actions/checkout@v3 | |
with: | |
# Fetch all history to get correct version numbers with versioningit | |
# Otherwise, `git describe` is not working | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install coverage pytest pytest-cases pytest-mock pytest-qt pytest-xvfb | |
- name: Install package | |
run: python -m pip install -e . | |
- name: Test with pytest | |
run: | | |
coverage run -m pytest --junit-xml=test-results.xml src/tests | |
coverage xml | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytest-results-${{ matrix.python-version }} | |
path: test-results.xml | |
if: always() | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.xml | |
env_vars: OS,PYTHON | |
publish-test-results: | |
name: "Publish test results" | |
needs: build-and-pytest | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
pull-requests: write | |
if: always() | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Publish test results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
with: | |
files: "artifacts/**/*.xml" |