[go: up one dir, main page]

Skip to content

Run MATLAB scripts, functions, and statements on a GitHub-hosted or self-hosted runner.

License

Notifications You must be signed in to change notification settings

jaouadnabti-eaton/run-command

 
 

Repository files navigation

Action for Running MATLAB Commands

The Run MATLAB Command action enables you to execute MATLAB® scripts, functions, or statements on a self-hosted or GitHub®-hosted runner:

  • To use a self-hosted runner, you must set up a computer with MATLAB (R2013b or later) as your runner. The runner uses the topmost MATLAB version on the system path to execute your workflow.

  • To use a GitHub-hosted runner, you must include the Setup MATLAB action in your workflow to set up MATLAB on the runner. Currently, this action is available only for public projects. It does not set up transformation products, such as MATLAB Coder™ and MATLAB Compiler™.

Examples

Use the Run MATLAB Command action to run MATLAB scripts, functions, and statements. You can use this action to flexibly customize your test run or add a step in MATLAB to your workflow.

Run MATLAB Script on Self-Hosted Runner

Use a self-hosted runner to run the commands in a file named myscript.m in the root of your repository.

name: Run MATLAB Script on Self-Hosted Runner
on: [push]
jobs:
  my-job:
    name: Run MATLAB Script
    runs-on: self-hosted
    steps:
      - name: Check out repository
        uses: actions/checkout@v3
      - name: Run script
        uses: matlab-actions/run-command@v1
        with:
          command: myscript

Run MATLAB Commands on GitHub-Hosted Runner

Before you run MATLAB code or Simulink models on a GitHub-hosted runner, first use the Setup MATLAB action. The action sets up your specified MATLAB release (R2020a or later) on a Linux® virtual machine. If you do not specify a release, the action sets up the latest release of MATLAB.

For example, set up the latest release of MATLAB on a GitHub-hosted runner, and then use the Run MATLAB Command action to execute your MATLAB commands.

name: Run MATLAB Commands on GitHub-Hosted Runner
on: [push]
jobs:
  my-job:
    name: Run MATLAB Commands
    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 commands
        uses: matlab-actions/run-command@v1
        with:
          command: results = runtests, assertSuccess(results);

Run MATLAB Command

When you define your workflow in the .github/workflows directory of your repository, specify the Run MATLAB Command action as matlab-actions/run-command@v1. The action requires an input and also accepts an optional input.

Input Description
command (Required) Script, function, or statement to execute. If the value of command is the name of a MATLAB script or function, do not specify the file extension. If you specify more than one script, function, or statement, use a comma or semicolon to separate them.
MATLAB exits with exit code 0 if the specified script, function, or statement executes successfully without error. Otherwise, MATLAB terminates with a nonzero exit code, which causes the build to fail. To fail the build in certain conditions, use the assert or error function.
Example: command: myscript
Example: command: results = runtests, assertSuccess(results);
startup-options (Optional) MATLAB startup options. If you specify more than one option, use a space to separate them. For more information about startup options, see Commonly Used Startup Options.
Using this input to specify the -batch or -r option is not supported.
Example: startup-options: -nojvm
Example: startup-options: -nojvm -logfile "output.log"

When you use this action, all of the required files must be on the MATLAB search path. If your script or function is not in the root of your repository, you can use the addpath, cd, or run function to put it on the path. For example, to run myscript.m in a folder named myfolder located in the root of the repository, you can specify command like this:

command: addpath("myfolder"), myscript

Notes

  • In MATLAB R2019a and later, the Run MATLAB Command action uses the -batch option to start MATLAB noninteractively. Preferences do not persist across different MATLAB sessions launched with the -batch option. To run code that requires the same preferences, use a single action.
  • When you use the Run MATLAB Command action, you execute third-party code that is licensed under separate terms.

See Also

Contact Us

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

About

Run MATLAB scripts, functions, and statements on a GitHub-hosted or self-hosted runner.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 92.7%
  • Shell 6.2%
  • JavaScript 1.1%