Skip to content

Add pull request validation workflow #1

Add pull request validation workflow

Add pull request validation workflow #1

name: Run pull request validation
on:
pull_request:
branches:
- main
jobs:
run-checks:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python-version: "3.10"
- python-version: "3.11"
- python-version: "3.12"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
python -m pip install poetry==1.8.2
- name: Configure poetry
run: |
python -m poetry config virtualenvs.in-project true
- name: Cache the virtualenv
id: poetry-dependencies-cache
uses: actions/cache@v3
with:
path: ./.venv
key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dev dependencies
if: steps.poetry-dependencies-cache.outputs.cache-hit != 'true'
run: |
python -m poetry install --only=development,linting
- name: Check for formatting issues
run: python -m poetry run black --check --diff .
- name: Check for linting issues
run: python -m poetry run ruff check .
- name: Run static type analysis
run: python -m poetry run mypy .
- name: Test with tox
run: |
source .venv/bin/activate
coverage erase
tox run-parallel -f py${{ matrix.python-version }} --parallel-no-spinner --parallel-live
coverage combine
coverage xml
- uses: codecov/codecov-action@v3
with:
# Explicitly using the token to avoid Codecov rate limit errors
# See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true # optional (default = false)