Skip to content

Commit

Permalink
Add build options (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
mw-kapilg authored Feb 15, 2024
1 parent 4001148 commit c4a811b
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 11 deletions.
52 changes: 49 additions & 3 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,17 @@ jobs:
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 testTask(~,tests,options)
arguments
~
tests string = "tests"
options.OutputDetail (1,1) string = "terse"
end
f = fopen('buildlog.txt', 'a+');
fprintf(f, 'testing\n');
fprintf(f, '%s\n', tests);
fprintf(f, '%s\n', options.OutputDetail);
fclose(f);
function deployTask(~)
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'deploying\n'); fclose(f);
Expand All @@ -367,6 +376,8 @@ jobs:
set -e
grep "building" buildlog.txt
grep "testing" buildlog.txt
grep "tests" buildlog.txt
grep "terse" buildlog.txt
grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt
Expand All @@ -380,20 +391,39 @@ jobs:
set -e
grep "building" buildlog.txt
grep "testing" buildlog.txt
grep "tests" buildlog.txt
grep "terse" buildlog.txt
grep "deploying" buildlog.txt
grep "checking" buildlog.txt
rm buildlog.txt
shell: bash
# run build with task args
- matlab/run-build:
tasks: test("myTests",OutputDetail="concise")
- run:
name: Verify that correct tasks appear in buildlog.txt
command: |
set -e
grep "building" buildlog.txt
grep "testing" buildlog.txt
grep "myTests" buildlog.txt
grep "concise" buildlog.txt
! grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt
shell: bash
# run build with default tasks
- matlab/run-build:
startup-options: -logfile console.log
- run:
name: Verify that correct tasks appear in buildlog.txt
name: Verify that correct tasks appear in buildlog.txt and console.log
command: |
set -e
grep "building" buildlog.txt
grep "build" console.log
grep "testing" buildlog.txt
grep "tests" buildlog.txt
grep "terse" buildlog.txt
grep "test" console.log
! grep "deploying" buildlog.txt
! grep "deploy" console.log
Expand All @@ -402,6 +432,22 @@ jobs:
rm buildlog.txt
rm console.log
shell: bash
# run build with task skipping
- matlab/run-build:
tasks: deploy
build-options: -skip test
- run:
name: Verify that correct tasks appear in buildlog.txt
command: |
set -e
grep "building" buildlog.txt
! grep "testing" buildlog.txt
! grep "tests" buildlog.txt
! grep "terse" buildlog.txt
grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt
shell: bash

workflows:
test-deploy:
Expand Down
2 changes: 1 addition & 1 deletion devel/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Familiarize yourself with the best practices in the [orb authoring process](http
Make changes to the orb in the src folder. After you are done updating, pack and validate the orb locally:

```
circleci orb pack > orb.yml
circleci orb pack src > orb.yml
circleci orb validate orb.yml
```
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.
Expand Down
11 changes: 10 additions & 1 deletion src/commands/run-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ parameters:
in the plan returned by buildfile.m as well as all the tasks on which they depend.
type: string
default: ""
build-options:
description: >
MATLAB build options, specified as a list of options separated by spaces. The command
supports the same options that you can pass to the `buildtool` command when running a
MATLAB build. For more information, see
https://www.mathworks.com/help/matlab/ref/buildtool.html.
type: string
default: ""
startup-options:
description: >
MATLAB startup options. If you specify more than one option, use a space to
Expand All @@ -29,7 +37,8 @@ steps:
name: Run MATLAB build
environment:
PARAM_TASKS: <<parameters.tasks>>
PARAM_ARGS: <<parameters.startup-options>>
PARAM_BUILD_OPTIONS: <<parameters.build-options>>
PARAM_STARTUP_OPTIONS: <<parameters.startup-options>>
command: <<include(scripts/run-build.sh)>>
shell: bash
no_output_timeout: <<parameters.no-output-timeout>>
2 changes: 1 addition & 1 deletion src/commands/run-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ steps:
name: Run MATLAB command
environment:
PARAM_COMMAND: <<parameters.command>>
PARAM_ARGS: <<parameters.startup-options>>
PARAM_STARTUP_OPTIONS: <<parameters.startup-options>>
command: <<include(scripts/run-command.sh)>>
shell: bash
no_output_timeout: <<parameters.no-output-timeout>>
2 changes: 1 addition & 1 deletion src/commands/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ steps:
PARAM_USE_PARALLEL: <<parameters.use-parallel>>
PARAM_OUTPUT_DETAIL: <<parameters.output-detail>>
PARAM_LOGGING_LEVEL: <<parameters.logging-level>>
PARAM_ARGS: <<parameters.startup-options>>
PARAM_STARTUP_OPTIONS: <<parameters.startup-options>>
command: <<include(scripts/run-tests.sh)>>
shell: bash
no_output_timeout: <<parameters.no-output-timeout>>
11 changes: 9 additions & 2 deletions src/scripts/run-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ if [[ $os = CYGWIN* || $os = MINGW* || $os = MSYS* ]]; then
fi

# create buildtool command from parameters
buildCommand="buildtool ${PARAM_TASKS}"
buildCommand="buildtool"

if [ -n "$PARAM_TASKS" ]; then
buildCommand+=" ${PARAM_TASKS}"
fi
if [ -n "$PARAM_BUILD_OPTIONS" ]; then
buildCommand+=" ${PARAM_BUILD_OPTIONS}"
fi

# create script to execute
script=command_${RANDOM}
Expand All @@ -34,4 +41,4 @@ $buildCommand
EOF

# run MATLAB command
"${tmpdir}/bin/run-matlab-command$binext" "setenv('MW_ORIG_WORKING_FOLDER', cd('${scriptdir//\'/\'\'}'));$script" $PARAM_ARGS
"${tmpdir}/bin/run-matlab-command$binext" "setenv('MW_ORIG_WORKING_FOLDER', cd('${scriptdir//\'/\'\'}'));$script" $PARAM_STARTUP_OPTIONS
2 changes: 1 addition & 1 deletion src/scripts/run-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ ${PARAM_COMMAND}
EOF

# run MATLAB command
"${tmpdir}/bin/run-matlab-command$binext" "setenv('MW_ORIG_WORKING_FOLDER', cd('${scriptdir//\'/\'\'}'));$script" $PARAM_ARGS
"${tmpdir}/bin/run-matlab-command$binext" "setenv('MW_ORIG_WORKING_FOLDER', cd('${scriptdir//\'/\'\'}'));$script" $PARAM_STARTUP_OPTIONS
2 changes: 1 addition & 1 deletion src/scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ fi
disp('Running MATLAB script with contents:');\
disp(testScript.Contents);\
fprintf('__________\n\n');\
run(testScript);" $PARAM_ARGS
run(testScript);" $PARAM_STARTUP_OPTIONS

0 comments on commit c4a811b

Please sign in to comment.