-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinteg-test-promote-template.yml
479 lines (461 loc) · 20.6 KB
/
integ-test-promote-template.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
jobs:
- ${{ each version in parameters.TASK_VERSION }}:
- job: test_install_v${{ version }}
strategy:
matrix:
microsoft_hosted_linux:
poolName: Azure Pipelines
vmImage: ubuntu-22.04
microsoft_hosted_macos:
poolName: Azure Pipelines
vmImage: macOS-latest
microsoft_hosted_windows:
poolName: Azure Pipelines
vmImage: windows-latest
pool:
name: $(poolName)
vmImage: $(vmImage)
steps:
- checkout: none
- task: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
displayName: Install MATLAB
- bash: |
set -e
os=$(uname)
if [[ $os = CYGWIN* || $os = MINGW* || $os = MSYS* ]]; then
mex.bat -h
else
mex -h
fi
displayName: Check mex
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Check matlab installation
inputs:
command: version
- job: test_install_release_v${{ version }}
strategy:
matrix:
microsoft_hosted_linux:
poolName: Azure Pipelines
vmImage: ubuntu-22.04
microsoft_hosted_macos:
poolName: Azure Pipelines
vmImage: macOS-latest
microsoft_hosted_windows:
poolName: Azure Pipelines
vmImage: windows-latest
pool:
name: $(poolName)
vmImage: $(vmImage)
steps:
- checkout: none
- task: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
displayName: Install MATLAB
inputs:
release: R2023a
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Check matlab release
inputs:
command: assert(strcmp(version('-release'),'2023a'))
- job: test_install_latest_including_prerelease_v${{ version }}
condition: not(eq(${{ version }}, '0'))
strategy:
matrix:
microsoft_hosted_linux:
poolName: Azure Pipelines
vmImage: ubuntu-22.04
pool:
name: $(poolName)
vmImage: $(vmImage)
steps:
- checkout: none
- task: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
displayName: Install MATLAB
inputs:
release: latest-including-prerelease
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Print MATLAB version
inputs:
command: version
- job: test_run_command_v${{ version }}
strategy:
matrix:
microsoft_hosted_linux:
poolName: Azure Pipelines
vmImage: ubuntu-22.04
microsoft_hosted_macos:
poolName: Azure Pipelines
vmImage: macOS-latest
microsoft_hosted_windows:
poolName: Azure Pipelines
vmImage: windows-latest
pool:
name: $(poolName)
vmImage: $(vmImage)
steps:
- checkout: none
- task: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
displayName: Install MATLAB on Microsoft-hosted agents
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB statement
inputs:
command: f = fopen('myscript.m', 'w'); fwrite(f, 'assert(true)'); fclose(f);
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB script
inputs:
command: myscript
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB statement with quotes 1
inputs:
command: 'eval("a = 1+2"); assert(a == 3); eval(''b = 3+4''); assert(b == 7);'
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB statement with quotes 2
inputs:
command: "eval(\"a = 1+2\"); assert(a == 3); eval('b = 3+4'); assert(b == 7);"
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB statement with quotes 3
inputs:
command: a = """hello world"""; b = '"hello world"'; assert(strcmp(a,b));
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB statement with symbols
inputs:
command: a = " !""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; b = char([32:126]); assert(strcmp(a, b), a+b);
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB statement in working directory
inputs:
command: exp = getenv('SYSTEM_DEFAULTWORKINGDIRECTORY'); act = pwd; assert(strcmp(act, exp), strjoin({act exp}, '\n'));
- bash: |
echo 'myvar = 123' > startup.m
displayName: Create startup.m
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: MATLAB runs startup.m automatically
inputs:
command: assert(myvar==123, 'myvar was not set as expected by startup.m')
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB statement with startup options
inputs:
command: disp("Hello world!")
startupOptions: -logfile mylog.log
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB statement with startup options
inputs:
command: assert(isfile("mylog.log"), 'mylog.log was not created as expected')
- bash: |
mkdir subdir
echo 'onetyone = 11' > subdir/startup.m
displayName: Create subdir/startup.m
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run MATLAB statement with subdir/startup
inputs:
command: >
assert(onetyone==11, 'onetyone was not set as expected by subdir/startup.m');
[~, folder] = fileparts(pwd());
assert(strcmp(folder, 'subdir'));
startupOptions: -sd subdir
- job: test_run_tests_v${{ version }}
strategy:
matrix:
microsoft_hosted_linux:
poolName: Azure Pipelines
vmImage: ubuntu-22.04
pool:
name: $(poolName)
vmImage: $(vmImage)
workspace:
clean: all
steps:
- checkout: none
- task: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
displayName: Install MATLAB on Microsoft-hosted agents
condition: eq(${{ version }}, '0')
- task: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
inputs:
products: Simulink Simulink_Test Simulink_Coverage Parallel_Computing_Toolbox
displayName: Install MATLAB on Microsoft-hosted agents
condition: eq(${{ version }}, '1')
- bash: |
echo 'myvar = 123' > startup.m
mkdir src
echo 'function c=add(a,b);c=a+b;' > src/add.m
mkdir tests
echo "%% StartupTest" > tests/mytest.m
echo "evalin('base','assert(myvar==123)')" >> tests/mytest.m
echo "%% FirstTest" >> tests/mytest.m
echo "assert(add(1,2)==3)" >> tests/mytest.m
mkdir tests/filteredTest
echo "%% simpleTest" >> tests/filteredTest/filtertest.m
echo "assert(2==2)" >> tests/filteredTest/filtertest.m
echo "%% FilterByTag" >> tests/filteredTest/TaggedTest.m
cat << EOF > tests/filteredTest/TaggedTest.m
classdef (TestTags = {'FILTERED'}) TaggedTest < matlab.unittest.TestCase
methods(Test)
function testTag(testCase)
assert(2==2);
end
end
end
EOF
displayName: Make MATLAB tests
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
displayName: Run MATLAB tests with defaults
inputs:
sourceFolder: src
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
displayName: Run MATLAB tests producing artifacts
inputs:
testResultsJUnit: test-results/matlab/results.xml
codeCoverageCobertura: code-coverage/coverage.xml
sourceFolder: src
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
displayName: Run MATLAB tests filter by folder
inputs:
testResultsJUnit: test-results/matlab/selectbyfolder.xml
selectByFolder: tests/filteredTest
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
displayName: Run MATLAB tests filter by folder
inputs:
testResultsJUnit: test-results/matlab/selectbytag.xml
selectByTag: FILTERED
- bash: |
set -e
grep -q FirstTest test-results/matlab/results.xml
displayName: Verify test results file was created
- bash: |
set -e
grep -q add code-coverage/coverage.xml
displayName: Verify code coverage file was created
- bash: |
set -e
grep -q simpleTest test-results/matlab/selectbyfolder.xml
grep -v FirstTest test-results/matlab/selectbyfolder.xml
displayName: Verify test filtered by folder
- bash: |
set -e
grep -q TaggedTest test-results/matlab/selectbytag.xml
grep -v FirstTest test-results/matlab/selectbytag.xml
grep -v simpleTest test-results/matlab/selectbytag.xml
displayName: Verify test filtered by tag name
- bash: |
echo 'diary console.log' >> startup.m
displayName: Set up diary for logging
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
displayName: Run MATLAB tests with strict checks
inputs:
strict: true
sourceFolder: src
- bash: |
set -e
grep -q "runner.addPlugin(FailOnWarningsPlugin())" console.log
rm console.log
displayName: Verify tests ran with strict checks
# Disable parallel tests until PCT bug is fixed g3416906
# - task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
# displayName: Run MATLAB tests in parallel
# inputs:
# useParallel: true
# sourceFolder: src
# condition: not(eq(${{ version }}, '0'))
# - bash: |
# set -e
# grep -q "Starting parallel pool (parpool)" console.log
# rm console.log
# displayName: Verify tests ran in parallel
# condition: not(eq(${{ version }}, '0'))
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
displayName: Run MATLAB tests with detailed display level for event details
inputs:
outputDetail: Detailed
sourceFolder: src
- bash: |
set -e
grep -q "TestRunner.withTextOutput('OutputDetail', 3)" console.log
rm console.log
displayName: Verify tests ran with detailed display level for event details
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
displayName: Run MATLAB tests with detailed verbosity level for logged diagnostics
inputs:
loggingLevel: Detailed
sourceFolder: src
- bash: |
set -e
grep -q "TestRunner.withTextOutput('LoggingLevel', 3)" console.log
rm console.log
displayName: Verify tests ran with detailed verbosity level for logged diagnostics
- bash: |
mkdir simtests
cat << EOF > simtests/createModel.m
% Create model
model = 'new_temp_model';
new_system(model);
load_system(model);
% add blocks
add_block('built-in/Inport', [model, '/InputPort'], ...
'Position', [50 50 100 100]);
add_block('built-in/Gain', [model, '/Gain'], 'Gain', '1', ...
'Position', [150 50 200 100]);
add_block('built-in/Outport', [model, '/OutputPort'], ...
'Position', [250 50 300 100]);
% add lines
add_line(model, 'InputPort/1', 'Gain/1');
add_line(model, 'Gain/1', 'OutputPort/1');
% save system
save_system(model);
close_system(model);
% Create Simulink Test File
sltest.testmanager.clear;
sltest.testmanager.clearResults;
tf = sltest.testmanager.TestFile('test.mldatx');
% Set coverage related options.
cs = tf.getCoverageSettings;
cs.RecordCoverage = true;
cs.MdlRefCoverage = true;
cs.MetricSettings = 'd';
% Set model and collect baseline.
ts = tf.getTestSuites;
tc = ts.getTestCases;
tc.setProperty('model', model);
captureBaselineCriteria(tc,'baseline_API.mat',true);
% Save test file and close.
tf.saveToFile;
tf.close;
sltest.testmanager.close;
disp('Created Model and Simulink Test file to simulate the model.');
evalin('base', 'clear all');
EOF
displayName: Create model file and Simulink test.
condition: eq(variables['Agent.OS'], 'Linux')
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
displayName: Run model creator and test Simulink test generator
inputs:
command: "cd simtests;createModel"
condition: eq(variables['Agent.OS'], 'Linux')
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABTests.RunMATLABTests@${{ version }}
displayName: Run MATLAB tests and generate Simulink test artifacts
inputs:
selectByFolder: "simtests"
modelCoverageCobertura: test-results/matlab/modelcoverage.xml
testResultsSimulinkTest: test-results/matlab/stmResult.mldatx
testResultsPDF: test-results/matlab/results.pdf
condition: eq(variables['Agent.OS'], 'Linux')
- bash: |
set -e
grep -q new_temp_model test-results/matlab/modelcoverage.xml
displayName: Verify Model coverage was created
condition: eq(variables['Agent.OS'], 'Linux')
- bash: |
set -e
test -f test-results/matlab/stmResult.mldatx
displayName: Verify STM report was created
condition: eq(variables['Agent.OS'], 'Linux')
- bash: |
set -e
test -f test-results/matlab/results.pdf
displayName: Verify PDF report was created
condition: eq(variables['Agent.OS'], 'Linux')
- job: test_run_build_v${{ version }}
strategy:
matrix:
microsoft_hosted_linux:
poolName: Azure Pipelines
vmImage: ubuntu-22.04
setupTask: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
microsoft_hosted_macos:
poolName: Azure Pipelines
vmImage: macOS-latest
setupTask: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
microsoft_hosted_windows:
poolName: Azure Pipelines
vmImage: windows-latest
setupTask: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
pool:
name: $(poolName)
vmImage: $(vmImage)
steps:
- checkout: none
- task: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
displayName: Install MATLAB on Microsoft-hosted agents
condition: not(startsWith(variables['Agent.Name'], 'vmss'))
- bash: |
cat << EOF > buildfile.m
function plan = buildfile
plan = buildplan(localfunctions);
plan("test").Dependencies = "build";
plan("deploy").Dependencies = "test";
plan.DefaultTasks = "test";
function buildTask(~)
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'building\n'); fclose(f);
function testTask(~)
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'testing\n'); fclose(f);
function deployTask(~)
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'deploying\n'); fclose(f);
function checkTask(~)
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'checking\n'); fclose(f);
function errorTask(~)
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'erroring\n'); fclose(f);
error('Error occured in errorTask');
EOF
displayName: Create buildfile.m in project root
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABBuild.RunMATLABBuild@${{ version }}
displayName: Run build with default tasks
- bash: |
set -e
grep "building" buildlog.txt
grep "testing" buildlog.txt
! grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt
displayName: Verify that correct tasks appear in buildlog.txt
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABBuild.RunMATLABBuild@${{ version }}
displayName: Run build with specified task
inputs:
tasks: deploy
- bash: |
set -e
grep "building" buildlog.txt
grep "testing" buildlog.txt
grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt
displayName: Verify that correct tasks appear in buildlog.txt
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABBuild.RunMATLABBuild@${{ version }}
displayName: Run build with multiple specified tasks
inputs:
tasks: deploy check
- bash: |
set -e
grep "building" buildlog.txt
grep "testing" buildlog.txt
grep "deploying" buildlog.txt
grep "checking" buildlog.txt
rm buildlog.txt
displayName: Verify that correct tasks appear in buildlog.txt
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABBuild.RunMATLABBuild@${{ version }}
displayName: Run build with task skipping
inputs:
tasks: deploy
buildOptions: -skip test
condition: not(eq(${{ version }}, '0'))
- bash: |
set -e
grep "building" buildlog.txt
! grep "testing" buildlog.txt
grep "deploying" buildlog.txt
rm buildlog.txt
displayName: Verify that correct tasks appear in buildlog.txt
condition: not(eq(${{ version }}, '0'))
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABBuild.RunMATLABBuild@${{ version }}
displayName: Run build with continue on failure
continueOnError: true
inputs:
tasks: error deploy
buildOptions: -continueOnFailure
condition: not(eq(${{ version }}, '0'))
- bash: |
set -e
grep "erroring" buildlog.txt
grep "building" buildlog.txt
grep "testing" buildlog.txt
grep "deploying" buildlog.txt
rm buildlog.txt
displayName: Verify that correct tasks appear in buildlog.txt
condition: not(eq(${{ version }}, '0'))