Skip to content

Tests

Tests #51

Workflow file for this run

name: Tests
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
# 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:
name: ${{ matrix.os }}, ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
if: inputs.poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.7.1"
- name: Install dependencies with Poetry
if: inputs.poetry
run: |
poetry install --with test --all-extras
poetry add git+https://github.com/AstarVienna/ScopeSim_Data.git
- name: Install dependencies without Poetry
if: ${{ ! inputs.poetry }}
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
env:
PTRY: ${{ inputs.poetry && 'poetry run' || '' }}
run: $PTRY pytest -m "not webtest" --cov --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}