GitHub Action
Setup MATLAB
Before you run MATLAB® code and Simulink® models on a GitHub®-hosted runner, first use the Setup MATLAB action. The action sets up the specified MATLAB release on a Linux® virtual machine. If you do not specify a release, the action sets up the latest release of MATLAB.
The Setup MATLAB action is not supported on self-hosted runners. Currently, it is available only for public projects. It does not set up transformation products, such as MATLAB Coder™ and MATLAB Compiler™.
Once you set up MATLAB, you can build and test your MATLAB project as part of your workflow. To execute code on the runner, include the Run MATLAB Build, Run MATLAB Tests, or Run MATLAB Command actions in your workflow.
Set up a GitHub-hosted runner to run a specific task and its depended-on tasks that are specified in a file named buildfile.m
in the root of your repository. To run tasks using the MATLAB build tool, include the Run MATLAB Build action in your workflow. This action is supported in MATLAB R2022b and later.
name: Run MATLAB Build on GitHub-Hosted Runner
on: [push]
jobs:
my-job:
name: Run MATLAB Build
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Run build
uses: matlab-actions/run-build@v1
with:
tasks: test
Set up a GitHub-hosted runner to run the tests in your MATLAB project and generate a JUnit test results report and a Cobertura code coverage report. To run the tests and generate the artifacts, include the Run MATLAB Tests action in your workflow.
name: Run MATLAB Tests on GitHub-Hosted Runner
on: [push]
jobs:
my-job:
name: Run MATLAB Tests and Generate Artifacts
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Run tests and generate artifacts
uses: matlab-actions/run-tests@v1
with:
test-results-junit: test-results/results.xml
code-coverage-cobertura: code-coverage/coverage.xml
Set up a GitHub-hosted runner to run the commands in a file named myscript.m
in the root of your repository. To run the script, include the Run MATLAB Command action in your workflow.
name: Run MATLAB Script on GitHub-Hosted Runner
on: [push]
jobs:
my-job:
name: Run MATLAB Script
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Run script
uses: matlab-actions/run-command@v1
with:
command: myscript
When you define your workflow in the .github/workflows
directory of your repository, specify the Setup MATLAB action as matlab-actions/setup-matlab@v1
. The action accepts an optional input.
Input | Description |
---|---|
release |
(Optional) MATLAB release to set up. You can specify R2020a or a later release. If you do not specify release , the action sets up the latest release of MATLAB.Example: R2022a |
When you use the Setup MATLAB action, you execute third-party code that is licensed under separate terms.
- Action for Running MATLAB Builds
- Action for Running MATLAB Tests
- Action for Running MATLAB Commands
- Continuous Integration with MATLAB and Simulink
If you have any questions or suggestions, please contact MathWorks® at [email protected].