From e9b662ea13359bd744a1e958237c2a2b392441e8 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Wed, 21 Dec 2022 17:15:37 +0100 Subject: [PATCH] GitHub CI actions: Split tests and linters into two separate actions 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 --- .github/workflows/ci.yaml | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 16f829fe..f67fe5ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,8 +3,7 @@ name: CI on: [push, pull_request] jobs: - ci: - + tests: strategy: fail-fast: false matrix: @@ -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