Skip to content

Commit

Permalink
GitHub CI actions: Split tests and linters into two separate actions
Browse files Browse the repository at this point in the history
We want to run our test suite across all supported Python versions, but
we don't really need/want to run our linters on more than one Python
version. Split the CI definition into:

  - a "tests" job that runs the test suite on Python versions 3.7, 3.8,
    3.9, 3.10, and 3.11, inside virtualenvs where only the test
    dependencies are available.

  - a "linter" job that runs on Python 3.10 only, inside a virtualenv
    where all dev dependencies are available.

This should hopefully make CI a little bit faster:
  - we run the linters _once_, not for every Python version
  - we run linters in parallel with tests instead of strictly afterwards
  - we run the tests in a smaller virtualenv
  • Loading branch information
jherland committed Jan 3, 2023
1 parent 9cd75b9 commit e9b662e
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: CI
on: [push, pull_request]

jobs:
ci:

tests:
strategy:
fail-fast: false
matrix:
Expand All @@ -22,11 +21,33 @@ jobs:
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
key: ${{ runner.os }}-poetry-tests-${{ hashFiles('poetry.lock') }}
- name: Install project
run: poetry install --no-interaction --sync --with=test,dev
run: poetry install --no-interaction --sync --with=test
- name: Run tests
run: poetry run pytest

linters:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: Gr1N/setup-poetry@v7
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-linters-${{ hashFiles('poetry.lock') }}
- name: Install project
run: poetry install --no-interaction --sync --with=test,dev
- name: Run type checker
run: poetry run mypy
- name: Check formatting with Black
Expand Down

0 comments on commit e9b662e

Please sign in to comment.