55 push :
66 pull_request : ~
77
8- env :
9- CACHE_VERSION : 1
10- DEFAULT_PYTHON : 3.8.16
11- PRE_COMMIT_HOME : ~/.cache/pre-commit
12-
138jobs :
14- # Separate job to pre-populate the base dependency cache
15- # This prevent upcoming jobs to do the same individually
16- prepare-base :
17- name : Prepare base dependencies
18- runs-on : ubuntu-latest
19- strategy :
20- matrix :
21- python-version : ['3.8.16', '3.9.15', '3.10.8', '3.11.0']
22- steps :
23- - name : Check out code from GitHub
24- uses : actions/checkout@v2
25- - name : Set up Python ${{ matrix.python-version }}
26- id : python
27- uses : actions/setup-python@v2.1.4
28- with :
29- python-version : ${{ matrix.python-version }}
30- - name : Restore base Python virtual environment
31- id : cache-venv
32- uses : actions/cache@v2
33- with :
34- path : venv
35- key : >-
36- ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
37- steps.python.outputs.python-version }}-${{
38- hashFiles('requirements_test.txt', 'setup.py') }}
39- restore-keys : |
40- ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-
41- - name : Create Python virtual environment
42- if : steps.cache-venv.outputs.cache-hit != 'true'
43- run : |
44- python -m venv venv
45- . venv/bin/activate
46- pip install -U pip setuptools pre-commit
47- pip install -r requirements_test.txt
48- pip install -e .
49-
50- pre-commit :
51- name : Prepare pre-commit environment
52- runs-on : ubuntu-latest
53- needs : prepare-base
54- steps :
55- - name : Check out code from GitHub
56- uses : actions/checkout@v2
57- - name : Set up Python ${{ env.DEFAULT_PYTHON }}
58- uses : actions/setup-python@v2.1.4
59- id : python
60- with :
61- python-version : ${{ env.DEFAULT_PYTHON }}
62- - name : Restore base Python virtual environment
63- id : cache-venv
64- uses : actions/cache@v2
65- with :
66- path : venv
67- key : >-
68- ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
69- steps.python.outputs.python-version }}-${{
70- hashFiles('requirements_test.txt', 'setup.py') }}
71- - name : Fail job if Python cache restore failed
72- if : steps.cache-venv.outputs.cache-hit != 'true'
73- run : |
74- echo "Failed to restore Python virtual environment from cache"
75- exit 1
76- - name : Restore pre-commit environment from cache
77- id : cache-precommit
78- uses : actions/cache@v2
79- with :
80- path : ${{ env.PRE_COMMIT_HOME }}
81- key : |
82- ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
83- restore-keys : |
84- ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-
85- - name : Install pre-commit dependencies
86- if : steps.cache-precommit.outputs.cache-hit != 'true'
87- run : |
88- . venv/bin/activate
89- pre-commit install-hooks
90-
91- lint-black :
92- name : Check black
93- runs-on : ubuntu-latest
94- needs : pre-commit
95- steps :
96- - name : Check out code from GitHub
97- uses : actions/checkout@v2
98- - name : Set up Python ${{ env.DEFAULT_PYTHON }}
99- uses : actions/setup-python@v2.1.4
100- id : python
101- with :
102- python-version : ${{ env.DEFAULT_PYTHON }}
103- - name : Restore base Python virtual environment
104- id : cache-venv
105- uses : actions/cache@v2
106- with :
107- path : venv
108- key : >-
109- ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
110- steps.python.outputs.python-version }}-${{
111- hashFiles('requirements_test.txt', 'setup.py') }}
112- - name : Fail job if Python cache restore failed
113- if : steps.cache-venv.outputs.cache-hit != 'true'
114- run : |
115- echo "Failed to restore Python virtual environment from cache"
116- exit 1
117- - name : Restore pre-commit environment from cache
118- id : cache-precommit
119- uses : actions/cache@v2
120- with :
121- path : ${{ env.PRE_COMMIT_HOME }}
122- key : |
123- ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
124- - name : Fail job if cache restore failed
125- if : steps.cache-venv.outputs.cache-hit != 'true'
126- run : |
127- echo "Failed to restore Python virtual environment from cache"
128- exit 1
129- - name : Run black
130- run : |
131- . venv/bin/activate
132- pre-commit run --hook-stage manual black --all-files --show-diff-on-failure
133-
134- lint-flake8 :
135- name : Check flake8
136- runs-on : ubuntu-latest
137- needs : pre-commit
138- steps :
139- - name : Check out code from GitHub
140- uses : actions/checkout@v2
141- - name : Set up Python ${{ env.DEFAULT_PYTHON }}
142- uses : actions/setup-python@v2.1.4
143- id : python
144- with :
145- python-version : ${{ env.DEFAULT_PYTHON }}
146- - name : Restore base Python virtual environment
147- id : cache-venv
148- uses : actions/cache@v2
149- with :
150- path : venv
151- key : >-
152- ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
153- steps.python.outputs.python-version }}-${{
154- hashFiles('requirements_test.txt', 'setup.py') }}
155- - name : Fail job if Python cache restore failed
156- if : steps.cache-venv.outputs.cache-hit != 'true'
157- run : |
158- echo "Failed to restore Python virtual environment from cache"
159- exit 1
160- - name : Restore pre-commit environment from cache
161- id : cache-precommit
162- uses : actions/cache@v2
163- with :
164- path : ${{ env.PRE_COMMIT_HOME }}
165- key : |
166- ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
167- - name : Fail job if cache restore failed
168- if : steps.cache-venv.outputs.cache-hit != 'true'
169- run : |
170- echo "Failed to restore Python virtual environment from cache"
171- exit 1
172- - name : Register flake8 problem matcher
173- run : |
174- echo "::add-matcher::.github/workflows/matchers/flake8.json"
175- - name : Run flake8
176- run : |
177- . venv/bin/activate
178- pre-commit run --hook-stage manual flake8 --all-files
179-
180- lint-isort :
181- name : Check isort
182- runs-on : ubuntu-latest
183- needs : pre-commit
184- steps :
185- - name : Check out code from GitHub
186- uses : actions/checkout@v2
187- - name : Set up Python ${{ env.DEFAULT_PYTHON }}
188- uses : actions/setup-python@v2.1.4
189- id : python
190- with :
191- python-version : ${{ env.DEFAULT_PYTHON }}
192- - name : Restore base Python virtual environment
193- id : cache-venv
194- uses : actions/cache@v2
195- with :
196- path : venv
197- key : >-
198- ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
199- steps.python.outputs.python-version }}-${{
200- hashFiles('requirements_test.txt', 'setup.py') }}
201- - name : Fail job if Python cache restore failed
202- if : steps.cache-venv.outputs.cache-hit != 'true'
203- run : |
204- echo "Failed to restore Python virtual environment from cache"
205- exit 1
206- - name : Restore pre-commit environment from cache
207- id : cache-precommit
208- uses : actions/cache@v2
209- with :
210- path : ${{ env.PRE_COMMIT_HOME }}
211- key : |
212- ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
213- - name : Fail job if cache restore failed
214- if : steps.cache-venv.outputs.cache-hit != 'true'
215- run : |
216- echo "Failed to restore Python virtual environment from cache"
217- exit 1
218- - name : Run isort
219- run : |
220- . venv/bin/activate
221- pre-commit run --hook-stage manual isort --all-files --show-diff-on-failure
222-
223- lint-codespell :
224- name : Check codespell
225- runs-on : ubuntu-latest
226- needs : pre-commit
227- steps :
228- - name : Check out code from GitHub
229- uses : actions/checkout@v2
230- - name : Set up Python ${{ env.DEFAULT_PYTHON }}
231- uses : actions/setup-python@v2.1.4
232- id : python
233- with :
234- python-version : ${{ env.DEFAULT_PYTHON }}
235- - name : Restore base Python virtual environment
236- id : cache-venv
237- uses : actions/cache@v2
238- with :
239- path : venv
240- key : >-
241- ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
242- steps.python.outputs.python-version }}-${{
243- hashFiles('requirements_test.txt', 'setup.py') }}
244- - name : Fail job if Python cache restore failed
245- if : steps.cache-venv.outputs.cache-hit != 'true'
246- run : |
247- echo "Failed to restore Python virtual environment from cache"
248- exit 1
249- - name : Restore pre-commit environment from cache
250- id : cache-precommit
251- uses : actions/cache@v2
252- with :
253- path : ${{ env.PRE_COMMIT_HOME }}
254- key : |
255- ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
256- - name : Fail job if cache restore failed
257- if : steps.cache-venv.outputs.cache-hit != 'true'
258- run : |
259- echo "Failed to restore Python virtual environment from cache"
260- exit 1
261- - name : Register codespell problem matcher
262- run : |
263- echo "::add-matcher::.github/workflows/matchers/codespell.json"
264- - name : Run codespell
265- run : |
266- . venv/bin/activate
267- pre-commit run --hook-stage manual codespell --all-files --show-diff-on-failure
268-
269- pytest :
270- runs-on : ubuntu-latest
271- needs : prepare-base
272- strategy :
273- matrix :
274- python-version : ['3.8.16', '3.9.15', '3.10.8', '3.11.0']
275- name : >-
276- Run tests Python ${{ matrix.python-version }}
277- steps :
278- - name : Check out code from GitHub
279- uses : actions/checkout@v2
280- - name : Set up Python ${{ matrix.python-version }}
281- uses : actions/setup-python@v2.1.4
282- id : python
283- with :
284- python-version : ${{ matrix.python-version }}
285- - name : Restore base Python virtual environment
286- id : cache-venv
287- uses : actions/cache@v2
288- with :
289- path : venv
290- key : >-
291- ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
292- steps.python.outputs.python-version }}-${{
293- hashFiles('requirements_test.txt', 'setup.py') }}
294- - name : Fail job if Python cache restore failed
295- if : steps.cache-venv.outputs.cache-hit != 'true'
296- run : |
297- echo "Failed to restore Python virtual environment from cache"
298- exit 1
299- - name : Register Python problem matcher
300- run : |
301- echo "::add-matcher::.github/workflows/matchers/python.json"
302- - name : Install Pytest Annotation plugin
303- run : |
304- . venv/bin/activate
305- # Ideally this should be part of our dependencies
306- # However this plugin is fairly new and doesn't run correctly
307- # on a non-GitHub environment.
308- pip install pytest-github-actions-annotate-failures
309- - name : Run pytest
310- run : |
311- . venv/bin/activate
312- pytest \
313- -qq \
314- --timeout=15 \
315- --durations=10 \
316- --cov zigpy_deconz \
317- --cov-report=term-missing \
318- -o console_output_style=count \
319- -p no:sugar \
320- tests
321- - name : Upload coverage artifact
322- uses : actions/upload-artifact@v2.2.0
323- with :
324- name : coverage-${{ matrix.python-version }}
325- path : .coverage
326- - name : Coveralls
327- env :
328- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
329- COVERALLS_FLAG_NAME : ${{ matrix.python-version }}
330- COVERALLS_PARALLEL : true
331- run : |
332- . venv/bin/activate
333- coveralls --service=github
334-
335-
336- coverage :
337- name : Process test coverage
338- runs-on : ubuntu-latest
339- needs : pytest
340- steps :
341- - name : Check out code from GitHub
342- uses : actions/checkout@v2
343- - name : Set up Python ${{ matrix.python-version }}
344- uses : actions/setup-python@v2.1.4
345- id : python
346- with :
347- python-version : ${{ env.DEFAULT_PYTHON }}
348- - name : Restore base Python virtual environment
349- id : cache-venv
350- uses : actions/cache@v2
351- with :
352- path : venv
353- key : >-
354- ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
355- steps.python.outputs.python-version }}-${{
356- hashFiles('requirements_test.txt', 'setup.py') }}
357- - name : Fail job if Python cache restore failed
358- if : steps.cache-venv.outputs.cache-hit != 'true'
359- run : |
360- echo "Failed to restore Python virtual environment from cache"
361- exit 1
362- - name : Download all coverage artifacts
363- uses : actions/download-artifact@v2
364- - name : Combine coverage results
365- run : |
366- . venv/bin/activate
367- coverage combine coverage*/.coverage*
368- coverage report --fail-under=97
369- coverage xml
370- - name : Upload coverage to Codecov
371- uses : codecov/codecov-action@v1
372- - name : Upload coverage to Coveralls
373- env :
374- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
375- run : |
376- . venv/bin/activate
377- coveralls --service=github --finish
9+ shared-ci :
10+ uses : zigpy/workflows/.github/workflows/ci.yml@main
11+ with :
12+ CODE_FOLDER : zigpy_deconz
13+ CACHE_VERSION : 2
14+ PYTHON_VERSION_DEFAULT : 3.8.14
15+ PRE_COMMIT_CACHE_PATH : ~/.cache/pre-commit
16+ MINIMUM_COVERAGE_PERCENTAGE : 97
0 commit comments