-
Notifications
You must be signed in to change notification settings - Fork 68
132 lines (126 loc) · 4.68 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
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
concurrency:
# yamllint disable-line rule:line-length
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
ci:
name: ${{ matrix.name }} py ${{ matrix.python-version }} on ${{ matrix.os }} (${{ matrix.extension }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os:
- ubuntu-latest
- windows-latest
- macos-latest
extension:
- "skip_cython"
- "use_cython"
exclude:
- python-version: "3.9"
os: windows-latest
- python-version: "3.10"
os: windows-latest
- python-version: "3.11"
os: windows-latest
- python-version: "3.13"
os: windows-latest
- python-version: "3.9"
os: macos-latest
- python-version: "3.10"
os: macos-latest
- python-version: "3.11"
os: macos-latest
- python-version: "3.13"
os: macos-lates
- extension: "use_cython"
os: windows-latest
- extension: "use_cython"
os: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
id: python
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Get pip cache dir
id: pip-cache
shell: bash
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Restore PIP cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-${{ steps.python.outputs.python-version }}-${{ matrix.extension }}-${{ hashFiles('requirements.txt', 'requirements_test.txt') }}
restore-keys: |
pip-${{ steps.python.outputs.python-version }}-${{ matrix.extension }}-
- name: Set up Python environment (no cython)
if: ${{ matrix.extension == 'skip_cython' }}
env:
SKIP_CYTHON: 1
shell: bash
run: |
pip3 install -r requirements.txt -r requirements_test.txt
pip3 install -e .
- name: Set up Python environment (cython)
if: ${{ matrix.extension == 'use_cython' }}
env:
REQUIRE_CYTHON: 1
shell: bash
run: |
pip3 install -r requirements.txt -r requirements_test.txt
pip3 install -e .
- name: Register problem matchers
shell: bash
run: |
echo "::add-matcher::.github/workflows/matchers/flake8.json"
echo "::add-matcher::.github/workflows/matchers/pylint.json"
echo "::add-matcher::.github/workflows/matchers/mypy.json"
echo "::add-matcher::.github/workflows/matchers/pytest.json"
- run: flake8 aioesphomeapi
name: Lint with flake8
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}
- run: pylint aioesphomeapi
name: Lint with pylint
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}
- run: ruff check aioesphomeapi tests
name: Check formatting with ruff
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}
- run: mypy aioesphomeapi
name: Check typing with mypy
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}
- run: pytest -vv --cov=aioesphomeapi --cov-report=xml --tb=native tests
name: Run tests with pytest
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- run: |
docker run \
-v "$PWD":/aioesphomeapi \
-u "$(id -u):$(id -g)" \
ghcr.io/esphome/aioesphomeapi-proto-builder:latest
if ! git diff --quiet; then
echo "You have altered the generated proto files but they do not match what is expected."
echo "Please run the following to update the generated files:"
echo 'docker run -v "$PWD":/aioesphomeapi ghcr.io/esphome/aioesphomeapi-proto-builder:latest'
exit 1
fi
name: Check protobuf files match
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}