Skip to content

Commit

Permalink
Update github CI to use poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovsyanka committed Jan 2, 2024
1 parent 75918db commit fce6f8c
Showing 1 changed file with 60 additions and 8 deletions.
68 changes: 60 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,74 @@ jobs:
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:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
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
run: |
sudo apt update
sudo apt-get install -y libxml2-dev libxmlsec1-dev
python -m pip install --upgrade pip
pip install -r requirements.txt
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: |
python -m unittest tests.tests
poetry run python -m unittest tests.tests

0 comments on commit fce6f8c

Please sign in to comment.