Skip to content

tests

tests #63

Workflow file for this run

name: tests
on:
push:
branches: [main]
pull_request: # Run in every PR
workflow_dispatch: # Allow manually triggering the workflow
schedule:
# Run roughly every 15 days at 00:00 UTC
# (useful to check if updates on dependencies break the package)
- cron: "0 0 1,16 * *"
concurrency:
group: >-
${{ github.workflow }}-${{ github.ref_type }}-
${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-latest
if: "!startsWith(github.event.head_commit.message, 'bump: version')"
outputs:
wheel-distribution: ${{ steps.wheel-distribution.outputs.path }}
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 0 } # deep clone for setuptools-scm
- uses: actions/setup-python@v4
with: { python-version: "3.11" }
- name: Run static analysis and format checkers
run: pipx run pre-commit run --all-files --show-diff-on-failure
- name: Build package distribution files
run: pipx run tox -e clean,build
- name: Record the path of wheel distribution
id: wheel-distribution
run: echo "::set-output name=path::$(ls dist/*.whl)"
- name: Store the distribution files for use in other stages
uses: actions/upload-artifact@v4
with:
name: python-distribution-files
path: dist/
retention-days: 1
test:
needs: prepare
if: "!startsWith(github.event.head_commit.message, 'bump: version')"
strategy:
matrix:
python:
- "3.10"
- "3.11"
- "3.12"
platform:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Retrieve pre-built distribution files
uses: actions/download-artifact@v4
with: { name: python-distribution-files, path: dist/ }
- name: Run tests
run: >-
pipx run tox
--installpkg '${{ needs.prepare.outputs.wheel-distribution }}'
-- -rFEx --durations 10 --color yes
- name: Generate coverage report
run: pipx run coverage lcov -o coverage.lcov
- name: Upload partial coverage report
uses: coverallsapp/github-action@master
with:
path-to-lcov: coverage.lcov
github-token: ${{ secrets.github_token }}
flag-name: ${{ matrix.platform }} - py${{ matrix.python }}
parallel: true