forked from python-kasa/python-kasa
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (126 loc) Β· 4.49 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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:
python-version: ["3.12"]
steps:
- uses: "actions/checkout@v4"
- name: Install poetry
run: pipx install poetry
- uses: "actions/setup-python@v5"
id: setup-python
with:
python-version: "${{ matrix.python-version }}"
cache: 'poetry'
- name: "Install dependencies"
run: |
poetry install
- 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 }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: "Check supported device md files are up to date"
run: |
poetry run pre-commit run generate-supported --all-files
- name: "Linting and code formating (ruff)"
run: |
poetry run pre-commit run ruff --all-files
- 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
tests:
name: Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }}
needs: linting
runs-on: ${{ matrix.os }}
continue-on-error: ${{ startsWith(matrix.python-version, 'pypy') }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8", "pypy-3.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
extras: [false, true]
exclude:
- os: macos-latest
extras: true
- os: windows-latest
extras: true
- os: ubuntu-latest
python-version: "pypy-3.8"
extras: true
- os: ubuntu-latest
python-version: "pypy-3.10"
extras: true
- 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
steps:
- uses: "actions/checkout@v4"
- name: Install poetry
run: pipx install poetry
- uses: "actions/setup-python@v5"
id: setup-python
with:
python-version: "${{ matrix.python-version }}"
- name: Read poetry version
id: poetry-cache-location
run: >-
echo "$(poetry config --list)"
echo "POETRY_VENV_LOCATION=$(poetry config --list | grep virtualenvs.path | awk '{print $5}')" >> $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 }}
- name: "Install dependencies (no extras)"
if: matrix.extras == false
run: |
poetry install
- name: "Install dependencies (with extras)"
if: matrix.extras == true
run: |
poetry install --all-extras
- 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') }}
run: |
poetry run pytest --cov kasa --cov-report xml
- name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@v3"
with:
token: ${{ secrets.CODECOV_TOKEN }}