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:
|
2023-12-19 16:59:35 +08:00
|
|
|
POETRY_VERSION: "1.6.1"
|
2022-12-28 06:58:28 +08:00
|
|
|
|
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]
|
2024-03-04 00:22:16 +08:00
|
|
|
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
2022-04-18 23:59:30 +08:00
|
|
|
|
|
|
|
env:
|
|
|
|
PYTHON_VERSION: ${{ matrix.python-version }}
|
|
|
|
|
|
|
|
steps:
|
2023-10-02 00:36:54 +08:00
|
|
|
- uses: actions/checkout@v4
|
2022-04-18 23:59:30 +08:00
|
|
|
|
|
|
|
- name: Set up Python
|
2024-01-01 23:29:45 +08:00
|
|
|
uses: actions/setup-python@v5
|
2022-04-18 23:59:30 +08:00
|
|
|
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
|
2024-02-02 03:04:17 +08:00
|
|
|
uses: actions/cache@v4
|
2022-12-30 21:10:22 +08:00
|
|
|
if: ${{ !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
|
2024-08-25 18:22:23 +08:00
|
|
|
uses: snok/install-poetry@v1.4.0
|
2022-12-28 06:58:28 +08:00
|
|
|
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
|
2024-02-02 03:03:43 +08:00
|
|
|
uses: codecov/codecov-action@v4
|
2022-04-18 23:59:30 +08:00
|
|
|
with:
|
|
|
|
env_vars: PYTHON_VERSION
|