Continuous integration (CI) is the practice of integrating code changes into a shared repository on a frequent basis. It 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 new committed changes to the remote repository, the continuous integration platform can automatically run a suite of tests to ensure that the changes do not cause any conflicts in the target branch of the remote repository.
The benefits of continuous integration include:
Finding problems in software and fixing them soon after they are introduced.
Adding more features while reducing the resources required for debugging code.
Minimizing integration and deployment overheads by performing integration on a continuous basis.
Clearly communicating the state of software and the changes that have been made to it.
A typical software development workflow using continuous integration involves several steps:
Cloning the remote repository and creating a feature branch
Editing files and committing the changes to the local repository
Pushing the committed changes to the remote repository (which triggers an automated pipeline of tasks such as compiling MEX files, packaging toolboxes, and testing on the CI platform)
Analyzing the reports generated by the CI platform and fixing the errors within the pipeline
Merging the remote feature branch into the master branch through a pull request (which triggers another automated pipeline of tasks on the CI platform)
Analyzing the reports generated by the CI platform and resolving the merge failures
This figure shows an example of the development cycle using the Jenkins™ CI server and open-source source code management tools such as Git™ and GitHub®. For information on how to interface MATLAB® with Jenkins, see Run MATLAB Tests on Jenkins Server.
Develop a feature and commit your changes to the local repository:
Clone the GitHub repository and create a new feature branch.
Make changes to the existing files or add new files as appropriate.
Run MATLAB and Simulink® tests to qualify the changes and commit them to the local repository.
Run an automated pipeline of tasks (including testing) when you push your changes to the remote repository or when you make a pull request:
Trigger an automated pipeline of tasks on Jenkins by pushing the committed changes to GitHub or by making a pull request to merge the remote feature branch into the master branch.
Jenkins runs the automated pipeline, including MATLAB and Simulink tests, and generates artifacts as specified in the project configuration.
If you do not succeed in pushing your changes or making a pull request, follow these steps:
Inspect the automated pipeline results and the generated test artifacts. Make appropriate changes to your code.
Trigger a new pipeline on Jenkins by pushing your changes to GitHub or by making a pull request.
Integration engineers can use Jenkins test artifacts to decide when to merge the feature branch into the master branch.
You can perform continuous integration with MATLAB on various continuous integration 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 models and code.
Toolbox | Use Case | More Information |
---|---|---|
Simulink |
| About Source Control with Projects (Simulink) Using a Project with Git (Simulink) |
Simulink Test™ | Run test files on CI platforms and collect CI-compatible coverage using Simulink Coverage™ | Continuous Integration (Simulink Test) |
Simulink Check™ | Use Jenkins to detect metric threshold violations in a model | Fix Metric Threshold Violations in a Continuous Integration Systems Workflow (Simulink Check) |
Simulink Requirements™ | Summarize requirements verification results for tests run on CI platforms | Include Results from External Sources in Verification Status (Simulink Requirements) |
Polyspace® Bug Finder™ Server™, Polyspace Code Prover™ Server |
| Run Bug Finder Analysis on Server During Continuous Integration (Polyspace Bug Finder Server) Run Code Prover Analysis on Server During Continuous Integration (Polyspace Code Prover Server) |
matlab.unittest.plugins Package