Skip to content

Commit c4a811b

Browse files
authored
Add build options (#67)
1 parent 4001148 commit c4a811b

File tree

8 files changed

+73
-11
lines changed

8 files changed

+73
-11
lines changed

.circleci/test-deploy.yml

+49-3
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,17 @@ jobs:
348348
function buildTask(~)
349349
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'building\n'); fclose(f);
350350
351-
function testTask(~)
352-
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'testing\n'); fclose(f);
351+
function testTask(~,tests,options)
352+
arguments
353+
~
354+
tests string = "tests"
355+
options.OutputDetail (1,1) string = "terse"
356+
end
357+
f = fopen('buildlog.txt', 'a+');
358+
fprintf(f, 'testing\n');
359+
fprintf(f, '%s\n', tests);
360+
fprintf(f, '%s\n', options.OutputDetail);
361+
fclose(f);
353362
354363
function deployTask(~)
355364
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'deploying\n'); fclose(f);
@@ -367,6 +376,8 @@ jobs:
367376
set -e
368377
grep "building" buildlog.txt
369378
grep "testing" buildlog.txt
379+
grep "tests" buildlog.txt
380+
grep "terse" buildlog.txt
370381
grep "deploying" buildlog.txt
371382
! grep "checking" buildlog.txt
372383
rm buildlog.txt
@@ -380,20 +391,39 @@ jobs:
380391
set -e
381392
grep "building" buildlog.txt
382393
grep "testing" buildlog.txt
394+
grep "tests" buildlog.txt
395+
grep "terse" buildlog.txt
383396
grep "deploying" buildlog.txt
384397
grep "checking" buildlog.txt
385398
rm buildlog.txt
386399
shell: bash
400+
# run build with task args
401+
- matlab/run-build:
402+
tasks: test("myTests",OutputDetail="concise")
403+
- run:
404+
name: Verify that correct tasks appear in buildlog.txt
405+
command: |
406+
set -e
407+
grep "building" buildlog.txt
408+
grep "testing" buildlog.txt
409+
grep "myTests" buildlog.txt
410+
grep "concise" buildlog.txt
411+
! grep "deploying" buildlog.txt
412+
! grep "checking" buildlog.txt
413+
rm buildlog.txt
414+
shell: bash
387415
# run build with default tasks
388416
- matlab/run-build:
389417
startup-options: -logfile console.log
390418
- run:
391-
name: Verify that correct tasks appear in buildlog.txt
419+
name: Verify that correct tasks appear in buildlog.txt and console.log
392420
command: |
393421
set -e
394422
grep "building" buildlog.txt
395423
grep "build" console.log
396424
grep "testing" buildlog.txt
425+
grep "tests" buildlog.txt
426+
grep "terse" buildlog.txt
397427
grep "test" console.log
398428
! grep "deploying" buildlog.txt
399429
! grep "deploy" console.log
@@ -402,6 +432,22 @@ jobs:
402432
rm buildlog.txt
403433
rm console.log
404434
shell: bash
435+
# run build with task skipping
436+
- matlab/run-build:
437+
tasks: deploy
438+
build-options: -skip test
439+
- run:
440+
name: Verify that correct tasks appear in buildlog.txt
441+
command: |
442+
set -e
443+
grep "building" buildlog.txt
444+
! grep "testing" buildlog.txt
445+
! grep "tests" buildlog.txt
446+
! grep "terse" buildlog.txt
447+
grep "deploying" buildlog.txt
448+
! grep "checking" buildlog.txt
449+
rm buildlog.txt
450+
shell: bash
405451

406452
workflows:
407453
test-deploy:

devel/contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Familiarize yourself with the best practices in the [orb authoring process](http
1111
Make changes to the orb in the src folder. After you are done updating, pack and validate the orb locally:
1212

1313
```
14-
circleci orb pack > orb.yml
14+
circleci orb pack src > orb.yml
1515
circleci orb validate orb.yml
1616
```
1717
Note: the packed orb.yml file does not need to be committed to the repo. CircleCI will take care of all of this on release.

src/commands/run-build.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ parameters:
1010
in the plan returned by buildfile.m as well as all the tasks on which they depend.
1111
type: string
1212
default: ""
13+
build-options:
14+
description: >
15+
MATLAB build options, specified as a list of options separated by spaces. The command
16+
supports the same options that you can pass to the `buildtool` command when running a
17+
MATLAB build. For more information, see
18+
https://www.mathworks.com/help/matlab/ref/buildtool.html.
19+
type: string
20+
default: ""
1321
startup-options:
1422
description: >
1523
MATLAB startup options. If you specify more than one option, use a space to
@@ -29,7 +37,8 @@ steps:
2937
name: Run MATLAB build
3038
environment:
3139
PARAM_TASKS: <<parameters.tasks>>
32-
PARAM_ARGS: <<parameters.startup-options>>
40+
PARAM_BUILD_OPTIONS: <<parameters.build-options>>
41+
PARAM_STARTUP_OPTIONS: <<parameters.startup-options>>
3342
command: <<include(scripts/run-build.sh)>>
3443
shell: bash
3544
no_output_timeout: <<parameters.no-output-timeout>>

src/commands/run-command.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ steps:
3131
name: Run MATLAB command
3232
environment:
3333
PARAM_COMMAND: <<parameters.command>>
34-
PARAM_ARGS: <<parameters.startup-options>>
34+
PARAM_STARTUP_OPTIONS: <<parameters.startup-options>>
3535
command: <<include(scripts/run-command.sh)>>
3636
shell: bash
3737
no_output_timeout: <<parameters.no-output-timeout>>

src/commands/run-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ steps:
122122
PARAM_USE_PARALLEL: <<parameters.use-parallel>>
123123
PARAM_OUTPUT_DETAIL: <<parameters.output-detail>>
124124
PARAM_LOGGING_LEVEL: <<parameters.logging-level>>
125-
PARAM_ARGS: <<parameters.startup-options>>
125+
PARAM_STARTUP_OPTIONS: <<parameters.startup-options>>
126126
command: <<include(scripts/run-tests.sh)>>
127127
shell: bash
128128
no_output_timeout: <<parameters.no-output-timeout>>

src/scripts/run-build.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ if [[ $os = CYGWIN* || $os = MINGW* || $os = MSYS* ]]; then
2323
fi
2424

2525
# create buildtool command from parameters
26-
buildCommand="buildtool ${PARAM_TASKS}"
26+
buildCommand="buildtool"
27+
28+
if [ -n "$PARAM_TASKS" ]; then
29+
buildCommand+=" ${PARAM_TASKS}"
30+
fi
31+
if [ -n "$PARAM_BUILD_OPTIONS" ]; then
32+
buildCommand+=" ${PARAM_BUILD_OPTIONS}"
33+
fi
2734

2835
# create script to execute
2936
script=command_${RANDOM}
@@ -34,4 +41,4 @@ $buildCommand
3441
EOF
3542

3643
# run MATLAB command
37-
"${tmpdir}/bin/run-matlab-command$binext" "setenv('MW_ORIG_WORKING_FOLDER', cd('${scriptdir//\'/\'\'}'));$script" $PARAM_ARGS
44+
"${tmpdir}/bin/run-matlab-command$binext" "setenv('MW_ORIG_WORKING_FOLDER', cd('${scriptdir//\'/\'\'}'));$script" $PARAM_STARTUP_OPTIONS

src/scripts/run-command.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ ${PARAM_COMMAND}
3131
EOF
3232

3333
# run MATLAB command
34-
"${tmpdir}/bin/run-matlab-command$binext" "setenv('MW_ORIG_WORKING_FOLDER', cd('${scriptdir//\'/\'\'}'));$script" $PARAM_ARGS
34+
"${tmpdir}/bin/run-matlab-command$binext" "setenv('MW_ORIG_WORKING_FOLDER', cd('${scriptdir//\'/\'\'}'));$script" $PARAM_STARTUP_OPTIONS

src/scripts/run-tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ fi
4747
disp('Running MATLAB script with contents:');\
4848
disp(testScript.Contents);\
4949
fprintf('__________\n\n');\
50-
run(testScript);" $PARAM_ARGS
50+
run(testScript);" $PARAM_STARTUP_OPTIONS

0 commit comments

Comments
 (0)