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:
Clone the central 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 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:
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).
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:
Inspect the automated pipeline results and the generated artifacts. Make appropriate changes to your code.
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.
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.
Toolbox | Use Case | More Information |
---|---|---|
Simulink |
| |
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 |
|
|
See Also
Functions
Namespaces
Topics
- Git in MATLAB
- SVN in MATLAB
- Reduce Test Runtime on CI Servers
- Use Source Control with MATLAB Projects
- Explore an Example Project
- Continuous Integration with MATLAB on CI Platforms