-
Notifications
You must be signed in to change notification settings - Fork 2
330 lines (299 loc) · 11.6 KB
/
python_checks.yml
File metadata and controls
330 lines (299 loc) · 11.6 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# Copyright (c) 2024 The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This workflow will install Python dependencies, run tests, lint and rat with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python Actions
on:
workflow_call:
inputs:
dependencies:
description: >
The list of SpiNNaker dependencies to check out. Space-separated
required: true
type: string
install-module:
description: >
Flag to say if the current model should be installed should be installed
Excepted values are true of false
required: false
type: string
default: 'true'
pip-installs:
description: >
Extra things to pip install when package not installed
Mainly used when install-module is false
required: false
type: string
default: ''
ubuntu-packages:
description: >
The names of the ubuntu packages to install
These are NOT installed on none linux workflows
required: false
type: string
default: ''
test-directories:
description: >
The list of directories to run pytest on. Space-seperated
required: true
type: string
coverage-package:
description: The names of the Python package to get coverage for
required: true
type: string
flake8-packages:
description: The names of the Python packages to run flake8 on.
required: true
type: string
check-prereleases:
description: Flag to say if prereleases python versions should be checked
required: false
type: string
default: 'true'
cfg-file:
description: >
Name of the cfg file to be created
excluding the ~./ start and .cfg end
The default string will skip the create cfg stage
A value of ~/.spynnaker.cfg will also trigger setup PyNN
required: false
type: string
default: ''
rcfile:
description: The name of the pylint rc file
required: false
type: string
default: global_strict
# global_relaxed and global_strict will use files in support scripts
# Any other value will be looked for in the calling repository
pylint-packages:
description: The names of the Python packages to run pylint on.
required: true
type: string
pylint-disable:
description: The pylint messages/categories to disable
required: false
type: string
default: "R"
pylint-exitcheck:
description: The combined results code to fail on
required: false
type: string
default: "31" # Action fails on any message
mypy-full-packages:
description: >
The names of the Python packages to run full mypy on.
These are run in --disallow-untyped-defs mode
required: false
type: string
default: ''
mypy-packages:
description: >
The names of Python packages to run simple mypy on.
These are run in without --disallow-untyped-defs
required: false
type: string
default: ''
rat-config-file:
description: >
Which xml config file to use for rat.
Supported options are:
'rat.xml' all license acceptable to rat
'rat_asl20.xml' Only the AppliedApacheSoftwareLicense20
'rat_gpl3.xml' Only the GNU General Public License version 3
required: false
type: string
default: "rat_asl20.xml"
run-sphinx:
description: Flag to say if sphinx should be run
required: false
type: string
default: true
sphinx-directory:
description: Where to run Sphinx
required: false
type: string
default: "doc/source"
run-cff-validator:
description: Flag to say if cff-validator should be run
required: false
type: string
default: true
env:
PRERELEASE: "3.15"
jobs:
validate:
# Everything as checks but do validation steps first
strategy:
matrix:
include:
- runner: ubuntu-latest
python-version: "3.12"
checks: 'validate'
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
steps:
- name: Prepare
uses: SpiNNakerManchester/SupportScripts/actions/prepare@main
with:
python-version: ${{ matrix.python-version }}
install-dependencies: ${{ inputs.dependencies }}
install-module: ${{ inputs.install-module }}
install-check-tools: true
ubuntu-packages: ${{ inputs.ubuntu-packages }}
cfg-file: ${{ inputs.cfg-file }}
pip-installs: ${{ inputs.pip-installs }}
- name: Run rat copyright enforcement
uses: SpiNNakerManchester/SupportScripts/actions/check-copyrights@main
with:
config-file: ${{ inputs.rat-config-file }}
- name: Build documentation with sphinx
if: ${{ inputs.run-sphinx == 'true' }}
uses: SpiNNakerManchester/SupportScripts/actions/sphinx@main
with:
directory: ${{ inputs.sphinx-directory }}
- name: Validate CITATION.cff
if: ${{ inputs.run-cff-validator == 'true' }}
uses: dieghernan/cff-validator@main
with:
install-r: true
- name: Lint with flake8
if: inputs.flake8-packages != ''
run: flake8 ${{ inputs.flake8-packages }}
- name: Lint with pylint
if: inputs.pylint-packages != ''
uses: SpiNNakerManchester/SupportScripts/actions/pylint@main
with:
package: ${{ inputs.pylint-packages }}
disable: ${{ inputs.pylint-disable }}
exitcheck: ${{ inputs.pylint-exitcheck }}
rcfile: ${{ inputs.rcfile }}
language: en_GB
- name: Lint with mypy
if: ${{ inputs.mypy-packages != ''}}
run: mypy --python-version ${{ matrix.python-version }} ${{ inputs.mypy-packages }}
- name: Lint with mypy using disallow-untyped-def
if: ${{ inputs.mypy-full-packages != ''}}
run: mypy --python-version ${{ matrix.python-version }} --disallow-untyped-defs ${{ inputs.mypy-full-packages }}
- name: Test with pytest
if: ${{ inputs.test-directories != ''}}
uses: SpiNNakerManchester/SupportScripts/actions/pytest@main
with:
tests: ${{ inputs.test-directories }}
coverage: ${{ matrix.coverage == 'coverage' && inputs.coverage-package != '' }}
cover-packages: ${{ inputs.coverage-package }}
coveralls-token: ${{ secrets.GITHUB_TOKEN }}
env:
SPALLOC_USER: ${{ secrets.SPALLOC_USER }}
SPALLOC_PASSWORD: ${{ secrets.SPALLOC_PASSWORD }}
# Tests using ping won't work in Github Actions because of system config
SKIP_PING_TESTS: true
checks:
# Everything as tests but do validation steps first
strategy:
matrix:
include:
# prereleases
- runner: ubuntu-latest
python-version: "3.14"
- runner: ubuntu-latest
python-version: "3.13"
- runner: ubuntu-24.04
python-version: "3.11"
- runner: ubuntu-latest
python-version: "3.10"
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
steps:
- name: Prepare
#if: ${{ matrix.python-version != '3.13' }}
#if: ${{ matrix.python-version != env.PRERELEASE || inputs.check-prereleases == 'true' }}
uses: SpiNNakerManchester/SupportScripts/actions/prepare@main
with:
python-version: ${{ matrix.python-version }}
install-dependencies: ${{ inputs.dependencies }}
install-module: ${{ inputs.install-module }}
install-check-tools: true
ubuntu-packages: ${{ inputs.ubuntu-packages }}
cfg-file: ${{ inputs.cfg-file }}
pip-installs: ${{ inputs.pip-installs }}
#- name: Prepare 3.13.5
# if: ${{ matrix.python-version == '3.13' }}
# uses: SpiNNakerManchester/SupportScripts/actions/prepare@main
# with:
# python-version: 3.13
# install-dependencies: ${{ inputs.dependencies }}
# install-module: ${{ inputs.install-module }}
# install-check-tools: true
# ubuntu-packages: ${{ inputs.ubuntu-packages }}
# cfg-file: ${{ inputs.cfg-file }}
# pip-installs: ${{ inputs.pip-installs }}
- name: Lint with mypy
if: ${{ (matrix.python-version != env.PRERELEASE || inputs.check-prereleases == 'true') && inputs.mypy-packages != '' }}
run: mypy --python-version ${{ matrix.python-version }} ${{ inputs.mypy-packages }}
- name: Lint with mypy using disallow-untyped-def
if: ${{ (matrix.python-version != env.PRERELEASE || inputs.check-prereleases == 'true') && inputs.mypy-full-packages != '' }}
run: mypy --python-version ${{ matrix.python-version }} --disallow-untyped-defs ${{ inputs.mypy-full-packages }}
- name: Lint with flake8
if: ${{ (matrix.python-version != env.PRERELEASE || inputs.check-prereleases == 'true') && inputs.flake8-packages != ''}}
run: flake8 ${{ inputs.flake8-packages }}
- name: Lint with pylint
if: ${{ (matrix.python-version != env.PRERELEASE || inputs.check-prereleases == 'true') && inputs.pylint-packages != ''}}
uses: SpiNNakerManchester/SupportScripts/actions/pylint@main
with:
package: ${{ inputs.pylint-packages }}
disable: ${{ inputs.pylint-disable }}
exitcheck: ${{ inputs.pylint-exitcheck }}
rcfile: ${{ inputs.rcfile }}
language: en_GB
- name: Test with pytest
if: ${{ (matrix.python-version != env.PRERELEASE || inputs.check-prereleases == 'true') && inputs.test-directories != ''}}
uses: SpiNNakerManchester/SupportScripts/actions/pytest@main
with:
tests: ${{ inputs.test-directories }}
env:
SPALLOC_USER: ${{ secrets.SPALLOC_USER }}
SPALLOC_PASSWORD: ${{ secrets.SPALLOC_PASSWORD }}
# Tests using ping won't work in Github Actions because of system config
SKIP_PING_TESTS: true
tests:
strategy:
matrix:
include:
- runner: windows-latest
checks: 'tests'
- runner: macos-latest
checks: 'tests'
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
steps:
- name: Prepare
uses: SpiNNakerManchester/SupportScripts/actions/prepare@main
with:
install-dependencies: ${{ inputs.dependencies }}
install-module: ${{ inputs.install-module }}
install-check-tools: false
# inputs.ubuntu-packages NOT installed!
cfg-file: ${{ inputs.cfg-file }}
pip-installs: ${{ inputs.pip-installs }}
- name: Pip cap
run: pip install pytest!=9.0.0 -U
- name: Test with pytest
if: ${{ inputs.test-directories != ''}}
env:
SPALLOC_USER: ${{ secrets.SPALLOC_USER }}
SPALLOC_PASSWORD: ${{ secrets.SPALLOC_PASSWORD }}
# Tests using ping won't work in Github Actions because of system config
SKIP_PING_TESTS: true
run: pytest ${{ inputs.test-directories }}