11version : 2.1
2-
2+ setup : true
33orbs :
4- matlab : mathworks/matlab@<<pipeline.parameters.dev-orb-version>>
5- orb-tools : circleci/orb-tools@9.1
6- win : circleci/windows@2.2.0
7-
8- # Pipeline parameters
9- parameters :
10- # These pipeline parameters are required by the "trigger-integration-tests-workflow"
11- # job, by default.
12- run-integration-tests :
13- type : boolean
14- default : false
15- dev-orb-version :
16- type : string
17- default : " dev:alpha"
18-
19- integration-tests : &integration-tests
20- [
21- integration-test-install,
22- integration-test-install-release,
23- integration-test-run-command,
24- integration-test-run-tests
25- ]
26-
27- executors :
28- linux : &linux-executor
29- machine :
30- image : ubuntu-2004:202111-02
31- macos :
32- macos :
33- xcode : 13.2.1
34- windows :
35- win/default
36-
37- jobs :
38- integration-test-install :
39- parameters :
40- executor :
41- type : executor
42- executor : <<parameters.executor>>
43- steps :
44- - matlab/install
45- - run :
46- name : Verify the matlab and mex scripts are available
47- command : |
48- set -e
49- matlab -batch version
50- os=$(uname)
51- if [[ $os = CYGWIN* || $os = MINGW* || $os = MSYS* ]]; then
52- mex.bat -h
53- else
54- mex -h
55- fi
56- shell : bash
57-
58- integration-test-install-release :
59- parameters :
60- executor :
61- type : executor
62- executor : <<parameters.executor>>
63- steps :
64- - matlab/install :
65- release : R2021a
66- - run :
67- name : Verify the matlab and mex scripts are available
68- command : |
69- set -e
70- matlab -batch "assert(strcmp(version('-release'),'2021a'))"
71- shell : bash
4+ orb-tools : circleci/orb-tools@11.1
5+ shellcheck : circleci/shellcheck@3.1
726
73- integration-test-run-command :
74- parameters :
75- executor :
76- type : executor
77- executor : <<parameters.executor>>
78- steps :
79- - matlab/install
80- - matlab/run-command :
81- command : f = fopen('myscript.m', 'w'); fwrite(f, 'assert(true)'); fclose(f);
82- - matlab/run-command :
83- command : myscript
84- - matlab/run-command :
85- command : " eval(\" a = 1+2\" ); assert(a == 3); eval('b = 3+4'); assert(b == 7);"
86- - matlab/run-command :
87- command : ' eval("a = 1+2"); assert(a == 3); eval('' b = 3+4'' ); assert(b == 7);'
88- - matlab/run-command :
89- command : a = """hello world"""; b = '"hello world"'; assert(strcmp(a,b), a+b);
90- - matlab/run-command :
91- command : |
92- a = " !""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; b = char([32:126]); assert(strcmp(a, b), a+b);
93- - run :
94- command : |
95- dir=$CIRCLE_WORKING_DIRECTORY
96- os=$(uname)
97- if [[ $os = CYGWIN* || $os = MINGW* || $os = MSYS* ]]; then
98- dir=$(cygpath -w "${dir/#\~/$HOME}")
99- fi
100- echo 'export WORK_DIR="'$dir'"' >> $BASH_ENV
101- shell : bash
102- - matlab/run-command :
103- command : |
104- [~, exp] = system("echo " + getenv('WORK_DIR')); exp = strtrim(exp); act = pwd; assert(strcmp(act, exp), strjoin({act exp}, '\n'));
105- - run :
106- command : echo 'myvar = 123' > startup.m
107- shell : bash
108- - matlab/run-command :
109- command : assert(myvar==123, 'myvar was not set as expected by startup.m')
110-
111- integration-test-run-tests :
112- parameters :
113- executor :
114- type : executor
115- executor : <<parameters.executor>>
116- steps :
117- # Setup for Integ tests for matlab/run-tests
118- - matlab/install
119- - run :
120- command : |
121- echo 'myvar = 123' > startup.m
122- mkdir src
123- echo 'function c=add(a,b);c=a+b;' > src/add.m
124- mkdir tests
125- echo "%% StartupTest" > tests/mytest.m
126- echo "evalin('base','assert(myvar==123)')" >> tests/mytest.m
127- echo "%% FirstTest" >> tests/mytest.m
128- echo "assert(add(1,2)==3)" >> tests/mytest.m
129- mkdir tests/filteredTest
130- echo "%% simpleTest" >> tests/filteredTest/filtertest.m
131- echo "assert(2==2)" >> tests/filteredTest/filtertest.m
132- printf "%% FilterByTag\n" >> tests/filteredTest/TaggedTest.m
133- printf "classdef (TestTags = {'FILTERED'}) TaggedTest < matlab.unittest.TestCase\n" >> tests/filteredTest/TaggedTest.m
134- printf "methods (Test)\n function testTag (testCase)\n assert(2==2);\n end\n end\n end" >> tests/filteredTest/TaggedTest.m
135- shell : bash
136-
137- # Integ tests for matlab/run-tests
138- - matlab/run-tests :
139- source-folder : src
140- - matlab/run-tests :
141- test-results-junit : test-results/matlab/results.xml
142- code-coverage-cobertura : code-coverage/coverage.xml
143- source-folder : src
144- - matlab/run-tests :
145- test-results-junit : test-results/matlab/filterdtestresult.xml
146- select-by-folder : tests/filteredTest
147- - matlab/run-tests :
148- test-results-junit : test-results/matlab/filterdtagresult.xml
149- select-by-tag : FILTERED
150-
151- - run :
152- name : Verify test results file was created
153- command : |
154- set -e
155- grep -q FirstTest test-results/matlab/results.xml
156- shell : bash
157- - run :
158- name : Verify code coverage file was created
159- command : |
160- set -e
161- grep -q add code-coverage/coverage.xml
162- shell : bash
163- - run :
164- name : Verify filtered test results file was created
165- command : |
166- set -e
167- grep -q simpleTest test-results/matlab/filterdtestresult.xml
168- grep -v FirstTest test-results/matlab/filterdtestresult.xml
169- shell : bash
170- - run :
171- name : Verify filter by tag test results file was created
172- command : |
173- set -e
174- grep -q TaggedTest test-results/matlab/filterdtagresult.xml
175- grep -v FirstTest test-results/matlab/filterdtagresult.xml
176- grep -v simpleTest test-results/matlab/filterdtagresult.xml
177- shell : bash
178-
179- # Set up for model coverage artifact tests
180- - when :
181- condition :
182- equal : [*linux-executor, <<parameters.executor>>]
183- steps :
184- - run :
185- command : |
186- mkdir simtests
187- cat \<<'_EOF' >> "simtests/createModelAndTest.m"
188- model = 'simple_model';
189- evalin('base','bdclose all');
190- if exist('simple_model.slx', 'file') == 0
191- new_system(model);
192- load_system(model);
193- add_block('built-in/Constant', [model, '/Constant']);
194- save_system(model);
195- close_system(model);
196- sltest.testmanager.clear;
197- sltest.testmanager.clearResults;
198- tf = sltest.testmanager.TestFile('test.mldatx');
199- cs = tf.getCoverageSettings;
200- cs.RecordCoverage = true;
201- cs.MdlRefCoverage = true;
202- cs.MetricSettings = 'd';
203- ts = tf.getTestSuites;
204- tc = ts.getTestCases;
205- tc.setProperty('model', model);
206- tf.saveToFile;
207- tf.close;
208- sltest.testmanager.close;
209- end
210- disp('Created Model and Simulink Test file to simulate the model.');
211- _EOF
212- shell : bash
213- - matlab/run-command :
214- command : cd simtests;createModelAndTest;
215- - matlab/run-tests :
216- select-by-folder : simtests
217- model-coverage-cobertura : model-coverage/coverage.xml
218- test-results-pdf : test-results/matlab/pdfresults.pdf
219- test-results-simulink-test : test-results/matlab/simulinkTest.mldatx
220- - run :
221- name : Verify pdf test report file generation
222- command : |
223- set -e
224- test -f test-results/matlab/pdfresults.pdf
225- shell : bash
226- - run :
227- name : Verify Simulink Test result file generation
228- command : |
229- set -e
230- test -f test-results/matlab/simulinkTest.mldatx
231- shell : bash
232- - run :
233- name : Verify model coverage file was created
234- command : |
235- set -e
236- grep -q simple_model model-coverage/coverage.xml
237- shell : bash
7+ filters : &filters
8+ tags :
9+ only : /.*/
23810
23911workflows :
240- # This `lint-pack_validate_publish-dev` workflow will run on any commit.
241- lint_pack-validate_publish-dev :
242- unless : << pipeline.parameters.run-integration-tests >>
12+ lint-pack :
24313 jobs :
244- # Lint your YAML
245- - orb-tools/lint
246-
247- # pack your orb YAML files to a single orb.yml
248- # validate the orb.yml file to ensure it is well-formed
249- - orb-tools/pack
250-
251- # release dev version of orb, for testing & possible publishing.
252- # orb will be published as dev:alpha and dev:${CIRCLE_SHA1:0:7}.
253- # requires a CircleCI API token to be stored as CIRCLE_TOKEN (default)
254- # https://circleci.com/docs/2.0/managing-api-tokens
255- # store CIRCLE_TOKEN as a project env var or Contexts resource
256- # if using Contexts, add your context below
257- - orb-tools/publish-dev :
14+ # Lint, pack, and review your orb
15+ - orb-tools/lint :
16+ filters : *filters
17+ - orb-tools/pack :
18+ filters : *filters
19+ - orb-tools/review :
20+ exclude : RC005
21+ filters : *filters
22+ - shellcheck/check :
23+ exclude : SC2148,SC2038,SC2086,SC2002,SC2016
24+ filters : *filters
25+ - orb-tools/publish :
25826 orb-name : mathworks/matlab
27+ vcs-type : << pipeline.project.type >>
25928 requires :
260- - orb-tools/lint
261- - orb-tools/pack
262-
263- # trigger an integration workflow to test the
264- # dev:${CIRCLE_SHA1:0:7} version of your orb
265- - orb-tools/trigger-integration-tests-workflow :
266- name : trigger-integration-dev
267- requires :
268- - orb-tools/publish-dev
269-
270- # This `integration-tests_prod-release` workflow will only run
271- # when the run-integration-tests pipeline parameter is set to true.
272- # It is meant to be triggered by the "trigger-integration-tests-workflow"
273- # job, and run tests on <your orb>@dev:${CIRCLE_SHA1:0:7}.
274- integration-tests_prod-release :
275- when : << pipeline.parameters.run-integration-tests >>
276- jobs :
277- # your integration test jobs go here: essentially, run all your orb's
278- # jobs and commands to ensure they behave as expected. or, run other
279- # integration tests of your choosing
280- - integration-test-install :
281- matrix :
282- parameters :
283- executor : [linux, windows]
284-
285- - integration-test-install-release :
286- matrix :
287- parameters :
288- executor : [linux, windows]
289-
290- - integration-test-run-command :
291- matrix :
292- parameters :
293- executor : [linux, windows]
294-
295- - integration-test-run-tests :
296- matrix :
297- parameters :
298- executor : [linux, windows]
299-
300- # publish a semver version of the orb. relies on
301- # the commit subject containing the text "[semver:patch|minor|major|skip]"
302- # as that will determine whether a patch, minor or major
303- # version will be published or if publishing should
304- # be skipped.
305- # e.g. [semver:patch] will cause a patch version to be published.
306- - orb-tools/dev-promote-prod-from-commit-subject :
307- orb-name : mathworks/matlab
308- add-pr-comment : false
309- fail-if-semver-not-indicated : true
310- publish-version-tag : true
311- ssh-fingerprints : e0:48:de:54:c4:e8:fb:15:1c:1c:a5:89:95:e5:23:69
312- requires : *integration-tests
313- filters :
314- branches :
315- only : master
29+ [orb-tools/lint, orb-tools/review, orb-tools/pack, shellcheck/check]
30+ filters : *filters
31+ # Triggers the next workflow in the Orb Development Kit.
32+ - orb-tools/continue :
33+ pipeline-number : << pipeline.number >>
34+ vcs-type : << pipeline.project.type >>
35+ requires : [orb-tools/publish]
36+ filters : *filters
0 commit comments