Skip to content

0.5.0

0.5.0 #59

Workflow file for this run

name: Run Tests
env:
PIP_CACHE_DIR: .pip
PYTHONPATH: src
on:
push:
paths:
- ".github/workflows/py-tests.yml"
- ".requirements/*.txt"
- "examples/**"
- "src/**"
- "tests/**"
- "pyproject.toml"
branches:
- master
pull_request:
branches:
- master
release:
types: ["published"]
jobs:
test:
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
# Run on all supported versions
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Set Up Python {{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Cache dependencies
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ./.pip
key: ${{ runner.os }}-tests-{{ matrix.python-version }}-${{ hashFiles('./.requirements/lint.txt') }}-${{ hashFiles('./.requirements/test.txt') }}
- name: Upgrade Pip
run: python -m pip install --upgrade pip
- name: Upgrade Build
run: pip install --upgrade build
- name: Install Dependencies
run: pip install -IU -r ./.requirements/deps.txt -r ./.requirements/lint.txt -r ./.requirements/test.txt
- name: Check Formatting
run: black --check src/ tests/
- name: Check Ruff
run: ruff -q src/ tests/
- name: Check Mypy
run: mypy src/
- name: Run Tests
run: coverage run -m pytest -v
- name: Coverage Report
run: coverage report
publish:
runs-on: ubuntu-20.04
needs: test
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Set Up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Upgrade Pip
run: python -m pip install --upgrade pip
- name: Upgrade Build
run: pip install --upgrade build
- name: Build Package
run: python -m build --sdist --wheel
# - name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}