Skip to content

Merge v2-beta changes to main #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 52 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
7e5f3a5
Invoke installer for private repo support
jwpereira Feb 24, 2021
6a3aaf9
Disable automatic activation
jwpereira Feb 24, 2021
05bdce8
Fix failing unit test to account for addition call
jwpereira Feb 24, 2021
c74b56f
Add environment variables to workflow
jwpereira Feb 24, 2021
9d1a304
Disable R2020a workflow; only R2020b for now
jwpereira Feb 25, 2021
82c7ee1
Merge pull request #11 from matlab-actions/jpereira/pilot-enable
jwpereira Feb 25, 2021
2816693
Build 82c7ee1
jwpereira Feb 25, 2021
ae84399
Merge branch 'main' into private-repo-pilot
jwpereira Mar 15, 2021
508c6b7
Merge branch 'main' into jpereira/update-pilot
jwpereira Jul 1, 2021
6a6f85e
Build for v1.0.1
jwpereira Jul 1, 2021
b0810e9
Remove -r from BaT workflow
jwpereira Jul 1, 2021
7265f9e
Merge pull request #20 from matlab-actions/jpereira/update-pilot
jwpereira Jul 2, 2021
3485584
First change
acampbel Dec 23, 2021
b38afb3
Use mpm
acampbel Dec 23, 2021
3b78aad
Update action.yml
acampbel Dec 23, 2021
3fdd0cb
Update bat.yml
acampbel Dec 23, 2021
52ff614
Update install.ts
acampbel Dec 23, 2021
7b15906
Add to path
acampbel Dec 23, 2021
d2433ee
Update index.ts
acampbel Dec 23, 2021
40ff726
Pass in products
acampbel Dec 23, 2021
af89a2a
Add products input
acampbel Dec 23, 2021
9e00645
Update bat.yml
acampbel Dec 23, 2021
249748b
Cache installs
acampbel Dec 23, 2021
75127fe
Update bat.yml
acampbel Dec 23, 2021
ac47fac
Update install.ts
acampbel Dec 23, 2021
e8cc1e5
Update install.ts
acampbel Dec 23, 2021
3a32df3
Update install.ts
acampbel Dec 23, 2021
24a56e1
Update install.ts
acampbel Dec 23, 2021
09fdde4
Enable caching
acampbel Dec 23, 2021
e185a51
Cache in the right place
acampbel Dec 23, 2021
2bd5c45
Print the key
acampbel Dec 23, 2021
fc813c8
More display tweaks
acampbel Dec 23, 2021
e324049
Get the key right
acampbel Dec 23, 2021
0ef2d59
Cache
acampbel Dec 23, 2021
db4be46
merge changes for v2-beta (#50)
davidbuzinski Nov 11, 2022
4b8f191
v2-beta bugfix (#52)
davidbuzinski Dec 6, 2022
180c8e5
Update release info (#57)
davidbuzinski Feb 21, 2023
a01189a
Restrict supported releases (#65)
davidbuzinski May 9, 2023
77b0040
Add cache input to leverage Github Actions cache for v2 (#73)
davidbuzinski Oct 2, 2023
222b3da
Fix mpm mac windows v2-beta (#77)
davidbuzinski Dec 14, 2023
7e7f2de
Updated to check if sudo command is available
sameagen-MW Dec 18, 2023
4d8e316
Add tests
sameagen-MW Dec 18, 2023
e5233f4
Switch to registry.npmjs.org
sameagen-MW Dec 18, 2023
e464348
Clean up change
sameagen-MW Dec 18, 2023
5826302
Update copyright
sameagen-MW Dec 18, 2023
717c4e2
Update to check if which returns empty string
sameagen-MW Dec 18, 2023
fd8d40c
Merge pull request #78 from matlab-actions/no-sudo
sameagen-MW Dec 18, 2023
1209386
merge rc0 changes to mpm branch (#83)
davidbuzinski Jan 23, 2024
1a23c87
Update action node version (#84)
davidbuzinski Jan 25, 2024
fa9244d
resolve merge conflicts
davidbuzinski Jan 25, 2024
d6fadce
review comments
davidbuzinski Feb 5, 2024
3ba1bee
updating README in preparation for matlab-actions/setup-matlab@v2 (#88)
mw-hrastega Feb 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
},
{
"files": [
"**/*.ts"
],
"rules": {
"prefer-const": "off"
}
}
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}
60 changes: 42 additions & 18 deletions .github/workflows/bat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ jobs:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
- name: Perform npm tasks
run: npm run ci
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: built-action
path: |
Expand All @@ -23,30 +23,54 @@ jobs:
needs: bat
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
include:
- os: ubuntu-latest
release: latest
command: assert(~isempty(regexp(version('-release'), '\d{4}.')))
release: latest
products: Simulink Simulink_Test
check-matlab: matlabVer = ver('matlab'); assert(~isempty(matlabVer));
check-simulink: simulinkVer = ver('simulink'); assert(~isempty(simulinkVer));
- os: ubuntu-20.04
release: R2020a
command: assert(strcmp(version('-release'),'2020a'))
- os: macos-latest
release: latest
command: assert(~isempty(regexp(version('-release'), '\d{4}.')))
release: R2021bU2
products: |
MATLAB
Simulink
check-matlab: matlabVer = ver('matlab'); assert(strcmp(matlabVer.Release,'(R2021b)'));
check-simulink: simulinkVer = ver('simulink'); assert(strcmp(simulinkVer.Release,'(R2021b)'));
- os: windows-latest
release: latest
command: assert(~isempty(regexp(version('-release'), '\d{4}.')))
products: Simulink
check-matlab: matlabVer = ver('matlab'); assert(~isempty(matlabVer));
check-simulink: simulinkVer = ver('simulink'); assert(~isempty(simulinkVer));
- os: macos-latest
release: latest
products: Simulink
check-matlab: matlabVer = ver('matlab'); assert(~isempty(matlabVer));
check-simulink: simulinkVer = ver('simulink'); assert(~isempty(simulinkVer));
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: built-action
- name: Perform 'setup-matlab'
- name: Install selected products
id: setup_matlab
uses: ./
with:
release: ${{ matrix.release }}
- name: Run Sample MATLAB Command
uses: matlab-actions/run-command@v1
products: ${{ matrix.products }}
- name: Check matlabroot output is set
run: 'if [[ "${{ steps.setup_matlab.outputs.matlabroot }}" != *"MATLAB"* ]]; then exit 1; fi'
shell: bash
- name: Check MATLAB version
uses: matlab-actions/run-command@v2-rc0
with:
command: ${{ matrix.command }}
command: "${{ matrix.check-matlab }}"
- name: Check Simulink version
uses: matlab-actions/run-command@v2-rc0
with:
command: "${{ matrix.check-simulink }}"
- name: Check NoOp on 2nd install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need some sort of actual noop check in the future?

Copy link
Contributor Author

@davidbuzinski davidbuzinski Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that could be nice. Not immediately clear to me what that would look like

uses: ./
with:
release: ${{ matrix.release }}
products: ${{ matrix.products }}
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ jobs:
majorVersion=$(echo ${longVersion%.*.*})
minorVersion=$(echo ${longVersion%.*})

# Add the built artifacts. Using --force because dist/lib should be in
# Add the built artifacts. Using --force because dist should be in
# .gitignore
git add --force dist lib
git add --force dist

# Make the commit
MESSAGE="Build for $(git rev-parse --short HEAD)"
Expand Down
64 changes: 45 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Action for Setting Up MATLAB on GitHub-Hosted Runner
# Action for Setting Up MATLAB

Before you run MATLAB® code and Simulink® models on a [GitHub®-hosted](https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners) runner, first use the [Setup MATLAB](#set-up-matlab) action. The action sets up the specified MATLAB release on a Linux® virtual machine. If you do not specify a release, the action sets up the latest release of MATLAB.

The **Setup MATLAB** action is not supported on [self-hosted](https://docs.github.com/en/free-pro-team@latest/actions/hosting-your-own-runners/about-self-hosted-runners) runners. Currently, it is available only for public projects. It does not set up transformation products, such as MATLAB Coder™ and MATLAB Compiler™.
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 system PATH environment variable.

## Usage Examples
Once you set up MATLAB, 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.
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.

### Run MATLAB Build on GitHub-Hosted Runner
Set up a GitHub-hosted runner to run a specific task and its depended-on tasks that are specified in a file named `buildfile.m` in the root of your repository. To run tasks using the MATLAB build tool, include the [Run MATLAB Build](https://github.com/matlab-actions/run-build/) action in your workflow. This action is supported in MATLAB R2022b and later.
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, include the [Run MATLAB Build](https://github.com/matlab-actions/run-build/) action in your workflow.

```yaml
name: Run MATLAB Build on GitHub-Hosted Runner
Expand All @@ -19,17 +17,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
uses: matlab-actions/setup-matlab@v2
with:
products: Simulink Simulink_Test
- name: Run build
uses: matlab-actions/run-build@v1
uses: matlab-actions/run-build@v2
with:
tasks: test
```

### Run MATLAB Tests on GitHub-Hosted Runner
Set up a GitHub-hosted runner to run the tests in your [MATLAB project](https://www.mathworks.com/help/matlab/projects.html) and generate a JUnit test results report and a Cobertura code coverage report. To run the tests and generate the artifacts, include the [Run MATLAB Tests](https://github.com/matlab-actions/run-tests/) action in your workflow.
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, include the [Run MATLAB Tests](https://github.com/matlab-actions/run-tests/) action in your workflow.

```yaml
name: Run MATLAB Tests on GitHub-Hosted Runner
Expand All @@ -40,18 +40,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
uses: matlab-actions/setup-matlab@v2
- name: Run tests and generate artifacts
uses: matlab-actions/run-tests@v1
uses: matlab-actions/run-tests@v2
with:
test-results-junit: test-results/results.xml
code-coverage-cobertura: code-coverage/coverage.xml
```

### Run MATLAB Script on GitHub-Hosted Runner
Set up a GitHub-hosted runner to run the commands in a file named `myscript.m` in the root of your repository. To run the script, include the [Run MATLAB Command](https://github.com/matlab-actions/run-command/) action in your workflow.
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, include the [Run MATLAB Command](https://github.com/matlab-actions/run-command/) action in your workflow.

```yaml
name: Run MATLAB Script on GitHub-Hosted Runner
Expand All @@ -62,21 +62,47 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
uses: matlab-actions/setup-matlab@v2
- name: Run script
uses: matlab-actions/run-command@v1
uses: matlab-actions/run-command@v2
with:
command: myscript
```

### Run MATLAB Build Across Different Platforms
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).

```YAML
name: Run MATLAB Build on Different Platforms
on: [push]
jobs:
my-job:
name: Run MATLAB Build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
- name: Run build
uses: matlab-actions/run-build@v2
with:
tasks: test
```

## Set Up MATLAB
When you define your workflow in the `.github/workflows` directory of your repository, specify the **Setup MATLAB** action as `matlab-actions/setup-matlab@v1`. The action accepts an optional input.
When you define your workflow in the `.github/workflows` directory of your repository, specify the **Setup MATLAB** action as `matlab-actions/setup-matlab@v2`. The action accepts optional inputs.

| Input | Description |
|-----------|-------------|
| `release` | (Optional) MATLAB release to set up. You can specify R2020a or a later release. If you do not specify `release`, the action sets up the latest release of MATLAB.<br/>**Example**: ` release: R2023a`
| `release` | <p>(Optional) MATLAB release to set up. You can specify R2021a or a later release. If you do not specify `release`, the action defaults to `latest`, which represents the latest release of MATLAB.<p/><p>**Example**: `release: R2023a`<br/>**Example**: `release: latest`</p>
| `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&reg; products and support packages. For example, `products: Deep_Learning_Toolbox` sets up Deep Learning Toolbox&trade; 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`) for installing 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&trade; and MATLAB Compiler&trade;, the action does not automatically license such products for you.<p/><p>**Example**: `products: Simulink`</br>**Example:** `products: Simulink Deep_Learning_Toolbox`</p>
| `cache` | <p>(Optional) Option to enable caching with GitHub&reg; 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>

## Notes
When you use the **Setup MATLAB** action, you execute third-party code that is licensed under separate terms.
Expand Down
22 changes: 19 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 The MathWorks, Inc.
# Copyright 2020-2024 The MathWorks, Inc.

name: Setup MATLAB
description: >-
Expand All @@ -9,6 +9,22 @@ inputs:
MATLAB release to set up (R2020a or later)
required: false
default: latest
products:
description: >-
Array of products to install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Array" sounds like this should be specified as a YAML array. Perhaps "Products to install, specified as a list of product names separated by spaces"?

required: false
default: MATLAB
cache:
description: >-
Option to store MATLAB in the GitHub Actions cache, specified as false or true
required: false
default: false
outputs:
matlabroot:
description: >-
A full path to the folder where MATLAB is installed
runs:
using: node16
main: dist/index.js
using: node20
main: dist/setup/index.js
post: dist/cache-save/index.js
post-if: success()
Loading