-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
465 lines (444 loc) · 14.4 KB
/
.gitlab-ci.yml
File metadata and controls
465 lines (444 loc) · 14.4 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
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
stages:
- lint_and_test
- concepts
- examples
- coverage
- doc
- deploy_testpypi
- test_testpypi
- deploy_pypi
version_badge:
stage: lint_and_test
image: debian:12
script:
- apt update
- apt install -y python3 python3-pip python3-venv bc curl
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
- mkdir -p badges
- uv run anybadge --label=version --value=`uv version --short` --file=badges/version.svg
artifacts:
paths:
- badges/version.svg
test_ci_vars:
stage: lint_and_test
image: alpine
script:
- echo $CI_COMMIT_TAG
- echo $CI_COMMIT_BRANCH
- echo $IS_PRIVATE_GITLAB_INSTANCE
count_todos_in_code:
stage: lint_and_test
image: debian:12
variables:
GOAL: "60"
script:
- apt update
- apt install -y python3 python3-pip python3-venv bc curl
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
- make todo | tee todo.log
- TODOS=$(grep -oP 'TODOs=\K[\d]+' todo.log)
- |
if [ "$(echo "$TODOS > $GOAL" | bc)" -eq 1 ]; then
echo "ERROR: Number of TODOs $TODOS is over goal $GOAL"
exit 1
else
echo "SUCCESS: Number of TODOs $TODOS is equal or lower than goal $GOAL"
fi
coverage: /Count=([\d]+)/
artifacts:
when: always
paths:
- badges/todo.svg
lint_python:
stage: lint_and_test
image: debian:12
variables:
GOAL: "92"
script:
- apt update
- apt install -y python3 python3-pip python3-venv bc curl
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
- make lint | tee pylint.log
- RATING=$(grep -oP 'Your code has been rated at \K[\d.]+' pylint.log)
- PERCENTAGE=$(echo "$RATING * 10" | bc)
- printf "lint score is %.2f %%\n" "$PERCENTAGE"
- |
if [ "$(echo "$PERCENTAGE < $GOAL" | bc)" -eq 1 ]; then
echo "ERROR: Lint score $PERCENTAGE is below goal $GOAL"
exit 1
else
echo "SUCCESS: Lint score $PERCENTAGE equal or better than goal $GOAL"
fi
coverage: /lint score is ([\d]+\.[\d]+)/
test_all:
stage: lint_and_test
image: debian:12
script:
- apt update
- apt install -y python3 python3-pip python3-venv curl
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
- make test
- mv .coverage .coverage.pytest
artifacts:
when: always
paths:
- test/drom2psl/*.psl
- .coverage.pytest
- results.xml
reports:
junit:
- results.xml
run_concepts_questa: &run_concepts_questa
rules:
- if: $IS_PRIVATE_GITLAB_INSTANCE == "True"
stage: concepts
image: registry.woden.us.es/containers/questa:2025.1_2
variables:
TOOLCHAIN: "questa"
tags:
- fast
parallel:
matrix:
- DESIGN:
- adding_drom_sources
- assertion_decomposition
- assert_to_assume
- blackbox_example
- blackbox_instance
- counter_abstraction
- cutpoint_example
- defining_clocks_and_resets
- design_configurations
- design_configurations_reachability
- hooks
- inheriting_multiple_vunits
- inheriting_vunits
- multiple_designs
- parameterized_properties
- parameterized_sequences
- symbolic_constants
- user_defined_hdltypes
- user_defined_hdltypes_in_external_package
- user_defined_hdltypes_in_package
before_script:
- unset LM_LICENSE_FILE
- export SALT_LICENSE_SERVER=29000@popote.us.es
- yum install -y git python39 java-1.8.0-openjdk
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
script:
- make UVFLAGS=--dev PYTHON="coverage run --data-file=.coverage.$TOOLCHAIN.$DESIGN" $DESIGN
after_script:
- mv fvm_out/dashboard/$DESIGN/report fvm_out/dashboard/$DESIGN/report.$TOOLCHAIN.$DESIGN
artifacts:
when: always
paths:
- .coverage.$TOOLCHAIN.$DESIGN
- fvm_out/fvm_results/*.xml
- fvm_out/fvm_results/executor.json
- fvm_out/dashboard/$DESIGN/results/*.html
- fvm_out/dashboard/$DESIGN/results/*.json
- fvm_out/dashboard/$DESIGN/results/*.log
- fvm_out/dashboard/$DESIGN/report.$TOOLCHAIN.$DESIGN
reports:
junit:
- fvm_out/fvm_results/*.xml
.run_concepts_sby: &run_concepts_sby
<<: *run_concepts_questa
image: registry.gitlab.com/hgpub/fosshdl-dist
variables:
TOOLCHAIN: "sby"
before_script:
- DEBIAN_FRONTEND=noninteractive apt update && apt install -y python3 python3-pip python3-venv
- source /home/salas/fosshdl/env.rc
- export FVM_TOOLCHAIN=sby
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
run_test_examples_questa:
<<: *run_concepts_questa
stage: examples
parallel:
matrix:
- DESIGN:
- counter_psl_in_vhdl
- wishbone_sequence
run_examples_questa:
<<: *run_concepts_questa
stage: examples
parallel:
matrix:
- DESIGN:
- arbiter_prior
- arbiter_rr
- axi_lite_slave
- counter
- div32
- dualcounter
- fifo_async
- fifo_sync
- ipv6
- linearinterpolator
- sdram
- uart_tx
.run_examples_sby:
<<: *run_concepts_sby
stage: examples
parallel:
matrix:
- DESIGN:
- arbiter_prior
- arbiter_rr
- axi_lite_slave
- counter
- div32
- dualcounter
- fifo_async
- fifo_sync
- ipv6
- ipv6TX
- linearinterpolator
- sdram
- uart_tx
# Test that steps do not require any information from previous steps, so users
# can run them independently if needed.
run_steps_independently_questa:
rules:
- if: $IS_PRIVATE_GITLAB_INSTANCE == "True"
stage: examples
image: registry.woden.us.es/containers/questa:2025.1_2
tags:
- fast
variables:
TOOLCHAIN: "questa"
parallel:
matrix:
- DESIGN:
- counter
- arbiter_prior
STEP:
- lint
- friendliness
- rulecheck
- xverify
- reachability
- resets
- clocks
- prove
before_script:
- unset LM_LICENSE_FILE
- export SALT_LICENSE_SERVER=29000@popote.us.es
- yum install -y python39 java-1.8.0-openjdk git
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
script:
- uv run --dev coverage run --data-file=.coverage.$TOOLCHAIN.$DESIGN.$STEP -m examples.$DESIGN.formal -s $STEP
artifacts:
when: always
paths:
- .coverage.*
run_options_questa:
rules:
- if: $IS_PRIVATE_GITLAB_INSTANCE == "True"
stage: concepts
image: registry.woden.us.es/containers/questa:2025.1_2
tags:
- fast
variables:
TOOLCHAIN: "questa"
before_script:
- unset LM_LICENSE_FILE
- export SALT_LICENSE_SERVER=29000@popote.us.es
- yum install -y python39 java-1.8.0-openjdk
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
script:
- uv run --dev coverage run --data-file=.coverage.$TOOLCHAIN.hooks.verbose concepts/hooks/formal.py -v
- uv run --dev coverage run --data-file=.coverage.$TOOLCHAIN.hooks.list concepts/hooks/formal.py -l
- uv run --dev coverage run --data-file=.coverage.$TOOLCHAIN.design_configurations.list concepts/design_configurations/formal.py -l
- uv run --dev coverage run --data-file=.coverage.$TOOLCHAIN.hooks.outdir concepts/hooks/formal.py -o fvm_out_2
- uv run --dev coverage run --data-file=.coverage.$TOOLCHAIN.hooks.design concepts/hooks/formal.py -d counter
- uv run --dev coverage run --data-file=.coverage.$TOOLCHAIN.hooks.prove concepts/hooks/formal.py -s prove
- uv run --dev coverage run --data-file=.coverage.$TOOLCHAIN.hooks.prove_list concepts/hooks/formal.py -s prove -l
- uv run --dev coverage run --data-file=.coverage.$TOOLCHAIN.vunits.continue test/examples/inheriting_vunits_fail/formal.py -c
- make clean
artifacts:
when: always
paths:
- .coverage.$TOOLCHAIN.hooks.verbose
- .coverage.$TOOLCHAIN.hooks.list
- .coverage.$TOOLCHAIN.design_configurations.list
- .coverage.$TOOLCHAIN.hooks.outdir
- .coverage.$TOOLCHAIN.hooks.design
- .coverage.$TOOLCHAIN.hooks.prove
- .coverage.$TOOLCHAIN.hooks.prove_list
- .coverage.$TOOLCHAIN.vunits.continue
# Generate sphinx documentation
apidoc:
stage: doc
image: debian:12
variables:
GOAL: 98
script:
- apt update
- apt install -y python3 python3-pip python3-venv bc curl
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
- make docs 2>&1 | tee docs.log
- UNDOCUMENTED=$(grep -oP 'Total undocumented members= \K[\d]+' docs.log)
- |
if [ "$(echo "$UNDOCUMENTED > $GOAL" | bc)" -eq 1 ]; then
echo "ERROR: Number of undocumented $UNDOCUMENTED is over goal $GOAL"
exit 1
else
echo "SUCCESS: Number of undocumented $UNDOCUMENTED is equal or lower than goal $GOAL"
fi
artifacts:
when: always
paths:
- doc/sphinx/build/html
- badges/undocumented.svg
coverage: /Total undocumented members= ([\d]+)/
# Merge python coverage files from previous stages
pycoverage:
stage: coverage
image: debian:12
before_script:
- |
# When not running the examples and concepts, python coverage is lower
if [ "$IS_PRIVATE_GITLAB_INSTANCE" == "True" ]; then
export GOAL="92"
else
export GOAL="45"
fi
script:
- apt update
- apt install -y python3 python3-pip python3-venv bc curl
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
- make pycoverage | tee pycoverage.log
- LASTFIELD=$(grep 'TOTAL' pycoverage.log | awk '{print $NF}')
- PERCENTAGE=${LASTFIELD%\%}
- |
if [ "$(echo "$PERCENTAGE < $GOAL" | bc)" -eq 1 ]; then
echo "ERROR: Python coverage $PERCENTAGE is below goal $GOAL"
exit 1
else
echo "SUCCESS: Python coverage $PERCENTAGE equal or better than goal $GOAL"
fi
coverage: /TOTAL.*\s+(\d+\%)/
artifacts:
when: always
paths:
- htmlcov
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
# Deploy to testPyPI, but only if we have pushed a git tag, which should have
# only been pushed to the main branch (the bump_version.sh script enforces
# this), and we are in the private instance, which has the API tokens as CI/CD
# variables
#
# Sometimes testpypi seems to randomly fail, giving a not available error even
# if the upload was successful. If we stop there, since we only publish on
# tagged commits, this forces us to create a new, different tag. Instead, the
# check-url should allow us to re-run this job and not get errors if the files
# are already uploaded, or at least allow the pipeline to continue.
deploy_to_testpypi: &deploy_to_testpypi
variables:
PUBLISH_URL: "https://test.pypi.org/legacy/"
CHECK_URL: "https://test.pypi.org/simple/"
allow_failure: true
stage: deploy_testpypi
rules:
- if: $CI_COMMIT_TAG && $IS_PRIVATE_GITLAB_INSTANCE == "True"
image: debian:12
before_script:
- apt update
- apt install -y python3 python3-pip python3-venv curl
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
- uv build
script:
- uv publish --publish-url $PUBLISH_URL --check-url $CHECK_URL --token $TESTPYPI_API_TOKEN
# Get the recently published fvm from testpypi and try to run the tests
# Of couse we only do this if we have deployed to testpypi, but we can also run
# this on the public instance
# Here we don't want to use uv to run the tests, we only use uv to get the
# version number
# Then we install, using pip, the specific version from testpypi in a clean
# venv and run the tests with that version
# We remove the src/ folder in this job before running pytest to ensure we are
# finding the installed fvm (inside the testvenv)
# Tests may fail if the tests in the test/ folder do not match the installed
# version from testpypi (for example if the repo is 0.1.1 and we install
# 0.1.0), but as far as we know that shouldn't happen since we get the version
# from the repo using uv
# Let's test on multiple linux flavors that have python3.9 or later
test_from_testpypi:
stage: test_testpypi
rules:
- if: $CI_COMMIT_TAG
image: $DOCKERIMAGE
parallel:
matrix:
- DOCKERIMAGE:
- "debian:12"
- "debian:13"
- "ubuntu:22.04"
- "ubuntu:24.04"
- "alpine:3"
- "rockylinux:9"
- "fedora:41"
- "fedora:42"
script:
- |
# Check the value of the DOCKERIMAGE variable
case "$DOCKERIMAGE" in
# Match images containing 'alpine'
*alpine*)
echo "Setting up Alpine Linux (apk)"
apk update
apk add --no-cache python3 py3-pip curl
;;
# Match images containing 'debian' or 'ubuntu'
*debian* | *ubuntu*)
echo "Setting up Debian/Ubuntu Linux (apt)"
apt-get update
apt-get install -y python3 python3-pip python3-venv curl
;;
# Match images containing 'rocky', 'fedora', or 'centos'
*rocky* | *fedora* | *centos*)
echo "Setting up Rocky/Fedora/Centos/RHEL Linux ($PACKAGE_MANAGER)"
# No need to $PACKAGE_MANAGER update (that would update installed packages)
# Fedora and rocky, as alpine, provide python3-venv with python3.
# They also come with curl so we don't need to install it
dnf install -y python3 python3-pip
;;
*)
echo "Error: Unsupported Docker image base: $DOCKERIMAGE"
exit 1
;;
esac
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
- python3 -m venv testvenv
- source testvenv/bin/activate
- pip3 install --extra-index-url https://test.pypi.org/simple/ fvm-formal==`uv version --short`
- pip3 install pytest
- echo "[pytest]" > pytest.ini
- echo "pythonpath = ." >> pytest.ini
- rm -rf src/
- pytest -v
deploy_to_pypi:
<<: *deploy_to_testpypi
stage: deploy_pypi
variables:
PUBLISH_URL: "https://upload.pypi.org/legacy/"
CHECK_URL: "https://pypi.org/simple/"
script:
- uv publish --publish-url $PUBLISH_URL --check-url $CHECK_URL --token $PYPI_API_TOKEN