Move CI lint to separate state #81
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: 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: | ||
lint: | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
# Use only one version | ||
python-version: ["3.9"] | ||
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 }}-lint-{{ matrix.python-version }}-${{ hashFiles('./.requirements/lint.txt') }} | ||
- name: Upgrade Pip | ||
run: python -m pip install --upgrade pip | ||
- name: Install Dependencies | ||
run: pip install -IU ./.requirements/lint.txt | ||
- name: Check Formatting | ||
run: ruff format --check src/ tests/ | ||
- name: Check Ruff | ||
run: ruff check -q src/ tests/ | ||
- name: Check Mypy | ||
run: mypy src/ | ||
test: | ||
runs-on: ubuntu-24.04 | ||
needs: lint | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
# Run on all supported versions | ||
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | ||
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/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/test.txt | ||
- name: Run Tests | ||
run: coverage run -m pytest -v | ||
- name: Coverage Report | ||
run: coverage report | ||
publish: | ||
runs-on: ubuntu-24.04 | ||
needs: test | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- name: Set Up Python 3.13 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.13" | ||
- 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 }} |