Programmatically Run Tasks
With the support package CI/CD Automation for Simulink Check, you can run the tasks in your development and verification
process by using the Process
Advisor app on your local desktop or the Process Advisor
function runprocess
. Both of these approaches invoke the same incremental
build system so that you can have consistent task execution across different
environments like local desktop machines and continuous integration (CI) agents. The
build system is software that can create the
pipeline of tasks, efficiently execute tasks in the pipeline, and perform other
actions related to the pipeline.
This example shows how you can run tasks and generate a build report for a project
programmatically by using the runprocess
function with other
supporting functions. You can call these commands on your local desktop and from CI
agents. For information on running tasks with Process Advisor, see Process
Advisor.
Run Pipeline of Tasks
You can run tasks programmatically by
using the runprocess
function.
Run All Tasks
By default, if you use the runprocess
function
without specifying any name-value
arguments, runprocess()
, the function runs each of the
tasks associated with the current project and process model. This behavior
is equivalent to clicking the Run
All button in the
Process Advisor app.
To run each of the tasks associated with the current project and process, enter:
runprocess()
Run Specific Task
However, you often only want to run certain tasks or only run certain tasks on certain artifacts.
To only run a specific set of tasks, provide the task names to the
Tasks
argument. For
example:
% run the Generate Simulink Web View task % and the Check Modeling Standards tasks runprocess(... Tasks = ["padv.builtin.task.GenerateSimulinkWebView",... "padv.builtin.task.RunModelStandards"])
Run Task Iterations for Specific Artifact
To only run the task iterations associated with a specific artifact, use
the FilterArtifact
argument. For example, to run tasks
for the AHRS_Voter
model, you can specify the value as
the relative path to the
model:
% run only the AHRS_Voter tasks runprocess(... FilterArtifact = fullfile(... "02_Models","AHRS_Voter","specification","AHRS_Voter.slx"))
For more information, see the function runprocess
.
View Available Tasks Iterations
To return a list of the available task iterations in your current process, you
can use the generateProcessTasks
function.
generateProcessTasks
You can include or exclude certain task iterations by using the name-value
arguments of generateProcessTasks
. For example, to list the
task iterations associated with a specific model, you can specify the relative
path to the model using a padv.Artifact
object and pass that object to the
FilterArtifact
argument for
generateProcessTasks
.
% specify the relative path to the model AHRS_Voter model = padv.Artifact("sl_model_file",... padv.util.ArtifactAddress(... fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx"))); % find the tasks associated with the model AHRS_Voter ahrsVoterTasks = generateProcessTasks(FilterArtifact=model)
Generate Build Report
You can generate a report that summarizes the build results for the tasks that you run in your pipeline.
The report includes a:
Summary of task statuses
Summary of task results
Details about the task configuration and execution
Generate Report After Running Process
To automatically generate a report after you run your process, specify the
GenerateReport
argument of the runprocess
function as
true
:
runprocess(GenerateReport = true)
ReportFormat
and
ReportPath
arguments to specify a different report
format and a different report name or full file
path:runprocess(GenerateReport = true,... ReportFormat = "html-file",... ReportPath = fullfile(pwd,"folderName","reportName"))
Generate Report from Recent Task Results
After you run the tasks in your pipeline, you can also generate a report using the most recent task results.
After you run a task, create a padv.ProcessAdvisorReportGenerator
report object.
rptObj = padv.ProcessAdvisorReportGenerator;
Run generateReport
on the report object to generate a build
report in the current
directory.
generateReport(rptObj)
By default, the report generator generates a PDF. To generate an HTML
report, specify the Format
of the
ProcessAdvisorReportGenerator
object as
html-file
.
htmlReport=padv.ProcessAdvisorReportGenerator(Format="html-file");
generateReport(htmlReport);
If you run the tasks in the default process model, the report provides an overview common development and verification activities like the:
Model Advisor analysis, including the number of passing, warning, and failing checks
Test results, organized by iteration
Generated code files
Coding standards checks
For information on how to get started with the default process model, see Modify Default Process Model to Fit Your Process.
See Also
generateProcessTasks
| padv.Artifact
| padv.util.ArtifactAddress
| Process
Advisor | runprocess