74 lines
2.0 KiB
YAML
74 lines
2.0 KiB
YAML
name: tests
|
|
|
|
on:
|
|
push:
|
|
pull_request_target:
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
POETRY_VERSION: "1.3.1"
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
|
|
|
env:
|
|
PYTHON_VERSION: ${{ matrix.python-version }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
# Poetry cache depends on OS, Python version and Poetry version.
|
|
- name: Cache Poetry cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cache/pypoetry
|
|
key: poetry-cache-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ env.POETRY_VERSION }}
|
|
|
|
# virtualenv cache should depends on OS, Python version and `poetry.lock` (and optionally workflow files).
|
|
- name: Cache Packages
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.local
|
|
key: poetry-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}
|
|
|
|
- name: Install and configure Poetry
|
|
uses: snok/install-poetry@v1.3.3
|
|
with:
|
|
version: ${{ env.POETRY_VERSION }}
|
|
virtualenvs-create: true
|
|
virtualenvs-in-project: true
|
|
|
|
- name: Add poetry to windows path
|
|
if: "startsWith(runner.os, 'windows')"
|
|
run: |
|
|
echo "C:\Users\runneradmin\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
poetry install
|
|
|
|
- name: Type checking
|
|
if: ${{ env.PYTHON_VERSION != '3.7' }}
|
|
run: |
|
|
poetry run mypy pyModeS
|
|
|
|
- name: Run tests
|
|
run: |
|
|
poetry run pytest tests --cov --cov-report term-missing
|
|
|
|
- name: Upload coverage to Codecov
|
|
if: ${{ github.event_name != 'pull_request_target' && env.PYTHON_VERSION == '3.10' }}
|
|
uses: codecov/codecov-action@v2
|
|
with:
|
|
env_vars: PYTHON_VERSION
|