More GitHub workflow updates #70
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: Tests | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
jobs: | |
code-quality: | |
name: Code Quality | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Poetry | |
run: pipx install Poetry | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
cache: poetry | |
- name: Update PATH | |
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Install dependencies | |
run: poetry install | |
# Ruff | |
- name: Run linter | |
run: poetry run ruff check . --output-format github | |
- name: Run formatter | |
if: ${{ success() || failure() }} | |
run: poetry run ruff format --check . | |
# mypy for Linux | |
- name: Run mypy for Linux / 3.8 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.8 --platform linux | |
- name: Run mypy for Linux / 3.9 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.9 --platform linux | |
- name: Run mypy for Linux / 3.10 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.10 --platform linux | |
- name: Run mypy for Linux / 3.11 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.11 --platform linux | |
- name: Run mypy for Linux / 3.12 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.12 --platform linux | |
# mypy for macOS | |
- name: Run mypy for macOS / 3.8 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.8 --platform darwin | |
- name: Run mypy for macOS / 3.9 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.9 --platform darwin | |
- name: Run mypy for macOS / 3.10 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.10 --platform darwin | |
- name: Run mypy for macOS / 3.11 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.11 --platform darwin | |
- name: Run mypy for macOS / 3.12 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.12 --platform darwin | |
# mypy for Windows | |
- name: Run mypy for Windows / 3.8 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.8 --platform win32 | |
- name: Run mypy for Windows / 3.9 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.9 --platform win32 | |
- name: Run mypy for Windows / 3.10 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.10 --platform win32 | |
- name: Run mypy for Windows / 3.11 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.11 --platform win32 | |
- name: Run mypy for Windows / 3.12 | |
if: ${{ success() || failure() }} | |
run: poetry run mypy . --python-version 3.12 --platform win32 | |
tests: | |
strategy: | |
matrix: | |
os: ['Linux', 'macOS', 'Windows'] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
include: | |
- os: Linux | |
image: ubuntu-latest | |
- os: macOS | |
image: macos-latest | |
- os: Windows | |
image: windows-latest | |
name: ${{ matrix.os }} / ${{ matrix.python-version }} | |
runs-on: ${{ matrix.image }} | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Poetry | |
run: pipx install Poetry | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: poetry | |
- name: Update PATH | |
if: ${{ matrix.os != 'Windows' }} | |
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Update PATH (Windows) | |
if: ${{ matrix.os == 'Windows' }} | |
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH | |
- name: Install dependencies | |
run: poetry install | |
- name: Install pytest annotation plugin | |
run: poetry run pip install pytest-github-actions-annotate-failures | |
- name: Run tests with coverage | |
if: ${{ matrix.os != 'Linux' }} | |
run: poetry run pytest --cov | |
- name: Run tests with coverage (Linux) | |
if: ${{ matrix.os == 'Linux' }} | |
run: sudo -E env "PATH=$PATH" poetry run pytest --cov | |
- name: Upload coverage data to Coveralls | |
run: poetry run coveralls --service=github | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |