Main Content

Run Tasks Locally and in CI

The support package CI/CD Automation for Simulink Check provides tools to help you integrate your model-based process into a Continuous Integration / Continuous Deployment (CI/CD) system.

The support package provides:

  • A customizable process modeling system that you can use to define your build and verification process

  • A build system that can automatically generate and efficiently execute a process in your CI system

  • The Process Advisor app for deploying and automating your prequalification process

  • Integration with common CI systems

You can use the support package to help you set up a model-based design (MBD) pipeline, reduce build time, reduce build failures, debug build failures, and deploy a consistent build and verification process.

Installation

To install the support package, use one of the following methods:

  • In a Simulink® model window, in the Apps gallery, click Process Advisor. In the row for the support package CI/CD Automation for Simulink Check™, click Click to install.

    Process Advisor expects your model to be inside a project. If you do not have a project, you can create a project directly from the model or create a new project from scratch. For information, see Create Projects.

  • Download the support package installer from the MATLAB® File Exchange. To download and install, see CI/CD Automation for Simulink Check.

  • Use the Add-On Explorer. In the MATLAB toolstrip, click Add-Ons > Get Add-Ons and search for CI/CD Automation for Simulink Check.

After installing the support package, your team can identify, automate, and complete development and verification activities, like checking modeling standards with Model Advisor and running custom tasks, as part of your local prequalification in Process Advisor. Additionally, you can integrate your process into your continuous integration (CI) system by using the incremental build system and pipeline generator APIs from the support package.

MBD Pipeline

In a typical CI/CD pipeline, the CI/CD system automatically builds your source code, performs testing, packages deliverables, and deploys the packages to production. With the support package CI/CD Automation for Simulink Check, you can create a pipeline for the steps in your build and verification process, and maintain a repeatable CI/CD process for model-based design.

For example, this diagram shows an MBD pipeline that checks modeling standards, runs tests, generates code, and performs a custom task.

Flow diagram for an example MBD pipeline

You can use the customizable process modeling system to define the steps in your model-based design (MBD) pipeline. You define the steps by using a process model. A process model is a MATLAB script that specifies the tasks in the CI/CD process, dependencies between the tasks, and artifacts that you associate with each task.

A task is a single step in your process. Tasks can accept your project artifacts as inputs, perform actions, generate pass, fail, or warning assessments, and return project artifacts as outputs.

Flow diagram for a task accepting input artifacts and returning output artifacts and assessments

The support package contains built-in tasks for several common steps, including:

  • Creating Web views for your models with Simulink Report Generator™

  • Checking modeling standards with the Model Advisor

  • Running tests with Simulink Test™

  • Detecting design errors with Simulink Design Verifier™

  • Generating a System Design Description (SDD) report with Simulink Report Generator

  • Generating code with Embedded Coder®

  • Checking coding standards with Polyspace® Bug Finder™

  • Inspecting code with Simulink Code Inspector™

  • Running tests with Simulink Test

  • Generating a consolidated test results report and a merged coverage report with Simulink Test and Simulink Coverage™

The support package contains a default process model for an MBD pipeline, but you can also customize the default process model to fit your development workflow goals. For example, your custom process model might include the built-in tasks for checking modeling standards, running tests, and generating code before performing a custom task. You can customize the process model to add or remove tasks in the MBD pipeline. You can also reconfigure the tasks in your process model to change what action a task performs or how a task performs the action.

Build System

The support package CI/CD Automation for Simulink Check provides a build system that you can use to automate the steps in your MBD pipeline. 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.

To create the pipeline of tasks, the build system needs:

  1. A MATLAB project to analyze

  2. A process model in the project that defines the tasks in the pipeline

If the project does not contain a process model, the build system copies the default process model into the project and uses the default process model to create a default MBD pipeline.

When you call the build system, the build system loads the process model, analyzes the project, and creates a pipeline of tasks for the project.

Build system creating a pipeline of tasks for a MATLAB Project with a process model

To run the tasks in the pipeline, you can call the build system using one of these approaches:

  • In a CI environment by using the build system API. The build system API includes a function runprocess that you can use to run the tasks in a pipeline.

  • Locally on your machine by using either the build system API or the Process Advisor app. Process Advisor is a user interface that can call the build system. Process Advisor has run buttons that you can use to run the tasks in a pipeline. If there is a failure in the CI environment, you can reproduce the issue locally on your machine by using Process Advisor.

The build system supports incremental builds. If you change an artifact in your project, the build system can detect the change and automatically determine which of the tasks in your MBD pipeline now have outdated results. In your next build, you can instruct the build system to run only the tasks with outdated results. By identifying the tasks with outdated results, the build system can help you reduce build time by reducing the number of tasks you need to re-run after making changes to your project artifacts.

Note

There are limitations to the types of changes that the support package can detect. For more information, see the documentation that ships with the support package.

Process Advisor App

A prequalification process can help you prevent build and test failures from occurring in your CI/CD system. Use the Process Advisor desktop app to deploy and automate your prequalification process. You can use the app to locally run the tasks in your MBD pipeline and to prequalify your changes on your machine before submitting to source control. Process Advisor is a user interface for running the build system locally on your machine. Process Advisor runs tasks locally, not in the CI environment. You can use Process Advisor on your local machine to run the tasks in your MBD pipeline and to check your progress towards completing tasks in your prequalification pipeline for your changes.

If you make a change to an artifact in your project, Process Advisor can detect the change and automatically determine the impact of the change on your existing task results. For example, if you complete a task but then update your model, Process Advisor automatically invalidates the task completion and marks the task results as outdated.

CI/CD System Integration

You can use the support package CI/CD Automation for Simulink Check to integrate your model-based design process into common CI/CD systems. For GitLab® and Jenkins® systems, you can use the pipeline generator in the support package to automatically generate CI pipeline configuration files for running your process on the latest project files. For GitHub®, you can manually generate a pipeline configuration file that you can use to define a GitHub Actions workflow.

The support package contains example projects and pipeline configuration files for these CI systems:

  • For GitLab, enter:

    processAdvisorGitLabExampleStart
    This code creates an example project that contains an example YAML file, .gitlab-ci.yml, in the project root.

  • For Jenkins, enter:

    processAdvisorJenkinsExampleStart
    This code creates an example project that contains an example Jenkinsfile, Jenkinsfile, in the project root.

  • For GitHub, enter:

    processAdvisorGitHubExampleStart

Related Topics