Matlab on Travis-CI

Matlab on Travis-CI is useful to automatically unit test Matlab code on each git push as with other coding languages. As typical for CI, we use a “.travis.yml” file in the Git repo to control Travis-CI behavior.

language: matlab

matlab:
- latest

script:
- matlab -batch "r = runtests('IncludeSubfolders',true); assert(~isempty(r)); assertSuccess(r)"

Matlab CI with compiled program

Using Matlab with code from compiled languages takes a few extra parameters. Use a modern Ubuntu version compatible with the Matlab version to get more modern library versions when we use compiled code with the Matlab tests.

dist: bionic
# Matlab R2020a libstdc++ needs Ubuntu 18.04

language: matlab

matlab:
- latest

git:
- depth: 3
- quiet: true

addons:
  apt:
    packages:
    - gfortran
    - libhdf5-dev
  snaps:
  - name: cmake
    confinement: classic

before_script:
- export PATH=/snap/bin:$PATH

script:
- matlab -batch "r = runtests('IncludeSubfolders',true); assert(~isempty(r)); assertSuccess(r)"

Here we assumed the compiled project code for Matlab uses CMake, Fortran and HDF5.

Notes

For private projects that require offline CI, solutions include GitHub Actions self-hosted runner or self-hosted AppVeyor