Main Content

Develop and Integrate Software with Continuous Integration

Continuous integration (CI) is the practice of incorporating code changes into a shared central repository on a frequent basis. CI improves team throughput and software quality by automating and standardizing activities such as building code, testing, and packaging. For example, each time a developer pushes code changes to the central repository, the continuous integration platform can automatically run a suite of tests to verify that the changes do not cause any conflicts in the target branch of the central repository.

The benefits of continuous integration include:

  • Finding and fixing problems in software soon after they are introduced

  • Adding more features while reducing the resources needed for debugging code

  • Minimizing integration and deployment overhead by continuously integrating changes

  • Clearly communicating about the state of the software and its recent changes

Continuous Integration Workflow

A typical continuous integration workflow involves several steps within three phases:

Phase 1: Develop and Qualify Feature in Local Repository

Develop a feature and commit your changes to the local repository:

  1. Clone the central repository and create a new feature branch.

  2. Make changes to the existing files or add new files as appropriate.

  3. Run MATLAB® and Simulink® tests to qualify the changes and commit the changes to the local repository.

Phase 2: Run Automated Pipeline on Continuous Integration Platform

Run an automated pipeline of tasks (including testing) when you push your changes to the central repository or when you make a pull request:

  1. Push the committed changes to the central repository or make a pull request to merge your feature branch into the main branch (which triggers an automated pipeline of tasks, such as compiling MEX files, running MATLAB and Simulink tests, and packaging toolboxes on the CI platform).

  2. The CI platform runs the automated pipeline and generates artifacts as specified in the project configuration.

Phase 3: Investigate and Resolve Failures

If you do not succeed in pushing your changes or making a pull request, follow these steps:

  1. Inspect the automated pipeline results and the generated artifacts. Make appropriate changes to your code.

  2. Trigger a new pipeline on the CI platform by pushing your changes to the central repository or by making a pull request.

Integration engineers can use CI platform artifacts to decide when to merge the feature branch into the main branch.

This figure shows an example of the continuous integration workflow using Jenkins® as the CI platform and Git™ and GitHub® as the source code management tools. For information on how to use MATLAB with Jenkins, see Run MATLAB Tests on Jenkins Server. For more information on the built-in integrations with Git and Subversion® (SVN), see Source Control Integration in MATLAB.

Example of the continuous integration workflow

Continuous Integration with MathWorks Products

You can perform continuous integration with MATLAB on various CI platforms. You can run and test your MATLAB code and Simulink models, generate artifacts, and publish your results to the platforms. For more information, see Continuous Integration with MATLAB on CI Platforms.

In addition to MATLAB, different toolboxes support continuous integration workflows. This table lists common continuous integration use cases for code and models.

ToolboxUse CaseMore Information
Simulink

  • Cache files for simulation and code generation.

  • Attach model comparison reports to pull and merge requests.

  • Automatically merge models on CI platforms.

Simulink Test™

Run test files on CI platforms and collect CI-compatible coverage using Simulink Coverage™.

Continuous Integration (Simulink Test)

Simulink Check™

Deploy automated processes to your team to help them identify, automate, and complete development and verification activities.

Continuous Integration (Simulink Check)

Requirements Toolbox™Summarize requirements verification results for tests run on CI platforms.

Include Results from External Sources in Verification Status (Requirements Toolbox)

Polyspace® Bug Finder™ Server™, Polyspace Code Prover™ Server
  • Run a Polyspace analysis on C/C++ code as part of continuous integration.

  • Upload the analysis results (bugs, run-time errors, or coding standard violations) for review in the Polyspace Access™ web interface.

  • Send email notifications with Polyspace Bug Finder or Polyspace Code Prover results.

See Also

Functions

Namespaces

Topics

External Websites