Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 81 additions & 6 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ integration-tests: &integration-tests
executors:
linux: &linux-executor
machine:
image: ubuntu-2204:edge
image: ubuntu-2204:2022.07.1
macos:
macos:
xcode: 13.2.1
xcode: 13.4.1
windows:
win/default

Expand Down Expand Up @@ -254,29 +254,104 @@ jobs:
grep -r "simple_model Coverage Report" --include="*.html" model-coverage/html
shell: bash

integration-test-run-build:
parameters:
executor:
type: executor
executor: <<parameters.executor>>
steps:
# Setup for Integ tests for matlab/run-build
- matlab/install
- run:
command: |
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);
_EOF
shell: bash
# run build with one specified task
- matlab/run-build:
tasks: deploy
- run:
name: Verify that correct tasks appear in buildlog.txt
command: |
set -e
grep "building" buildlog.txt
grep "testing" buildlog.txt
grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt
shell: bash
# run build with multiple specified tasks
- matlab/run-build:
tasks: deploy check
- run:
name: Verify that correct tasks appear in buildlog.txt
command: |
set -e
grep "building" buildlog.txt
grep "testing" buildlog.txt
grep "deploying" buildlog.txt
grep "checking" buildlog.txt
rm buildlog.txt
shell: bash
# run build with default tasks
- matlab/run-build
- run:
name: Verify that correct tasks appear in buildlog.txt
command: |
set -e
grep "building" buildlog.txt
grep "testing" buildlog.txt
! grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt
shell: bash

workflows:
test-deploy:
jobs:
# Make sure to include "filters: *filters" in every test job you want to run as part of your deployment.
- integration-test-install:
matrix:
parameters:
executor: [linux, windows]
executor: [linux, windows, macos]

- integration-test-install-release:
matrix:
parameters:
executor: [linux, windows]
executor: [linux, windows, macos]

- integration-test-run-command:
matrix:
parameters:
executor: [linux, windows]
executor: [linux, windows, macos]

- integration-test-run-tests:
matrix:
parameters:
executor: [linux, windows]
executor: [linux, windows, macos]

- integration-test-run-build:
matrix:
parameters:
executor: [linux, windows, macos]

- orb-tools/pack:
filters: *filters
Expand Down
2 changes: 1 addition & 1 deletion src/commands/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ steps:
name: Install MATLAB
environment:
PARAM_RELEASE: <<parameters.release>>
command: <<include(scripts/install.sh)>>
command: <<include(scripts/install.sh)>>
shell: bash
28 changes: 28 additions & 0 deletions src/commands/run-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
description: >
Run builds using the MATLAB build tool. Use this command to run the tasks in the plan returned
by a file named buildfile.m in the root of your repository. To use the run-build command, you
need MATLAB R2022b or a later release.

parameters:
tasks:
description: >
Space-separated list of tasks to run. If not specified, the command runs the default tasks
in the plan returned by buildfile.m as well as all the tasks on which they depend.
type: string
default: ""
no-output-timeout:
description: >
Elapsed time the command can run without output. The string is a decimal with unit suffix,
such as “20m”, “1.25h”, “5s”. The default is 10 minutes and the maximum is governed by the
maximum time a job is allowed to run.
type: string
default: 10m

steps:
- run:
name: Run MATLAB build
environment:
PARAM_TASKS: <<parameters.tasks>>
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 @@ -25,6 +25,6 @@ steps:
name: Run MATLAB command
environment:
PARAM_COMMAND: <<parameters.command>>
command: <<include(scripts/run-command.sh)>>
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 @@ -89,6 +89,6 @@ steps:
PARAM_TEST_RESULTS_SIMULINK_TEST: <<parameters.test-results-simulink-test>>
PARAM_TEST_RESULTS_HTML: <<parameters.test-results-html>>
PARAM_TEST_RESULTS_PDF: <<parameters.test-results-pdf>>
command: <<include(scripts/run-tests.sh)>>
command: <<include(scripts/run-tests.sh)>>
shell: bash
no_output_timeout: <<parameters.no-output-timeout>>
20 changes: 20 additions & 0 deletions src/examples/run-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
description: >
Run a MATLAB build for your project.

usage:
version: 2.1
orbs:
matlab: mathworks/matlab@0
jobs:
build:
machine:
image: ubuntu-2204:2022.07.1
steps:
- checkout
- matlab/install
- matlab/run-build:
tasks: test
workflows:
build:
jobs:
- build
2 changes: 1 addition & 1 deletion src/examples/run-custom-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ usage:
jobs:
build:
machine:
image: ubuntu-2004:202111-02
image: ubuntu-2204:2022.07.1
steps:
- checkout
- matlab/install
Expand Down
2 changes: 1 addition & 1 deletion src/examples/run-tests-with-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ usage:
jobs:
build:
machine:
image: ubuntu-2004:202111-02
image: ubuntu-2204:2022.07.1
steps:
- checkout
- matlab/install
Expand Down
39 changes: 39 additions & 0 deletions src/scripts/run-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
downloadAndRun() {
url=$1
shift
if [[ -x $(command -v sudo) ]]; then
curl -sfL $url | sudo -E bash -s -- "$@"
else
curl -sfL $url | bash -s -- "$@"
fi
}

tmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'run-command')

# install run-matlab-command
downloadAndRun https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v1/install.sh "${tmpdir}/bin"

# form OS appropriate paths for MATLAB
os=$(uname)
workdir=$(pwd)
scriptdir=$tmpdir
binext=""
if [[ $os = CYGWIN* || $os = MINGW* || $os = MSYS* ]]; then
workdir=$(cygpath -w "$workdir")
scriptdir=$(cygpath -w "$scriptdir")
binext=".exe"
fi

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

# create script to execute
script=command_${RANDOM}
scriptpath=${tmpdir}/${script}.m
echo "cd('${workdir//\'/\'\'}');" > "$scriptpath"
cat << EOF >> "$scriptpath"
$buildCommand
EOF

# run MATLAB command
"${tmpdir}/bin/run-matlab-command$binext" "cd('${scriptdir//\'/\'\'}');$script"