You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-28Lines changed: 65 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
# Action for Setting Up MATLAB
2
2
3
-
The [Setup MATLAB](#set-up-matlab) action enables you to run MATLAB®code and Simulink®models with a specific version of MATLAB. 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) 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.
4
4
5
5
## Examples
6
6
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.
7
7
8
-
### Run MATLAB Build on GitHub-Hosted Runner
9
-
Use a [GitHub®-hosted runner](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners) to run a task and its depended-on tasks that are specified in a file named `buildfile.m` in the root of your repository. Because the `"test"` task in this example runs the tests authored using the MATLAB unit testing framework as well as Simulink Test™, you must set up Simulink and Simulink Test in addition to MATLAB. To run tasks using the MATLAB build tool, specify the [Run MATLAB Build](https://github.com/matlab-actions/run-build/) action in your workflow.
8
+
### Run Default Tasks in Build File
9
+
Using the latest release of MATLAB on a GitHub-hosted runner, run the default tasks in a build file named `buildfile.m` in the root of your repository as well as all the tasks on which they depend. To set up the latest release of MATLAB on the runner, specify the **Setup MATLAB** action in your workflow. To run the tasks, specify the [Run MATLAB Build](https://github.com/matlab-actions/run-build/) action.
10
10
11
11
```yaml
12
-
name: Run MATLAB Build on GitHub-Hosted Runner
12
+
name: Run Default Tasks in Build File
13
13
on: [push]
14
14
jobs:
15
15
my-job:
@@ -20,41 +20,41 @@ jobs:
20
20
uses: actions/checkout@v4
21
21
- name: Set up MATLAB
22
22
uses: matlab-actions/setup-matlab@v2
23
-
with:
24
-
products: Simulink Simulink_Test
25
23
- name: Run build
26
24
uses: matlab-actions/run-build@v2
27
-
with:
28
-
tasks: test
29
25
```
30
26
31
-
### Run MATLAB Tests on GitHub-Hosted Runner
32
-
Use a GitHub-hosted runner to run the tests in your [MATLAB project](https://www.mathworks.com/help/matlab/projects.html) and generate test results in JUnit-style XML format and code coverage results in Cobertura XML format. To run the tests and generate the artifacts, specify the [Run MATLAB Tests](https://github.com/matlab-actions/run-tests/) action in your workflow.
27
+
### Run MATLAB and Simulink Tests
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`.
Use a GitHub-hosted runner to run the commands in a file named `myscript.m` in the root of your repository. To run the script, specify the [Run MATLAB Command](https://github.com/matlab-actions/run-command/) action in your workflow.
53
+
### Run MATLAB Script
54
+
Using the latest release of MATLAB on a GitHub-hosted runner, run a script named `myscript.m` in the root of your repository. To set up the latest release of MATLAB on the runner, specify the **Setup MATLAB** action in your workflow. To run the script, specify the [Run MATLAB Command](https://github.com/matlab-actions/run-command/) action.
55
55
56
56
```yaml
57
-
name: Run MATLAB Script on GitHub-Hosted Runner
57
+
name: Run MATLAB Script
58
58
on: [push]
59
59
jobs:
60
60
my-job:
@@ -71,11 +71,39 @@ jobs:
71
71
command: myscript
72
72
```
73
73
74
-
### Run MATLAB Build Across Different Platforms
74
+
### 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.
76
+
77
+
To use a MATLAB batch licensing token:
78
+
79
+
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
+
2. Map the secret to an environment variable named `MLM_LICENSE_TOKEN` in your workflow.
81
+
82
+
For example, use the latest release of MATLAB on a GitHub-hosted runner to run the tests in your private project. To install 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.
83
+
84
+
```YAML
85
+
name: Use MATLAB Batch Licensing Token
86
+
on: [push]
87
+
env:
88
+
MLM_LICENSE_TOKEN: ${{ secrets.MyToken }}
89
+
jobs:
90
+
my-job:
91
+
name: Run MATLAB Tests in Private Project
92
+
runs-on: ubuntu-latest
93
+
steps:
94
+
- name: Check out repository
95
+
uses: actions/checkout@v4
96
+
- name: Set up MATLAB
97
+
uses: matlab-actions/setup-matlab@v2
98
+
- name: Run tests
99
+
uses: matlab-actions/run-tests@v2
100
+
```
101
+
102
+
### Build Across Multiple Platforms
75
103
The **Setup MATLAB** action supports the Linux, Windows, and macOS platforms. Define a matrix of job configurations to run a build using the MATLAB build tool on all the supported platforms. This workflow runs three jobs, one for each value in the variable `os`. For more information about matrices, see [Using a matrix for your jobs](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs).
76
104
77
105
```YAML
78
-
name: Run MATLAB Build Across Different Platforms
106
+
name: Build Across Multiple Platforms
79
107
on: [push]
80
108
jobs:
81
109
my-job:
@@ -100,12 +128,21 @@ When you define your workflow in the `.github/workflows` directory of your repos
100
128
101
129
| Input | Description |
102
130
|-----------|-------------|
103
-
| `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>**Example**: `release: R2023a`<br/>**Example**: `release: latest`</p>
104
-
| `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. For example, `products: Deep_Learning_Toolbox` sets up Deep Learning Toolbox™ in addition to MATLAB.</p><p>The action uses [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md) (`mpm`) to set up products. For a list of supported products and their correctly formatted names, see [Product Installation Options](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md#product-installation-options).</p> <p>:information_source: **Note:** If you use this input to set up transformation products, such as MATLAB Coder™ and MATLAB Compiler™, the action does not automatically license such products for you.<p/><p>**Example**: `products: Simulink`</br>**Example:** `products: Simulink Deep_Learning_Toolbox`</p>
105
-
| `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>
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>**Example**: `release: R2023b`<br/>**Example**: `release: latest`</p>
132
+
| `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. For example, `products: Deep_Learning_Toolbox` sets up Deep Learning Toolbox™ in addition to MATLAB.</p><p>The action uses [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md) (`mpm`) to set up products. For a list of supported products and their formatted names, see [Product Installation Options](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md#product-installation-options).</p><p>For an example of how to use the `products` input, see [Run MATLAB and Simulink Tests](#run-matlab-and-simulink-tests).</p><p>**Example**: `products: Simulink`<br/>**Example:** `products: Simulink Deep_Learning_Toolbox`</p>
133
+
| `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
+
135
+
#### Licensing
136
+
Product licensing for your workflow depends on your project visibility as well as the type of products to set up:
137
+
138
+
- Public project — If your workflow does not include transformation products, such as MATLAB Coder and MATLAB Compiler, then the action automatically licenses any products that you set up. If your workflow includes transformation products, you can request 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) by submitting the [MATLAB Batch Licensing Pilot](https://www.mathworks.com/support/batch-tokens.html) form.
139
+
- Private project — The action does not automatically license any products for you. You can request a batch licensing token by submitting the [MATLAB Batch Licensing Pilot](https://www.mathworks.com/support/batch-tokens.html) form.
140
+
141
+
To use a MATLAB batch licensing token, first set it as a [secret](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions). Then, map the secret to an environment variable named `MLM_LICENSE_TOKEN` in your workflow. For an example, see [Use MATLAB Batch Licensing Token](#use-matlab-batch-licensing-token).
106
142
107
143
## Notes
108
-
When you use the **Setup MATLAB** action, you execute third-party code that is licensed under separate terms.
144
+
- The **Setup MATLAB** action automatically includes the [MATLAB batch licensing executable](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/alternates/non-interactive/MATLAB-BATCH.md) (`matlab-batch`). To use a MATLAB batch licensing token in a workflow that does not use this action, you must first download the executable and add it to the system path.
145
+
- When you use the **Setup MATLAB** action, you execute third-party code that is licensed under separate terms.
109
146
110
147
## See Also
111
148
- [Action for Running MATLAB Builds](https://github.com/matlab-actions/run-build/)
@@ -114,4 +151,4 @@ When you use the **Setup MATLAB** action, you execute third-party code that is l
114
151
- [Continuous Integration with MATLAB and Simulink](https://www.mathworks.com/solutions/continuous-integration.html)
115
152
116
153
## Contact Us
117
-
If you have any questions or suggestions, please contact MathWorks at [continuous-integration@mathworks.com](mailto:continuous-integration@mathworks.com).
154
+
If you have any questions or suggestions, contact MathWorks at [continuous-integration@mathworks.com](mailto:continuous-integration@mathworks.com).
0 commit comments