Skip to content

tests

tests #554

Workflow file for this run

name: tests
on:
push:
branches:
- main
pull_request:
branches:
- '*'
workflow_dispatch:
schedule:
- cron: '0 13 * * SUN'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
pre_commit:
name: Run pre-commit hooks
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: "1"
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: pre-commit
uses: pre-commit/[email protected]
test_suite:
name: Test ${{ matrix.python-version }}, ${{ matrix.platform }}
needs: [pre_commit]
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: ['ubuntu-latest', 'windows-latest', 'macos-latest']
python-version: ${{ ( github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'push' && github.ref_type == 'tag' ) ) && fromJSON('["3.8", "3.9", "3.10", "3.11", "pypy3.9"]') || fromJSON('["3.8", "3.9", "3.11"]') }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
fetch-depth: "100"
- name: Fetch unshallow
run: git fetch --prune --tags --unshallow -f
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: env setup
run: |
python -m pip install --upgrade pip
python -m pip install hatch
- name: run unit tests
run: hatch -v run +py=${{ matrix.python-version }} tests:with_coverage
- name: run examples tests
# A notebook fails on Windows (UNIX path used in an example)
# No need to run these tests for PyPy really
if: contains(matrix.platform, 'ubuntu') && !startsWith(matrix.python-version, 'py')
run: hatch -v run +py=${{ matrix.python-version }} tests_examples:examples
- uses: codecov/codecov-action@v3
if: github.event_name == 'push'