fix(#10): handle optional path dependencies #97
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Tests" | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: {} | |
jobs: | |
Lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- name: Install poetry | |
run: pipx install poetry | |
- name: Linting | |
run: make lint | |
Tests: | |
name: ${{ matrix.os }} / py${{ matrix.python-version }} / poetry${{ matrix.poetry-version }} | |
runs-on: ${{ matrix.image }} | |
strategy: | |
matrix: | |
os: [Ubuntu, macOS, Windows] | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | |
poetry-version: ["==1.7.0", "==1.7.1", "==1.8.0", "==1.8.1", "==1.8.2", "==1.8.3", "==1.8.4", "==1.8.5", "==2.0.0", "==2.0.1", ""] | |
exclude: | |
- python-version: "3.8" | |
poetry-version: "==2.0.0" | |
- python-version: "3.8" | |
poetry-version: "==2.0.1" | |
- python-version: "3.8" | |
poetry-version: "" | |
include: | |
- os: Ubuntu | |
image: ubuntu-latest | |
- os: Windows | |
image: windows-latest | |
- os: macOS | |
image: macos-latest | |
fail-fast: false | |
defaults: | |
run: | |
shell: bash | |
needs: Lint | |
env: | |
OS: ${{ matrix.os }} | |
PYTHON: ${{ matrix.python-version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- name: Get full Python version | |
id: full-python-version | |
run: echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT | |
- name: Install poetry | |
shell: bash | |
run: | | |
pipx install poetry${{ matrix.poetry-version }} | |
pipx ensurepath | |
# as the poetry version specification will modify the lock, need to calculate the hash once, to be able to correctly cache the result | |
- name: Get repo lock hash | |
id: repo-lock-hash | |
run: | | |
echo "hash=$(git hash-object poetry.lock)" >> $GITHUB_OUTPUT | |
- name: Set up cache | |
uses: actions/cache/restore@v4 | |
id: cache | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ matrix.poetry-version }}-${{ steps.repo-lock-hash.outputs.hash }} | |
- name: Ensure cache is healthy | |
if: steps.cache.outputs.cache-hit == 'true' | |
run: timeout 10s poetry run pip --version || rm -rf .venv | |
- name: Latest pip | |
run: | | |
python -m pip install --upgrade pip | |
- name: Specify python version (poetry>=2.0) (non-macOS) | |
# As poetry>=2.0 is incompatible with python==3.8 (which we want to allow to allow poetry<2.0), we also pin the python version | |
if: (startsWith(matrix.poetry-version, '==2') || matrix.poetry-version == '') && runner.os != 'macOS' | |
run: | | |
sed -i "s/^python = \".*\"/python = \"~${{ matrix.python-version }}.0\"/" pyproject.toml | |
- name: Specify python version (poetry>=2.0) (macOs) | |
# need different sed command because it is zsh | |
if: (startsWith(matrix.poetry-version, '==2') || matrix.poetry-version == '') && runner.os == 'macOS' | |
run: | | |
sed -i '' "s/^python = \".*\"/python = \"~${{ matrix.python-version }}.0\"/" pyproject.toml | |
- name: Specify poetry version (windows) | |
# Pinning to a specific poetry version, such that we can verify test suite with that specific version | |
# because $(which python) returns / paths, while poetry wants \ paths | |
if: runner.os == 'Windows' | |
run: | | |
poetry config virtualenvs.prefer-active-python true || echo "probably on Poetry>=2.0.0" | |
echo "Python version = $(python --version)" | |
echo "Poetry's Python version = $(poetry run python --version)" | |
echo "Poetry version = $(poetry --version)" | |
poetry remove poetry poetry-core | |
poetry add poetry${{ matrix.poetry-version }} | |
echo "Poetry's Python version = $(poetry run python --version)" | |
echo "Poetry version within poetry venv = $(poetry run poetry --version)" | |
- name: Specify poetry version (non-windows) | |
if: runner.os != 'Windows' | |
run: | | |
poetry env use $(which python) | |
echo "Python version = $(python --version)" | |
echo "Poetry's Python version = $(poetry run python --version)" | |
echo "Poetry version = $(poetry --version)" | |
poetry remove poetry poetry-core | |
poetry add poetry${{ matrix.poetry-version }} | |
echo "Poetry's Python version = $(poetry run python --version)" | |
echo "Poetry version within poetry venv = $(poetry run poetry --version)" | |
# because our poetry update modifies the cache | |
- name: Update cache | |
id: cache-save | |
uses: actions/cache/save@v4 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ matrix.poetry-version }}-${{ steps.repo-lock-hash.outputs.hash }} | |
- name: Install dependencies | |
run: | | |
poetry install --sync --with github-actions | |
touch .venv/.touchfile | |
- name: Coverage for pytest | |
run: make test | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4.3.0 | |
with: | |
env_vars: OS,PYTHON | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
flags: unittests | |
files: ./coverage/coverage.xml | |
slug: gerbenoostra/poetry-plugin-mono-repo-deps |