Skip to content

Update github CI to use poetry #301

Update github CI to use poetry

Update github CI to use poetry #301

Workflow file for this run

name: CI
on: [push, pull_request, workflow_dispatch]
jobs:
tests:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"]
# Current (1.7.1) version of poetry doesn't support python < 3.8, and poetry 1.1.13 is the last version with
# python 3.6 support, so use it for both python 3.6 and 3.7
include:
- poetry-version: 1.7.1
- python-version: 3.6
poetry-version: 1.1.13
- python-version: 3.7
poetry-version: 1.1.13
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local # the path depends on the OS
key: poetry-${{ matrix.poetry-version }}-${{ matrix.python-version }}
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: ${{ matrix.poetry-version }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Unset unsupported group directive from pyproject.toml for poetry 1.1.13
if: matrix.poetry-version == '1.1.13'
# removing the section and one string after it, that contains sphinx dependency, that isn't needed for these
# tests anyway
run: sed -i '/\[tool.poetry.group.docs.dependencies\]/,+1 d' pyproject.toml
# Checking pyproject.toml just in case
- name: Check pyproject.toml validity
run: poetry check --no-interaction
# The lock file format has changed since 1.1.3, so we just recreate it.
# Be aware that it will have different versions, than the repository lock file.
- name: Recreate lock file (for poetry 1.1.13)
if: matrix.poetry-version == '1.1.13'
# poetry.lock should be deleted before recreating it, or an error occurs
run: rm poetry.lock && poetry lock
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# --no-root because it makes no sense to install our package into cache.
run: poetry install --no-interaction --no-root
# If we would need our package installed - here is the way. But we don't.
# - name: Install project
# run: poetry install --no-interaction
- name: Run tests
run: |
poetry run python -m unittest tests.tests