2021-09-23 16:25:41 +00:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: ["master"]
|
|
|
|
pull_request:
|
|
|
|
branches: ["master"]
|
|
|
|
workflow_dispatch: # to allow manual re-runs
|
|
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
linting:
|
|
|
|
name: "Perform linting checks"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-10-29 23:22:30 +00:00
|
|
|
python-version: ["3.12"]
|
2021-09-23 16:25:41 +00:00
|
|
|
|
|
|
|
steps:
|
2024-03-06 15:23:31 +00:00
|
|
|
- uses: "actions/checkout@v4"
|
|
|
|
- name: Install poetry
|
|
|
|
run: pipx install poetry
|
|
|
|
- uses: "actions/setup-python@v5"
|
2024-03-15 15:42:40 +00:00
|
|
|
id: setup-python
|
2021-09-23 16:25:41 +00:00
|
|
|
with:
|
|
|
|
python-version: "${{ matrix.python-version }}"
|
2024-03-06 15:23:31 +00:00
|
|
|
cache: 'poetry'
|
2021-09-23 16:25:41 +00:00
|
|
|
- name: "Install dependencies"
|
|
|
|
run: |
|
2021-09-23 16:29:45 +00:00
|
|
|
poetry install
|
2024-03-15 15:42:40 +00:00
|
|
|
- name: Read pre-commit version
|
|
|
|
id: pre-commit-version
|
|
|
|
run: >-
|
|
|
|
echo "PRE_COMMIT_VERSION=$(poetry run pre-commit -V | awk '{print $2}')" >> $GITHUB_OUTPUT
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: ~/.cache/pre-commit/
|
|
|
|
key: ${{ runner.os }}-pre-commit-${{ steps.pre-commit-version.outputs.PRE_COMMIT_VERSION }}-python-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
|
2024-03-01 18:32:45 +00:00
|
|
|
- name: "Check supported device md files are up to date"
|
|
|
|
run: |
|
|
|
|
poetry run pre-commit run generate-supported --all-files
|
2023-10-29 22:15:42 +00:00
|
|
|
- name: "Linting and code formating (ruff)"
|
2022-02-20 23:56:18 +00:00
|
|
|
run: |
|
2023-10-29 22:15:42 +00:00
|
|
|
poetry run pre-commit run ruff --all-files
|
2021-09-23 16:25:41 +00:00
|
|
|
- name: "Typing checks (mypy)"
|
|
|
|
run: |
|
|
|
|
poetry run pre-commit run mypy --all-files
|
|
|
|
- name: "Run trailing-whitespace"
|
|
|
|
run: |
|
|
|
|
poetry run pre-commit run trailing-whitespace --all-files
|
|
|
|
- name: "Run end-of-file-fixer"
|
|
|
|
run: |
|
|
|
|
poetry run pre-commit run end-of-file-fixer --all-files
|
|
|
|
- name: "Run check-docstring-first"
|
|
|
|
run: |
|
|
|
|
poetry run pre-commit run check-docstring-first --all-files
|
|
|
|
- name: "Run debug-statements"
|
|
|
|
run: |
|
|
|
|
poetry run pre-commit run debug-statements --all-files
|
|
|
|
- name: "Run check-ast"
|
|
|
|
run: |
|
|
|
|
poetry run pre-commit run check-ast --all-files
|
2024-01-23 10:14:59 +00:00
|
|
|
|
2021-09-23 16:25:41 +00:00
|
|
|
|
|
|
|
tests:
|
2023-06-30 00:43:01 +00:00
|
|
|
name: Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }}
|
2021-09-23 16:25:41 +00:00
|
|
|
needs: linting
|
|
|
|
runs-on: ${{ matrix.os }}
|
2024-02-27 14:58:06 +00:00
|
|
|
continue-on-error: ${{ startsWith(matrix.python-version, 'pypy') }}
|
2021-09-23 16:25:41 +00:00
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-10-29 23:22:30 +00:00
|
|
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8", "pypy-3.10"]
|
2021-09-23 16:25:41 +00:00
|
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
2023-06-30 00:43:01 +00:00
|
|
|
extras: [false, true]
|
|
|
|
exclude:
|
|
|
|
- os: macos-latest
|
|
|
|
extras: true
|
|
|
|
- os: windows-latest
|
|
|
|
extras: true
|
|
|
|
- os: ubuntu-latest
|
|
|
|
python-version: "pypy-3.8"
|
|
|
|
extras: true
|
2023-10-29 23:22:30 +00:00
|
|
|
- os: ubuntu-latest
|
|
|
|
python-version: "pypy-3.10"
|
|
|
|
extras: true
|
2023-06-30 00:43:01 +00:00
|
|
|
- os: ubuntu-latest
|
|
|
|
python-version: "3.8"
|
|
|
|
extras: true
|
|
|
|
- os: ubuntu-latest
|
|
|
|
python-version: "3.9"
|
|
|
|
extras: true
|
|
|
|
- os: ubuntu-latest
|
|
|
|
python-version: "3.10"
|
|
|
|
extras: true
|
2021-09-23 16:25:41 +00:00
|
|
|
|
|
|
|
steps:
|
2024-03-06 15:23:31 +00:00
|
|
|
- uses: "actions/checkout@v4"
|
|
|
|
- name: Install poetry
|
|
|
|
run: pipx install poetry
|
|
|
|
- uses: "actions/setup-python@v5"
|
2024-03-15 15:42:40 +00:00
|
|
|
id: setup-python
|
2021-09-23 16:25:41 +00:00
|
|
|
with:
|
|
|
|
python-version: "${{ matrix.python-version }}"
|
2024-03-15 15:42:40 +00:00
|
|
|
- name: Read poetry cache location
|
|
|
|
id: poetry-cache-location
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "POETRY_VENV_LOCATION=$(poetry config virtualenvs.path)" >> $GITHUB_OUTPUT
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
${{ steps.poetry-cache-location.outputs.POETRY_VENV_LOCATION }}
|
|
|
|
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}-extras-${{ matrix.extras }}
|
2024-02-20 18:40:28 +00:00
|
|
|
- name: "Install dependencies (no extras)"
|
2023-06-30 00:43:01 +00:00
|
|
|
if: matrix.extras == false
|
2021-09-23 16:25:41 +00:00
|
|
|
run: |
|
2021-09-23 17:09:19 +00:00
|
|
|
poetry install
|
2024-02-20 18:40:28 +00:00
|
|
|
- name: "Install dependencies (with extras)"
|
2023-06-30 00:43:01 +00:00
|
|
|
if: matrix.extras == true
|
|
|
|
run: |
|
2024-02-20 18:40:28 +00:00
|
|
|
poetry install --all-extras
|
2024-03-06 15:23:31 +00:00
|
|
|
- name: "Run tests (no coverage)"
|
|
|
|
if: ${{ startsWith(matrix.python-version, 'pypy') }}
|
|
|
|
run: |
|
|
|
|
poetry run pytest
|
|
|
|
- name: "Run tests (with coverage)"
|
|
|
|
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
|
2021-09-23 16:25:41 +00:00
|
|
|
run: |
|
|
|
|
poetry run pytest --cov kasa --cov-report xml
|
|
|
|
- name: "Upload coverage to Codecov"
|
2023-10-29 23:22:30 +00:00
|
|
|
uses: "codecov/codecov-action@v3"
|
2021-09-23 16:25:41 +00:00
|
|
|
with:
|
2022-10-17 16:08:26 +00:00
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|