-
Notifications
You must be signed in to change notification settings - Fork 0
546 lines (481 loc) · 17.5 KB
/
ci_cd.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
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
name: CI
on:
pull_request:
workflow_dispatch:
push:
tags:
- "v*.*.*"
branches:
- main
env:
MAIN_PYTHON_VERSION: '3.10'
DOCUMENTATION_CNAME: 'actions.scade.docs.pyansys.com'
test-library-name: 'ansys-scade-actions'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
labeler:
name: "Label syncer"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: micnncim/action-label-syncer@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Label based on changed files
uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions-ecosystem/action-add-labels@v1
if: |
startsWith(github.event.pull_request.head.ref, 'doc') ||
startsWith(github.event.pull_request.head.ref, 'docs')
with:
labels: documentation
- uses: actions-ecosystem/action-add-labels@v1
if: |
startsWith(github.event.pull_request.head.ref, 'maint') ||
startsWith(github.event.pull_request.head.ref, 'no-ci') ||
startsWith(github.event.pull_request.head.ref, 'ci')
with:
labels: maintenance
- uses: actions-ecosystem/action-add-labels@v1
if: startsWith(github.event.pull_request.head.ref, 'feat')
with:
labels: |
enhancement
- uses: actions-ecosystem/action-add-labels@v1
if: |
startsWith(github.event.pull_request.head.ref, 'fix') ||
startsWith(github.event.pull_request.head.ref, 'patch')
with:
labels: bug
- name: Suggest to add labels
uses: peter-evans/create-or-update-comment@v4
if: toJSON(github.event.pull_request.labels.*.name) == '{}'
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Please add one of the following labels to add this contribution to the Release Notes :point_down:
- [bug](https://github.com/ansys/scade-actions/pulls?q=label%3Abug+)
- [documentation](https://github.com/ansys/scade-actions/pulls?q=label%3Adocumentation+)
- [enhancement](https://github.com/ansys/scade-actions/pulls?q=label%3Aenhancement+)
- [good first issue](https://github.com/ansys/scade-actions/pulls?q=label%3Agood+first+issue)
- [maintenance](https://github.com/ansys/scade-actions/pulls?q=label%3Amaintenance+)
- [release](https://github.com/ansys/scade-actions/pulls?q=label%3Arelease+)
commit-and-branch-style:
name: "Commit and branch style"
runs-on: ubuntu-latest
needs: labeler
steps:
- name: "Check commit style"
uses: ansys/actions/commit-style@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: "Check branch naming convention"
uses: ansys/actions/branch-name-style@v7
code-style:
name: "Code style"
runs-on: ubuntu-latest
needs: commit-and-branch-style
steps:
- name: "Run code style checks"
uses: ansys/actions/code-style@v7
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
use-python-cache: false
- name: "Verify private actions are not pointing to the 'main' branch"
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
run: |
if $(grep -q --exclude-dir={.git,.github,doc} "ansys\/actions\/.*\@main" -r .); then
echo -e "\033[1;91m[ERROR]: Found private actions pointing to the 'main' branch.\033[0m"
grep -q --exclude-dir={.git,.github,doc} "ansys\/actions\/.*\@main" -r .
fi
doc-style:
name: "Doc style"
runs-on: ubuntu-latest
needs: commit-and-branch-style
steps:
- name: "Run documentation style checks"
uses: ansys/actions/doc-style@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
doc-build:
name: "Doc build"
runs-on: ubuntu-latest
needs: doc-style
steps:
- name: "Build documentation"
uses: ansys/actions/doc-build@v7
with:
skip-install: true
python-version: ${{ env.MAIN_PYTHON_VERSION }}
use-python-cache: false
dependencies: "texlive-fonts-extra qpdf"
python-tests:
# tests for python actions
name: "Python Tests"
runs-on: [self-hosted, 'SCADE']
strategy:
matrix:
scade-version: ['23.2']
fail-fast: false
steps:
- name: "Execute setup.py tests"
uses: ./scade-tests-pytest
with:
scade-version: ${{ matrix.scade-version }}
library-dir: "tests/python-setup"
pytest-postargs: "tests/python-setup/tests -vv"
checkout: false
- name: "Execute pyproject tests"
uses: ./scade-tests-pytest
with:
scade-version: ${{ matrix.scade-version }}
library-dir: "tests/python-pyproject"
pytest-postargs: "tests/python-pyproject/tests -vv"
checkout: false
unit-tests:
# tests for Python code included in actions
# cannot reuse ./scade-tests-pytest: the tested scripts are not part of a Python package
name: "Run Python unit tests"
runs-on: [self-hosted, 'SCADE']
strategy:
matrix:
scade-version: ['23.2']
fail-fast: false
steps:
- name: "Install Git and clone project"
uses: actions/checkout@v4
- name: "Get SCADE installation directory"
uses: ./get-scade-dir
id: get-scade-dir
with:
scade-version: ${{ matrix.scade-version }}
- name: "Get SCADE Python interpreter"
uses: ./get-scade-python
id: get-scade-python
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
- name: "Create Python virtual environment"
uses: ./create-scade-venv
id: create-scade-venv
with:
python-dir: ${{ steps.get-scade-python.outputs.python-dir }}
target-dir: '.venvs'
target-name: ${{ steps.get-scade-python.outputs.python-name }}
- name: "Check python"
shell: cmd
run: |
:: Check python
echo Activate the virtual environment
call ${{ steps.create-scade-venv.outputs.scripts-dir }}\activate.bat"
python.exe --version
:: store the "exe for the next steps"
echo PYTHON_EXE=${{ steps.create-scade-venv.outputs.scripts-dir }}\python.exe>> %GITHUB_ENV%
- name: "Update pip"
shell: cmd
run: |
%PYTHON_EXE% -m pip install -U pip
- name: "Install test requirements"
shell: cmd
run: |
echo Installing test dependencies from requirements_tests.txt
%PYTHON_EXE% -m pip install -r requirements/requirements_tests.txt
- name: "Executing test suite"
shell: cmd
run: |
:: Run tests
%PYTHON_EXE% -m pytest --ignore=tests/python-pyproject --ignore=tests/python-setup --basetemp=tmp --cov-report=term --cov-branch --cov-report=html:.cov/html --cov-report=xml:.cov/xml
# - name: "Upload coverage reports to Codecov"
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# slug: ansys/scade-actions
# files: .cov/xml
suite-tests:
# tests for SCADE Suite actions
name: "Suite Tests"
runs-on: [self-hosted, 'SCADE']
strategy:
matrix:
scade-version: ['23.2']
fail-fast: false
steps:
- name: "Check out the repository"
uses: actions/checkout@v4
- name: "Get SCADE installation directory"
uses: ./get-scade-dir
id: get-scade-dir
with:
scade-version: ${{ matrix.scade-version }}
- name: "Generate with suite-code"
uses: ./suite-code
id: suite-code-generate
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/suite-code/Model/Model.etp"
configuration: "Suite Code"
build: "false"
checkout: false
- name: "Upload code target directory to artifacts"
uses: actions/upload-artifact@v4
with:
name: "scade-suite-code-target-directory"
path: "${{ steps.suite-code-generate.outputs.target-directory }}/*.*"
retention-days: 7
if-no-files-found: error
- name: "Build with suite-code"
uses: ./suite-code
id: suite-code-build
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/suite-code/Model/Model.etp"
configuration: "Simulation"
build: "true"
checkout: false
- name: "Log the target directories"
shell: cmd
run: |
echo Generation target directory: ${{ steps.suite-code-generate.outputs.target-directory }}
echo Build target directory: ${{ steps.suite-code-build.outputs.target-directory }}
- name: "Acquire the model coverage with test-coverage"
uses: ./test-coverage
id: test-coverage
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
test-project: "tests/test-coverage/Test/Test.etp"
results-project: "tests/test-coverage/Results/Results.etp"
configuration: "Test"
cov-status: "cov_status/Model.json"
checkout: false
- name: "Upload coverage status to artifacts"
uses: actions/upload-artifact@v4
with:
name: "coverage-status"
path: "cov_status\\Model.json"
retention-days: 7
if-no-files-found: error
- name: "Run the tests with test-execute"
uses: ./test-execute
id: test-execute
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
test-project: "tests/test-execute/Test/Test.etp"
results-project: "tests/test-execute/Results/Results.etp"
configuration: "Test Success"
junit-report: "junit-reports/Model.xml"
checkout: false
- name: "Upload JUnit report to artifacts"
uses: actions/upload-artifact@v4
with:
name: "junit-report"
path: "junit-reports\\Model.xml"
retention-days: 7
if-no-files-found: error
- name: "Compute metrics with suite-metrics"
uses: ./suite-metrics
id: suite-metrics
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/suite-metrics/Model/Model.etp"
configuration: "MetricRule"
checkout: false
- name: "Upload metrics report artifacts"
uses: actions/upload-artifact@v4
with:
name: "metrics"
path: "${{ steps.suite-metrics.outputs.report }}"
retention-days: 7
if-no-files-found: error
- name: "Check custom rules with suite-rules"
uses: ./suite-rules
id: suite-rules
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/suite-rules/Model/Model.etp"
configuration: "RuleSuccess"
checkout: false
- name: "Upload Custom rules report artifacts"
uses: actions/upload-artifact@v4
with:
name: "check-custom-rules"
path: "${{ steps.suite-rules.outputs.report }}"
retention-days: 7
if-no-files-found: error
- name: "Check with suite-check"
uses: ./suite-check
id: suite-check
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/suite-check/Model/Model.etp"
configuration: "KCG Expall"
checkout: false
- name: "Upload Checker report artifacts"
uses: actions/upload-artifact@v4
with:
name: "scade-suite-check-report"
path: "${{ steps.suite-check.outputs.report }}"
retention-days: 7
if-no-files-found: error
- name: "Generate the documentation with suite-report"
uses: ./suite-report
id: suite-report
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/suite-report/Model/Model.etp"
configuration: "RTF"
checkout: false
- name: "Upload the document to artifacts"
uses: actions/upload-artifact@v4
with:
name: "scade-suite-report"
path: "${{ steps.suite-report.outputs.report }}"
retention-days: 7
if-no-files-found: error
display-tests:
# tests for SCADE Display actions
name: "Display Tests"
runs-on: [self-hosted, 'SCADE']
strategy:
matrix:
scade-version: ['24.2']
fail-fast: false
steps:
- name: "Check out the repository"
uses: actions/checkout@v4
- name: "Get SCADE installation directory"
uses: ./get-scade-dir
id: get-scade-dir
with:
scade-version: ${{ matrix.scade-version }}
- name: "Generate the documentation with display-report"
uses: ./display-report
id: display-report
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/display-report/Model/Model.etp"
configuration: "RTF"
checkout: false
- name: "Upload the document to artifacts"
uses: actions/upload-artifact@v4
with:
name: "scade-display-report"
path: "${{ steps.display-report.outputs.report }}"
retention-days: 7
if-no-files-found: error
- name: "Generate code with display-generate"
uses: ./display-generate
id: display-generate-code
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/display-generate/Model/Model.etp"
configuration: "Code"
checkout: false
- name: "Upload code target directory to artifacts"
uses: actions/upload-artifact@v4
with:
name: "scade-display-code-target-directory"
path: "${{ steps.display-generate-code.outputs.target-directory }}/*.*"
retention-days: 7
if-no-files-found: error
- name: "Generate standalone with display-generate"
uses: ./display-generate
id: display-generate-standalone
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/display-generate/Model/Model.etp"
configuration: "Windows"
checkout: false
- name: "Upload standalone target directory to artifacts"
uses: actions/upload-artifact@v4
with:
name: "scade-display-standalone-target-directory"
path: "${{ steps.display-generate-standalone.outputs.target-directory }}/*.*"
retention-days: 7
if-no-files-found: error
- name: "Check with display-check"
uses: ./display-check
id: display-check
with:
scade-dir: ${{ steps.get-scade-dir.outputs.scade-directory }}
project: "tests/display-check/Model/Model.etp"
specification: "specification.sgfx"
format: 'TXT'
output: 'design-checker-report-specification.txt'
checkout: false
- name: "Upload Checker report artifacts"
uses: actions/upload-artifact@v4
with:
name: "scade-display-check-report"
path: 'design-checker-report-specification.txt'
retention-days: 7
if-no-files-found: error
tests:
name: "All Tests"
needs: [display-tests, python-tests, unit-tests, suite-tests]
runs-on: ubuntu-latest
steps:
- name: "Synchronization"
run: |
echo Tests completed
doc-deploy-dev:
name: "Deploy developers documentation"
needs: [doc-build, tests]
runs-on: ubuntu-latest
if: github.event_name == 'push' && !contains(github.ref, 'refs/tags')
steps:
- uses: ansys/actions/doc-deploy-dev@v7
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
release:
name: "Release to GitHub"
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [doc-build, tests]
steps:
- name: "Download HTML documentation"
uses: actions/download-artifact@v4
with:
name: documentation-html
path: documentation-html
- name: "Zip HTML documentation"
uses: vimtor/[email protected]
with:
files: documentation-html
dest: documentation-html.zip
- name: "Download PDF documentation"
uses: actions/download-artifact@v4
with:
name: documentation-pdf
path: documentation-pdf
- name: "Zip PDF documentation"
uses: vimtor/[email protected]
with:
files: documentation-pdf
dest: documentation-pdf.zip
- name: "Display the structure of downloaded files"
shell: bash
run: ls -R
- name: "Release to GitHub"
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
documentation-html.zip
documentation-pdf.zip
doc-deploy-stable:
name: "Upload stable documentation"
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: release
steps:
- uses: ansys/actions/doc-deploy-stable@v7
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}