Skip to content

add pytest Workflow

add pytest Workflow #5

Workflow file for this run

name: Test Python package
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: 'pyproject.toml' # Read python version from a file pyproject.toml
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
**/pyproject.toml
**/requirements*.txt
- run: pip install -e . -r requirements-test.txt
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: >
${{ format('pre-commit-{0}-{1}',
steps.setup-python.outputs.python-version,
hashFiles('.pre-commit-config.yaml')
) }}
- name: Install pre-commit
run: |
pip install --upgrade pip
pip install pre-commit
pre-commit install
- name: Run pre-commit hooks
continue-on-error: true
run: >
git ls-files | xargs pre-commit run
--show-diff-on-failure
--color=always
--files
- name: Test with pytest
continue-on-error: true
run: |
pytest tests