Skip to content

Commit d45f97e

Browse files
Format and update actions (#71)
* add format checks and use setup-matlab@v3 * update common-utils
1 parent 51e8202 commit d45f97e

10 files changed

Lines changed: 162 additions & 104 deletions

File tree

.github/workflows/bat.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
node-version: 24
1515
- name: Perform npm tasks
1616
run: npm run ci
17-
- uses: actions/upload-artifact@v5
17+
- uses: actions/upload-artifact@v7
1818
with:
1919
name: built-action
2020
path: |
@@ -28,12 +28,12 @@ jobs:
2828
matrix:
2929
os: [ubuntu-latest, windows-latest, macos-latest, macos-14]
3030
steps:
31-
- uses: actions/download-artifact@v5
31+
- uses: actions/download-artifact@v8
3232
with:
3333
name: built-action
3434

3535
- name: Perform 'setup-matlab'
36-
uses: matlab-actions/setup-matlab@v2
36+
uses: matlab-actions/setup-matlab@v3
3737
with:
3838
products: MATLAB_Test
3939

.github/workflows/publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
git add package.json package-lock.json
3333
git commit -m "[skip ci] Bump $VERSION"
3434
git push origin HEAD:main
35-
35+
3636
# Now carry on, business as usual
3737
- name: Perform npm tasks
3838
run: npm run ci
@@ -61,15 +61,15 @@ jobs:
6161
6262
# Get the commit of the tag you just released
6363
commitHash=$(git rev-list -n 1 $longVersion)
64-
64+
6565
# Delete the old major and minor version tags locally
6666
git tag -d $majorVersion || true
6767
git tag -d $minorVersion || true
68-
68+
6969
# Make new major and minor version tags locally that point to the commit you got from the "git rev-list" above
7070
git tag -f $majorVersion $commitHash
7171
git tag -f $minorVersion $commitHash
72-
72+
7373
# Force push the new minor version tag to overwrite the old tag remotely
7474
echo "Pushing new tags"
7575
git push -f origin $longVersion

README.md

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,62 @@
33
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).
44

55
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+
67
- 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.
78
- 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.
89

910
## Examples
11+
1012
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.
1113

1214
### Run Default Tasks in Build File
15+
1316
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.
1417

1518
```yaml
1619
name: Run Default Tasks in Build File
1720
on: [push]
1821
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
2730
```
2831
2932
### Run Specified Task in Build File
33+
3034
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.
3135

3236
```yaml
3337
name: Run Specified Task in Build File
3438
on: [push]
3539
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
4852
```
4953

5054
### 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.
5257

5358
To use a MATLAB batch licensing token:
5459

5560
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.
5762

5863
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.
5964

@@ -76,26 +81,30 @@ jobs:
7681
```
7782

7883
## Run MATLAB Build
84+
7985
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.
8086

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>
87+
| Input | Description |
88+
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
89+
| `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> |
8692

8793
## 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.
9198

9299
## See Also
100+
93101
- [Action for Running MATLAB Tests](https://github.com/matlab-actions/run-tests/)
94102
- [Action for Running MATLAB Commands](https://github.com/matlab-actions/run-command)
95103
- [Action for Setting Up MATLAB](https://github.com/matlab-actions/setup-matlab/)
96104
- [Continuous Integration with MATLAB and Simulink](https://www.mathworks.com/solutions/continuous-integration.html)
97105

98106
## Feedback and Support
107+
99108
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).
100109

101110
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.

devel/contributing.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Contributing
2+
3+
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.

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default {
1414
},
1515
],
1616
},
17-
extensionsToTreatAsEsm: ['.ts'],
17+
extensionsToTreatAsEsm: [".ts"],
1818
transformIgnorePatterns: ["node_modules/(?!(@actions)/)"],
1919
moduleNameMapper: {
2020
"^(\\.{1,2}/.*)\\.js$": "$1",

0 commit comments

Comments
 (0)