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
+39-30Lines changed: 39 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,57 +3,62 @@
3
3
Starting in R2022b, the MATLAB® build tool provides a standard programming interface to create and run tasks in a uniform and efficient way. For example, you can create tasks that identify code issues, run tests, and package a toolbox in a single build file in your project root folder, and then invoke the build tool to run these tasks. For more information, see [Overview of MATLAB Build Tool](https://www.mathworks.com/help/matlab/matlab_prog/overview-of-matlab-build-tool.html).
4
4
5
5
The [Run MATLAB Build](#run-matlab-build) action enables you to invoke the MATLAB build tool on a [GitHub®-hosted](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners) or [self-hosted](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners) runner:
6
+
6
7
- To use a GitHub-hosted runner, include the [Setup MATLAB](https://github.com/matlab-actions/setup-matlab/) action in your workflow to set up your preferred MATLAB release (R2021a or later) on the runner.
7
8
- To use a self-hosted runner, set up a computer with MATLAB on its path and register the runner with GitHub Actions. (On self-hosted UNIX® runners, you can also use the **Setup MATLAB** action instead of having MATLAB already installed.) The runner uses the topmost MATLAB release on the system path to execute your workflow.
8
9
9
10
## Examples
11
+
10
12
Use the **Run MATLAB Build** action to run a build using the MATLAB build tool. You can use this action to run the tasks in your build file. (By default, the action looks for a build file named `buildfile.m` in the root of your repository.) To use the **Run MATLAB Build** action, you need MATLAB R2022b or a later release.
11
13
12
14
### Run Default Tasks in Build File
15
+
13
16
On a self-hosted runner that has MATLAB installed, 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 run the tasks, specify the **Run MATLAB Build** action in your workflow.
14
17
15
18
```yaml
16
19
name: Run Default Tasks in Build File
17
20
on: [push]
18
21
jobs:
19
-
my-job:
20
-
name: Run MATLAB Build
21
-
runs-on: self-hosted
22
-
steps:
23
-
- name: Check out repository
24
-
uses: actions/checkout@v6
25
-
- name: Run build
26
-
uses: matlab-actions/run-build@v3
22
+
my-job:
23
+
name: Run MATLAB Build
24
+
runs-on: self-hosted
25
+
steps:
26
+
- name: Check out repository
27
+
uses: actions/checkout@v6
28
+
- name: Run build
29
+
uses: matlab-actions/run-build@v3
27
30
```
28
31
29
32
### Run Specified Task in Build File
33
+
30
34
Using the latest release of MATLAB on a GitHub-hosted runner, run a task named `mytask`, specified in a build file named `buildfile.m` in the root of your repository, as well as all the tasks on which it depends. To set up the latest release of MATLAB on the runner, specify the [Setup MATLAB](https://github.com/matlab-actions/setup-matlab/) action in your workflow. To run the MATLAB build, specify the **Run MATLAB Build** action.
31
35
32
36
```yaml
33
37
name: Run Specified Task in Build File
34
38
on: [push]
35
39
jobs:
36
-
my-job:
37
-
name: Run MATLAB Build
38
-
runs-on: ubuntu-latest
39
-
steps:
40
-
- name: Check out repository
41
-
uses: actions/checkout@v6
42
-
- name: Set up MATLAB
43
-
uses: matlab-actions/setup-matlab@v3
44
-
- name: Run build
45
-
uses: matlab-actions/run-build@v3
46
-
with:
47
-
tasks: mytask
40
+
my-job:
41
+
name: Run MATLAB Build
42
+
runs-on: ubuntu-latest
43
+
steps:
44
+
- name: Check out repository
45
+
uses: actions/checkout@v6
46
+
- name: Set up MATLAB
47
+
uses: matlab-actions/setup-matlab@v3
48
+
- name: Run build
49
+
uses: matlab-actions/run-build@v3
50
+
with:
51
+
tasks: mytask
48
52
```
49
53
50
54
### Use MATLAB Batch Licensing Token
51
-
When you define a workflow using the [Setup MATLAB](https://github.com/matlab-actions/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 uses 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.
55
+
56
+
When you define a workflow using the [Setup MATLAB](https://github.com/matlab-actions/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 uses 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.
52
57
53
58
To use a MATLAB batch licensing token:
54
59
55
60
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).
56
-
2. Map the secret to an environment variable named `MLM_LICENSE_TOKEN` in your workflow.
61
+
2. Map the secret to an environment variable named `MLM_LICENSE_TOKEN` in your workflow.
57
62
58
63
For example, use the latest release of MATLAB on a GitHub-hosted runner to run a MATLAB build 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 MATLAB build, specify the **Run MATLAB Build** action. In this example, `MyToken` is the name of the secret that holds the batch licensing token.
59
64
@@ -76,26 +81,30 @@ jobs:
76
81
```
77
82
78
83
## Run MATLAB Build
84
+
79
85
When you define your workflow in the `.github/workflows` directory of your repository, specify the **Run MATLAB Build** action as `matlab-actions/run-build@v3`. The action accepts optional inputs.
80
86
81
-
Input | Description
82
-
------------------------- | ---------------
83
-
`tasks` | <p>(Optional) MATLAB build tasks to run, specified as a list of task names separated by spaces. If a task accepts arguments, enclose them in parentheses. If you do not specify `tasks`, the action runs the default tasks in your build file as well as all the tasks on which they depend. By default, the action looks for a build file named `buildfile.m` in the root of your repository.</p><p>MATLAB exits with exit code 0 if the tasks run without error. Otherwise, MATLAB terminates with a nonzero exit code, which causes the action to fail.</p><p>**Example:** `tasks: test`<br/>**Example:** `tasks: compile test`<br/>**Example:** `tasks: check test("myFolder",OutputDetail="concise") archive("source.zip")`</p>
84
-
`build-options`| <p>(Optional) MATLAB build options, specified as a list of options separated by spaces. The action supports the same [options](https://www.mathworks.com/help/matlab/ref/buildtool.html#mw_50c0f35e-93df-4579-963d-f59f2fba1dba) that you can pass to the `buildtool` command.</p><p>**Example:** `build-options: -continueOnFailure`<br/>**Example:** `build-options: -continueOnFailure -skip test`</p>
85
-
`startup-options` | <p>(Optional) MATLAB startup options, specified as a list of options separated by spaces. For more information about startup options, see [Commonly Used Startup Options](https://www.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html).</p><p>Using this input to specify the `-batch` or `-r` option is not supported.</p><p>**Example:** `startup-options: -nojvm`<br/>**Example:** `startup-options: -nojvm -logfile output.log`</p>
| `tasks` | <p>(Optional) MATLAB build tasks to run, specified as a list of task names separated by spaces. If a task accepts arguments, enclose them in parentheses. If you do not specify `tasks`, the action runs the default tasks in your build file as well as all the tasks on which they depend. By default, the action looks for a build file named `buildfile.m` in the root of your repository.</p><p>MATLAB exits with exit code 0 if the tasks run without error. Otherwise, MATLAB terminates with a nonzero exit code, which causes the action to fail.</p><p>**Example:** `tasks: test`<br/>**Example:** `tasks: compile test`<br/>**Example:** `tasks: check test("myFolder",OutputDetail="concise") archive("source.zip")`</p> |
90
+
| `build-options` | <p>(Optional) MATLAB build options, specified as a list of options separated by spaces. The action supports the same [options](https://www.mathworks.com/help/matlab/ref/buildtool.html#mw_50c0f35e-93df-4579-963d-f59f2fba1dba) that you can pass to the `buildtool` command.</p><p>**Example:** `build-options: -continueOnFailure`<br/>**Example:** `build-options: -continueOnFailure -skip test`</p> |
91
+
| `startup-options` | <p>(Optional) MATLAB startup options, specified as a list of options separated by spaces. For more information about startup options, see [Commonly Used Startup Options](https://www.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html).</p><p>Using this input to specify the `-batch` or `-r` option is not supported.</p><p>**Example:** `startup-options: -nojvm`<br/>**Example:** `startup-options: -nojvm -logfile output.log`</p> |
86
92
87
93
## Notes
88
-
* By default, when you use the **Run MATLAB Build** action, the root of your repository serves as the MATLAB startup folder. To run your MATLAB build using a different folder, specify the `-sd` startup option in the action.
89
-
* The **Run MATLAB Build** action uses the `-batch` option to invoke the [`buildtool`](https://www.mathworks.com/help/matlab/ref/buildtool.html) command. MATLAB settings do not persist across different MATLAB sessions launched with the `-batch` option. To run code that requires the same settings, use a single action.
90
-
* When you use the **Run MATLAB Build** action, you execute third-party code that is licensed under separate terms.
94
+
95
+
- By default, when you use the **Run MATLAB Build** action, the root of your repository serves as the MATLAB startup folder. To run your MATLAB build using a different folder, specify the `-sd` startup option in the action.
96
+
- The **Run MATLAB Build** action uses the `-batch` option to invoke the [`buildtool`](https://www.mathworks.com/help/matlab/ref/buildtool.html) command. MATLAB settings do not persist across different MATLAB sessions launched with the `-batch` option. To run code that requires the same settings, use a single action.
97
+
- When you use the **Run MATLAB Build** action, you execute third-party code that is licensed under separate terms.
91
98
92
99
## See Also
100
+
93
101
- [Action for Running MATLAB Tests](https://github.com/matlab-actions/run-tests/)
94
102
- [Action for Running MATLAB Commands](https://github.com/matlab-actions/run-command)
95
103
- [Action for Setting Up MATLAB](https://github.com/matlab-actions/setup-matlab/)
96
104
- [Continuous Integration with MATLAB and Simulink](https://www.mathworks.com/solutions/continuous-integration.html)
97
105
98
106
## Feedback and Support
107
+
99
108
If you encounter a product licensing issue, consider requesting a MATLAB batch licensing token to use in your workflow. For more information, see [Use MATLAB Batch Licensing Token](#use-matlab-batch-licensing-token).
100
109
101
110
If you have an enhancement request or other feedback about this action, create an issue on the [Issues](https://github.com/matlab-actions/run-build/issues) page.
Verify changes by running tests and building locally with the following command:
4
+
5
+
```
6
+
npm run ci
7
+
```
8
+
9
+
## Creating a New Release
10
+
11
+
Familiarize yourself with the best practices for [releasing and maintaining GitHub actions](https://docs.github.com/en/actions/creating-actions/releasing-and-maintaining-actions).
12
+
13
+
Changes should be made on a new branch. The new branch should be merged to the main branch via a pull request. Ensure that all of the CI pipeline checks and tests have passed for your changes.
14
+
15
+
After the pull request has been approved and merged to main, follow the Github process for [creating a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository). The release must follow semantic versioning (ex: vX.Y.Z). This will kick off a new pipeline execution, and the action will automatically be published to the GitHub Actions Marketplace if the pipeline finishes successfully. Check the [GitHub Marketplace](https://github.com/marketplace/actions/setup-matlab) and check the major version in the repository (ex: v1 for v1.0.0) to ensure that the new semantically versioned tag is available.
16
+
17
+
## Adding a Pre-Commit Hook
18
+
19
+
You can run all CI checks before each commit by adding a pre-commit hook. To do so, navigate to the repository root folder and run the following commands:
20
+
21
+
_bash (Linux/macOS)_
22
+
23
+
```sh
24
+
echo'#!/bin/sh'> .git/hooks/pre-commit
25
+
echo'npm run ci'>> .git/hooks/pre-commit
26
+
chmod +x .git/hooks/pre-commit
27
+
```
28
+
29
+
_Command Prompt (Windows)_
30
+
31
+
```cmd
32
+
echo #!/bin/sh > .git\hooks\pre-commit
33
+
echo npm run ci >> .git\hooks\pre-commit
34
+
```
35
+
36
+
_PowerShell (Windows)_
37
+
38
+
```pwsh
39
+
Set-Content .git\hooks\pre-commit '#!/bin/sh'
40
+
Add-Content .git\hooks\pre-commit 'npm run ci'
41
+
```
42
+
43
+
> **Note:**
44
+
> Git hooks are not version-controlled, so you need to set up this hook for each fresh clone of the repository.
0 commit comments