pyModeS/.github/workflows/run-tests.yml

71 lines
1.8 KiB
YAML
Raw Normal View History

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:
- uses: actions/checkout@v4
2022-04-18 23:59:30 +08:00
- name: Set up Python
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
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') }}
- 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.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
uses: codecov/codecov-action@v4
2022-04-18 23:59:30 +08:00
with:
env_vars: PYTHON_VERSION