|
1 | 1 | # Action for Setting Up MATLAB
|
2 | 2 |
|
3 |
| -The [Setup MATLAB](#set-up-matlab) action enables you to set up MATLAB® and other MathWorks® products on a [GitHub®-hosted](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners) runner. When you specify this action as part of your workflow, the action sets up your preferred MATLAB release (R2021a or later) on a Linux®, Windows®, or macOS runner. If you do not specify a release, the action sets up the latest release of MATLAB. As part of the setup process, the action prepends MATLAB to the `PATH` system environment variable. |
| 3 | +The [Setup MATLAB](#set-up-matlab) action enables you to set up MATLAB® and other MathWorks® products on a [GitHub®-hosted](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners) (Linux®, Windows®, or macOS) runner or [self-hosted](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners) UNIX® (Linux or macOS) runner. When you specify this action as part of your workflow, the action sets up your preferred MATLAB release (R2021a or later) on the runner. If you do not specify a release, the action sets up the latest release of MATLAB. As part of the setup process, the action prepends MATLAB to the `PATH` system environment variable. |
| 4 | + |
| 5 | +>**Note:** For GitHub-hosted runners, the **Setup MATLAB** action automatically includes the dependencies required to run MATLAB and other MathWorks products. However, if you are using a self-hosted runner, you must ensure that the required dependencies are available on your runner. For details, see [Required Software on Self-Hosted Runners](#required-software-on-self-hosted-runners). |
4 | 6 |
|
5 | 7 | ## Examples
|
6 | 8 | Once you set up MATLAB on a runner, you can build and test your MATLAB project as part of your workflow. To execute code on the runner, include the [Run MATLAB Build](https://github.com/matlab-actions/run-build/), [Run MATLAB Tests](https://github.com/matlab-actions/run-tests/), or [Run MATLAB Command](https://github.com/matlab-actions/run-command/) action in your workflow.
|
|
25 | 27 | ```
|
26 | 28 |
|
27 | 29 | ### Run Tests in Parallel
|
28 |
| -Run your MATLAB and Simulink tests in parallel (requires Parallel Computing Toolbox™) using the latest release of the required products on a GitHub-hosted runner. To set up the latest release of MATLAB, Simulink, Simulink Test, and Parallel Computing Toolbox on the runner, specify the **Setup MATLAB** action with its `products` input in your workflow. To run the tests in parallel, specify the [Run MATLAB Tests](https://github.com/matlab-actions/run-tests/) action with its `use-parallel` input specified as `true`. |
| 30 | +Run your MATLAB and Simulink® tests in parallel (requires Parallel Computing Toolbox™) using the latest release of the required products on a GitHub-hosted runner. To set up the latest release of MATLAB, Simulink, Simulink Test, and Parallel Computing Toolbox on the runner, specify the **Setup MATLAB** action with its `products` input in your workflow. To run the tests in parallel, specify the [Run MATLAB Tests](https://github.com/matlab-actions/run-tests/) action with its `use-parallel` input specified as `true`. |
29 | 31 |
|
30 | 32 | ```YAML
|
31 | 33 | name: Run Tests in Parallel
|
@@ -72,14 +74,16 @@ jobs:
|
72 | 74 | ```
|
73 | 75 |
|
74 | 76 | ### Use MATLAB Batch Licensing Token
|
75 |
| -On a GitHub-hosted runner, you need a [MATLAB batch licensing token](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/alternates/non-interactive/MATLAB-BATCH.md#matlab-batch-licensing-token) if your project is private or if your workflow includes transformation products, such as MATLAB Coder™ and MATLAB Compiler™. Batch licensing tokens are strings that enable MATLAB to start in noninteractive environments. You can request a token by submitting the [MATLAB Batch Licensing Pilot](https://www.mathworks.com/support/batch-tokens.html) form. |
| 77 | +When you define a workflow using the **Setup MATLAB** action, you need a [MATLAB batch licensing token](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/alternates/non-interactive/MATLAB-BATCH.md#matlab-batch-licensing-token) if your project is private or if your workflow includes transformation products, such as MATLAB Coder™ and MATLAB Compiler™. Batch licensing tokens are strings that enable MATLAB to start in noninteractive environments. You can request a token by submitting the [MATLAB Batch Licensing Pilot](https://www.mathworks.com/support/batch-tokens.html) form. |
76 | 78 |
|
77 | 79 | To use a MATLAB batch licensing token:
|
78 | 80 |
|
79 | 81 | 1. Set the token as a secret. For more information about secrets, see [Using secrets in GitHub Actions](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions).
|
80 | 82 | 2. Map the secret to an environment variable named `MLM_LICENSE_TOKEN` in your workflow.
|
81 | 83 |
|
82 |
| -For example, use the latest release of MATLAB on a GitHub-hosted runner to run the tests in your private project. To set up the latest release of MATLAB on the runner, specify the **Setup MATLAB** action in your workflow. To run the tests, specify the [Run MATLAB Tests](https://github.com/matlab-actions/run-tests/) action. In this example, `MyToken` is the name of the secret that holds the batch licensing token. |
| 84 | +For example, define a workflow that runs the tests in your private project by using the latest release of MATLAB on a self-hosted UNIX runner: |
| 85 | +- To set up the latest release of MATLAB on the self-hosted UNIX runner, specify the **Setup MATLAB** action in your workflow. (The runner must include all the dependencies required to run MATLAB.) |
| 86 | +- To run the tests, specify the [Run MATLAB Tests](https://github.com/matlab-actions/run-tests/) action. License MATLAB to run the tests by mapping a secret to the `MLM_LICENSE_TOKEN` environment variable in your workflow. In this example, `MyToken` is the name of the secret that holds the batch licensing token. |
83 | 87 |
|
84 | 88 | ```YAML
|
85 | 89 | name: Use MATLAB Batch Licensing Token
|
|
89 | 93 | jobs:
|
90 | 94 | my-job:
|
91 | 95 | name: Run MATLAB Tests in Private Project
|
92 |
| - runs-on: ubuntu-latest |
| 96 | + runs-on: self-hosted |
93 | 97 | steps:
|
94 | 98 | - name: Check out repository
|
95 | 99 | uses: actions/checkout@v4
|
@@ -128,10 +132,23 @@ When you define your workflow in the `.github/workflows` directory of your repos
|
128 | 132 |
|
129 | 133 | | Input | Description |
|
130 | 134 | |-----------|-------------|
|
131 |
| -| `release` | <p>(Optional) MATLAB release to set up. You can specify R2021a or a later release. By default, the value of `release` is `latest`, which corresponds to the latest release of MATLAB.</p><p><ul><li>To set up the latest update of a release, specify only the release name, for example, `R2023b`.</li><li>To set up a specific update release, specify the release name with an update number suffix, for example, `R2023bU4`.</li><li>To set up a release without updates, specify the release name with an update 0 or general release suffix, for example, `R2023bU0` or `R2023bGR`.</li></ul></p><p>**Example**: `release: R2023b`<br/>**Example**: `release: latest`<br/>**Example**: `release: R2023bU4`</p> |
| 135 | +| `release` | <p>(Optional) MATLAB release to set up. You can specify R2021a or a later release. By default, the value of `release` is `latest`, which corresponds to the latest release of MATLAB.</p><p><ul><li>To set up the latest update of a release, specify only the release name, for example, `R2024a`.</li><li>To set up a specific update release, specify the release name with an update number suffix, for example, `R2024aU4`.</li><li>To set up a release without updates, specify the release name with an update 0 or general release suffix, for example, `R2024aU0` or `R2024aGR`.</li></ul></p><p>**Example**: `release: R2024a`<br/>**Example**: `release: latest`<br/>**Example**: `release: R2024aU4`</p> |
132 | 136 | | `products` | <p>(Optional) Products to set up in addition to MATLAB, specified as a list of product names separated by spaces. You can specify `products` to set up most MathWorks products and support packages. The action uses [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md) (`mpm`) to set up products.</p><p>For a list of supported products, open the input file for your preferred release from the [`mpm-input-files`](https://github.com/mathworks-ref-arch/matlab-dockerfile/tree/main/mpm-input-files) folder on GitHub. Specify products using the format shown in the input file, excluding the `#product.` prefix. For example, to set up Deep Learning Toolbox™ in addition to MATLAB, specify `products: Deep_Learning_Toolbox`.</p><p>For an example of how to use the `products` input, see [Run Tests in Parallel](#run-tests-in-parallel).</p><p>**Example**: `products: Simulink`<br/>**Example:** `products: Simulink Deep_Learning_Toolbox`</p>
|
133 | 137 | | `cache` | <p>(Optional) Option to enable caching with GitHub Actions, specified as `false` or `true`. By default, the value is `false` and the action does not store MATLAB and the specified products in a GitHub Actions cache for future use. For more information about caching with GitHub Actions, see [Caching dependencies to speed up workflows](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows).</p><p>**Example**: `cache: true`</p>
|
134 | 138 |
|
| 139 | +#### Required Software on Self-Hosted Runners |
| 140 | +Before using the **Setup MATLAB** action to set up MATLAB and other MathWorks products on a self-hosted UNIX runner, verify that the required software is installed on your runner. |
| 141 | + |
| 142 | +##### Linux |
| 143 | +If you are using a Linux runner, verify that the following software is installed on your runner: |
| 144 | +- Third-party packages required to run the `mpm` command — To view the list of `mpm` dependencies, refer to the Linux section of [Get MATLAB Package Manager](https://www.mathworks.com/help/install/ug/get-mpm-os-command-line.html). |
| 145 | +- All MATLAB dependencies — To view the list of MATLAB dependencies, go to the [MATLAB Dependencies](https://github.com/mathworks-ref-arch/container-images/tree/main/matlab-deps) repository on GitHub. Then, open the `<release>/<system>/base-dependencies.txt` file for your MATLAB release and your runner's operating system. |
| 146 | + |
| 147 | +##### macOS |
| 148 | +If you are using a macOS runner with an Apple silicon processor, verify that Java® Runtime Environment (JRE™) is installed on your runner. For information about this requirement and to get a compatible JRE version, see [MATLAB on Apple Silicon Macs](https://www.mathworks.com/support/requirements/apple-silicon.html). |
| 149 | + |
| 150 | +>**Tip:** One convenient way to include the required dependencies on a self-hosted runner is to specify the [MATLAB Dependencies container image on Docker® Hub](https://hub.docker.com/r/mathworks/matlab-deps) in your workflow. |
| 151 | + |
135 | 152 | #### Licensing
|
136 | 153 | Product licensing for your workflow depends on your project visibility as well as the type of products to set up:
|
137 | 154 |
|
|
0 commit comments