2022-04-18 23:59:30 +08:00
|
|
|
name: tests
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
pull_request_target:
|
|
|
|
workflow_dispatch:
|
|
|
|
|
2022-12-28 06:58:28 +08:00
|
|
|
env:
|
|
|
|
POETRY_VERSION: "1.3.1"
|
|
|
|
|
2022-04-18 23:59:30 +08:00
|
|
|
jobs:
|
|
|
|
deploy:
|
2022-04-19 00:50:38 +08:00
|
|
|
runs-on: ${{ matrix.os }}
|
2022-04-18 23:59:30 +08:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-04-19 00:50:38 +08:00
|
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
2022-12-28 06:58:28 +08:00
|
|
|
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
2022-04-18 23:59:30 +08:00
|
|
|
|
|
|
|
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 }}
|
|
|
|
|
2022-12-28 06:58:28 +08:00
|
|
|
# virtualenv cache should depends on OS, Python version and `poetry.lock` (and optionally workflow files).
|
|
|
|
- name: Cache Packages
|
|
|
|
uses: actions/cache@v3
|
2022-12-30 21:08:44 +08:00
|
|
|
if: ${{ not startsWith(runner.os, 'windows') }}
|
2022-12-28 06:58:28 +08:00
|
|
|
with:
|
2022-12-30 07:59:30 +08:00
|
|
|
path: |
|
|
|
|
~/.local
|
|
|
|
.venv
|
2022-12-28 06:58:28 +08:00
|
|
|
key: poetry-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}
|
|
|
|
|
2022-12-28 07:11:52 +08:00
|
|
|
- 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
|
|
|
|
|
2022-12-28 06:58:28 +08:00
|
|
|
- name: Install and configure Poetry
|
|
|
|
uses: snok/install-poetry@v1.3.3
|
|
|
|
with:
|
|
|
|
version: ${{ env.POETRY_VERSION }}
|
|
|
|
virtualenvs-create: true
|
|
|
|
virtualenvs-in-project: true
|
|
|
|
|
2022-12-30 07:59:30 +08:00
|
|
|
- name: Display Python version
|
|
|
|
run: poetry run python -c "import sys; print(sys.version)"
|
|
|
|
|
2022-12-28 06:58:28 +08:00
|
|
|
- name: Install dependencies
|
2022-04-18 23:59:30 +08:00
|
|
|
run: |
|
2022-12-28 06:58:28 +08:00
|
|
|
poetry install
|
2022-04-18 23:59:30 +08:00
|
|
|
|
2022-12-28 06:58:28 +08:00
|
|
|
- name: Type checking
|
2022-04-18 23:59:30 +08:00
|
|
|
run: |
|
2022-12-28 06:58:28 +08:00
|
|
|
poetry run mypy pyModeS
|
2022-04-18 23:59:30 +08:00
|
|
|
|
2022-12-28 06:58:28 +08:00
|
|
|
- name: Run tests
|
2022-04-18 23:59:30 +08:00
|
|
|
run: |
|
2022-12-28 06:58:28 +08:00
|
|
|
poetry run pytest tests --cov --cov-report term-missing
|
2022-04-18 23:59:30 +08:00
|
|
|
|
|
|
|
- name: Upload coverage to Codecov
|
2022-12-30 07:59:30 +08:00
|
|
|
if: ${{ github.event_name != 'pull_request_target' }}
|
2022-12-30 21:02:05 +08:00
|
|
|
uses: codecov/codecov-action@v3
|
2022-04-18 23:59:30 +08:00
|
|
|
with:
|
|
|
|
env_vars: PYTHON_VERSION
|