-
Notifications
You must be signed in to change notification settings - Fork 2
383 lines (299 loc) · 13.3 KB
/
action.yaml
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches:
- main
schedule:
- cron: '00 6 1 * *'
release:
types:
- published
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install -U pylint
- name: Run Main code Lint
run: pylint --rcfile tests/pylint.rc src/peakrdl_python
- name: Install dependencies for unit tests
run: |
python -m pip install .[unit_test] -U
- name: Run unit tests Lint
run: pylint --rcfile tests/pylint.rc src/peakrdl_python tests/unit_tests
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install -U mypy
- name: Type Check
run: mypy src/peakrdl_python --config-file=tests/.mypy.ini
unit_tests:
needs:
- mypy
- lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# the unit tests need the development version of installer as tomllib may be needed
# for older versions of python
python -m pip install .[unit_test]
- name: Run Unit Tests
run: |
python -m unittest discover -s tests/unit_tests -t .
dev_runner:
needs:
- mypy
- lint
- unit_tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[dev]
# the generate_and_test script is intended to run directly from source rather than from
# the installed package
python -m pip uninstall peakrdl-python -y
# peakrdl-ipxact is needed for some of the test cases so is imported by the
# generate_and_test script
# retrieve the example code from the systemRDL compiler
wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl
- name: Test Development Runner
run: |
python -m generate_and_test --RDL_source_file tests/testcases/simulator_test.rdl --root_node simulator_test
python -m generate_and_test --RDL_source_file tests/testcases/simulator_test.rdl --root_node simulator_test --async
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include int_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include int_property_to_include str_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include int_property_to_include str_property_to_include struct_property_to_include double_layer_struct_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/reserved_elements.rdl --root_node reserved_elements --hide_regex "(?:[\w_\[\]]+\.)+RSVD"
peakrdl_integration:
needs:
- mypy
- lint
- unit_tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[peakrdl]
- name: Run PeakRDL Case
run: |
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/raw/
peakrdl python tests/testcases/hidden_property.rdl -o peakrdl_out/raw/
peakrdl python tests/testcases/hidden_property.rdl -o peakrdl_out/raw/show_hidden/ --show_hidden
peakrdl python tests/testcases/simple.xml tests/testcases/multifile.rdl -o peakrdl_out/raw
peakrdl python tests/testcases/extended_memories.rdl -o peakrdl_out/raw/
peakrdl python tests/testcases/user_defined_properties.rdl -o peakrdl_out/raw/ --udp bool_property_to_include
peakrdl python tests/testcases/reserved_elements.rdl -o peakrdl_out/raw/ --hide_regex "(?:[\w_\[\]]+\.)+RSVD"
python -m unittest discover -s peakrdl_out/raw
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/raw_async/ --async
peakrdl python tests/testcases/hidden_property.rdl -o peakrdl_out/raw_async/ --async
peakrdl python tests/testcases/hidden_property.rdl -o peakrdl_out/raw_async/show_hidden/ --show_hidden --async
python -m unittest discover -s peakrdl_out/raw_async
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/raw_legacy/ --legacy_block_access
python -m unittest discover -s peakrdl_out/raw_legacy
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/no_test/ --skip_test_case_generation
# test a TOMl file that passes in overridden templates
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/simple_user_template/ --peakrdl-cfg tests/alternative_templates_toml/peakrdl.toml
python tests/alternative_templates_toml/header_check.py --generated_package_location peakrdl_out/simple_user_template/ --top_name basic
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/dynamic_user_template/ --peakrdl-cfg tests/alternative_templates_dynamic_toml/peakrdl.toml
python tests/alternative_templates_dynamic_toml/header_check.py --generated_package_location peakrdl_out/dynamic_user_template/ --top_name basic
- name: Check Examples
run: |
# build the libraries for the two cases
cd example/tranversing_address_map/
peakrdl python chip_with_registers.rdl -o .
python -m reseting_registers
python -m dumping_register_state_to_json_file
python -m writing_register_state_from_json_file
cd ../..
cd example/simulating_callbacks
peakrdl python chip_with_a_GPIO.rdl -o .
# this example creates a gui that stays up for ever so needs changing before it can be
# in the test suite
# python -m flashing_the_LED
cd ../..
cd example/optimised_access/
peakrdl python optimised_access.rdl -o .
python -m demo_optimised_access
cd ../..
cd example/array_access/
peakrdl python array_access.rdl -o .
python -m demo_array_access
cd ../..
cd example/enumerated_fields/
peakrdl python enumerated_fields.rdl -o .
python -m demo_enumerated_fields
cd ../..
cd example/why_ral/
peakrdl python gpio.rdl -o .
python -m without_ral
python -m with_ral
python -m with_hal
cd ../..
integration_tests:
needs:
- mypy
- lint
- unit_tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
# retrieve the example code from the systemRDL compiler
wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl
- name: Generate testcases
run: |
# one of the test cases uses IPxact so we need the importer
python -m pip install peakrdl-ipxact
# the generated code is type checked with mypy so this is needed
python -m pip install mypy
python generate_testcases.py
mypy testcase_output --config-file=tests/.mypy.ini
# pylint --rcfile tests/pylint.rc testcase_output/autopep8 --disable=duplicate-code,line-too-long,too-many-statements,invalid-name,unused-import,too-many-instance-attributes,too-many-arguments,too-many-lines
python -m unittest discover -s testcase_output
autoformating:
needs:
- integration_tests
runs-on: ubuntu-latest
strategy:
matrix:
# reduced matrix because the autoformatter was having issues with python 3.8 so we will
# limit this to modern versions of python only
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install mypy
# one of the test cases uses IPxact so we need the importer
python -m pip install peakrdl-ipxact
# black is the autoformatter used for this this testing
python -m pip install black
# retrieve the example code from the systemRDL compiler
wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl
- name: Generate testcases
run: |
# black will ignore files in the .gitingore by default, so we need to ensure that the
# content is generated with a different name
python generate_testcases.py --output autoformatted_output --test_case accelera-generic_example.rdl
# no need to check them as they are tested in the previous test
- name: Test Autoformating
run: |
# run the autoformatting
black autoformatted_output --line-length 120
# check the files are correct with mypy and unittesting
mypy autoformatted_output --config-file=tests/.mypy.ini
python -m unittest discover -s autoformatted_output
#-------------------------------------------------------------------------------
build:
needs:
- integration_tests
- autoformating
- dev_runner
- peakrdl_integration
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install -U build
- name: Build
run: python -m build
- uses: actions/upload-artifact@v4
with:
path: |
dist/*.tar.gz
dist/*.whl
#-------------------------------------------------------------------------------
deploy:
needs:
- build
runs-on: ubuntu-latest
# Only publish when a GitHub Release is created.
if: github.event_name == 'release'
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}