Files
fastapi-cache/.github/workflows/ci.yml
Martijn Pieters 0e9a8baeb2 Add tox configuration
Tox manages test environments for all supported Python versions, as
well as linting and formatting tools. On GitHub, the test and lint
steps are kept as close as possible to the Makefile equivalents.
2023-05-16 10:49:17 +01:00

73 lines
1.8 KiB
YAML

name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
name: Linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Poetry
run: pipx install poetry
- name: Setup Python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: poetry
- name: Cache mypy cache
uses: actions/cache@v3
with:
path: .mypy_cache
key: ${{ runner.os }}-mypy-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-mypy-${{ steps.setup-python.outputs.python-version }}-
${{ runner.os }}-mypy-
- name: Install linting requirements
run: poetry install --no-root --with=linting --all-extras
- name: Execute linters
run: make lint
test:
needs:
- lint
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
fail-fast: false
name: "Test on Python ${{ matrix.python }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python }}"
cache: poetry
- name: Install testing requirements
run: |
poetry install --no-root --all-extras
poetry run pip install tox-gh-actions
- name: Execute tests
run: poetry run tox
test-summary:
name: Test matrix status
runs-on: ubuntu-latest
needs: [test]
if: always()
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}