acampbel / Test_Repo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MATLAB CI Examples

This repository shows how to run MATLAB tests with a variety of continuous integration systems.

Badges

Jenkins

TBD

Azure DevOps

Azure DevOps Build Status Azure DevOps Coverage Blog with helpful information for setting up Azure DevOps badges

CircleCI

CircleCI Build Badge CircleCI documentation for setting up badges

Travis CI

Travis CI Build Status Travis CI documentation for setting up badges

GitHub Actions

MATLAB GitHub Actions documentation for setting up badges

About the code

The repository includes these files:

File Path Description
main/sierpinski.m The sierpinski function returns a matrix representing an image of a Sierpinski carpet fractal.
test/TestCarpet.m The TestCarpet class tests the sierpinski function.
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.
Jenkinsfile The Jenkinsfile file defines the pipeline that runs on Jenkins.
.travis.yml The .travis.yml file defines the pipeline that runs on Travis CI.
.github/workflows/ci.yml The ci.yml file defines the pipeline that runs on GitHub Actions.

CI configuration files

Azure DevOps

pool:
  vmImage: Ubuntu 16.04
steps:
  - task: InstallMATLAB@0
  - task: RunMATLABTests@0
    inputs:
      sourceFolder: main

  # As an alternative to RunMATLABTests, you can use RunMATLABCommand to execute a MATLAB script, function, or statement.
  # - task: RunMATLABCommand@0
  #   inputs:
  #     command: addpath('main'); results = runtests('IncludeSubfolders', true); assertSuccess(results);

CircleCI

version: 2.1
orbs:
  matlab: mathworks/matlab@0
  codecov: codecov/codecov@1
jobs:
  build:
    machine:
      image: ubuntu-1604:201903-01
    steps:
      - checkout
      - matlab/install
      - matlab/run-tests:
          source-folder: main

      # As an alternative to run-tests, you can use run-command to execute a MATLAB script, function, or statement.
      # - matlab/run-command:
      #     command: addpath('main'); results = runtests('IncludeSubfolders', true); assertSuccess(results);

Jenkins

pipeline {
  agent any
  stages {
    stage('Run MATLAB Tests') {
      steps {
        runMATLABTests(
          sourceFolder: 'main'
        )

        // As an alternative to runMATLABTests, you can use runMATLABCommand to execute a MATLAB script, function, or statement.
        // runMATLABCommand "addpath('main'); results = runtests('IncludeSubfolders', true); assertSuccess(results);"
      }
    }
  }
}

Travis CI

language: matlab
script: matlab -batch "addpath('main'); results = runtests('IncludeSubfolders', true); assertSuccess(results);"

GitHub Actions

# This is a basic workflow to help you get started with MATLAB Actions

name: MATLAB

# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      
      # Sets up MATLAB on the GitHub Actions runner
      - name: Setup MATLAB
        uses: matlab-actions/setup-matlab@v0

      # Runs a set of commands using the runners shell
      - name: Run all tests
        uses: matlab-actions/run-tests@v0
        with:
          source-folder: main

      # As an alternative to run-tests, you can use run-command to execute a MATLAB script, function, or statement.
      #- name: Run all tests
      #  uses: matlab-actions/run-command@v0
      #  with:
      #    command: addpath('main'); results = runtests('IncludeSubfolders', true); assertSuccess(results);

Caveats

  • Currently, MATLAB builds on Travis CI are available only for public projects. MATLAB builds on Azure DevOps, CircleCI, and GitHub Actions that use CI service-hosted agents are also available only for public projects. However, these integrations can be used in private projects that leverage self-hosted runners/agents.

Links

Contact Us

If you have any questions or suggestions, please contact MathWorks at continuous-integration@mathworks.com.

About


Languages

Language:MATLAB 100.0%