Skip to content

Make use of Poetry parametrized #1

Make use of Poetry parametrized

Make use of Poetry parametrized #1

Workflow file for this run

name: Tests
on:
push:
branches:
- master
- main
- poetry
pull_request:
branches:
- master
- main
- poetry
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
poetry:
type: boolean
description: "Use Poetry-based workflow."
required: false
# Allow this workflow to be called from other repositories.
workflow_call:
inputs:
poetry:
type: boolean
description: "Use Poetry-based workflow."
required: false
jobs:
run-tests:
# The web tests are run with a limited matrix, because they retrieve data
# from the internet and therefor run into rate limits with the full matrix.
name: ubuntu-latest, ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
if: ${{ inputs.poetry || github.event_name == 'push' || github.event_name == 'pull_request' }}
uses: abatilo/actions-poetry@v3
with:
poetry-version: "1.8.3"
- name: Install dependencies with Poetry
if: ${{ inputs.poetry || github.event_name == 'push' || github.event_name == 'pull_request' }}
run: |
poetry install --with test --all-extras
poetry add git+https://github.com/AstarVienna/ScopeSim_Data.git
- name: Run Pytest with Poetry
if: ${{ inputs.poetry || github.event_name == 'push' || github.event_name == 'pull_request' }}
run: poetry run pytest -m "webtest" --cov --cov-report=xml
- name: Install dependencies without Poetry
if: ${{ ! inputs.poetry && github.event_name != 'push' && github.event_name != 'pull_request' }}
run: |
python -m pip install --upgrade pip
pip install git+https://github.com/AstarVienna/ScopeSim_Data.git
# Install this clone of the project. This is relevant because for
# example ScopeSim has ScopeSim_Templates as a test-dependency
# and that package has ScopeSim as a dependency. So the PyPI version
# of ScopeSim would be installed without the "pip install ." line.
pip install .
# TODO: It should not be necessary to install the dev dependencies.
# Perhaps create a separate test for that?
pip install .[test,dev]
pip install pytest pytest-cov
- name: Run Pytest without Poetry
if: ${{ ! inputs.poetry && github.event_name != 'push' && github.event_name != 'pull_request' }}
run: pytest -m "webtest" --cov --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}