Codecov MATLAB Example
This guide shows how to run MATLAB® tests, produce a code coverage report, and upload the report to Codecov. The repository includes these files.
File Path | Description |
---|---|
source/quadraticSolver.m |
The quadraticSolver function solves quadratic equations. |
tests/SolverTest.m |
The SolverTest class tests the quadraticSolver function. |
runMyTests.m |
The runMyTests script creates a test suite and a test runner that outputs a Cobertura code coverage report. |
azure-pipelines.yml |
The azure-pipelines.yml file defines the pipeline that runs on Azure® DevOps. |
.circleci/config.yml |
The config.yml file defines the pipeline that runs on CircleCI®. |
.travis.yml |
The config.yml file defines the pipeline that runs on Travis CI. |
Use these example pipeline YAMLs to:
- Install the latest MATLAB release on a Linux®-based build agent.
- Run all MATLAB tests in the root of your repository, including its subfolders.
- Produce a code coverage report in Cobertura XML format for the
source
folder. - Upload the produced artifact to Codecov.
pool:
vmImage: Ubuntu 16.04
steps:
- task: InstallMATLAB@0
- task: RunMATLABTests@0
inputs:
sourceFolder: source
codeCoverageCobertura: coverage.xml
- script: bash <(curl -s https://codecov.io/bash)
version: 2.1
orbs:
matlab: mathworks/[email protected]
codecov: codecov/[email protected]
jobs:
build:
machine:
image: ubuntu-1604:201903-01
steps:
- checkout
- matlab/install
- matlab/run-tests:
source-folder: source
code-coverage-cobertura: coverage.xml
- codecov/upload:
file: coverage.xml
language: matlab
script: matlab -batch 'runMyTests'
after_success: bash <(curl -s https://codecov.io/bash)
- Currently, MATLAB builds on CircleCI and Travis CI are available only for public projects. MATLAB builds on Azure DevOps that use Microsoft®-hosted agents are also available only for public projects.
If you have any questions or suggestions, please contact MathWorks® at [email protected].