Skip to content

Commit

Permalink
Merge v2-beta changes to main (#86)
Browse files Browse the repository at this point in the history
* Invoke installer for private repo support

* Disable automatic activation

* Fix failing unit test to account for addition call

* Add environment variables to workflow

* Disable R2020a workflow; only R2020b for now

* Build 82c7ee1

* Build for v1.0.1

* Remove -r from BaT workflow

* First change

* Use mpm

* Update action.yml

* Update bat.yml

* Update install.ts

* Add to path

* Update index.ts

* Pass in products

* Add products input

* Update bat.yml

* Cache installs

* Update bat.yml

* Update install.ts

* Update install.ts

* Update install.ts

* Update install.ts

* Enable caching

* Cache in the right place

* Print the key

* More display tweaks

* Get the key right

* Cache

* merge changes for v2-beta (#50)

* v2-beta bugfix (#52)

* adding tests to catch bugs

* updating unit tests and source code

* updating workflow to use 2nd release

* fixing update level logic

* update level deps script workaround

* testing no-op on existing install

* add output

* Update bat.yml

* Update bat.yml

* Update bat.yml

* Update src/matlab.ts

Co-authored-by: Mark Cafaro <[email protected]>

* Update matlab.Release and removed usExisting from destination

* updated release info to fix inconsistency

* changed output name to matlabroot

* fixng pipeline syntax

* missing colon in yml

* updating naming and fixing missing simulink in bat workflow

* changing some variable names for clarity

Co-authored-by: Mark Cafaro <[email protected]>

* Update release info (#57)

* Restrict supported releases (#65)

* Add cache input to leverage Github Actions cache for v2 (#73)

* added cache-save and updated build. TODO: cache-restore

* added cache restore

* fixing release type conversion and bool type conversion

* add unit tests

* fixing path and cache hit issues

* add architecture to cache key and fix description

* addressed review feedback

* updated MatlabPath state 'type'

* updated missed copyrights

* changing back latest URL

* update cache input description

* Fix mpm mac windows v2-beta (#77)

* no more unzip mpm

* test no windows

* update url

* try with .exe extension?

* fail slow

* update url

* try cacheFile to fix file location

* take out bad secrets

* undo bad string interp

* trying fix linux mac

* use runcommand

* use runcommand

* try to specify directory

* error if no runner temp found

* Updated to check if sudo command is available

* Add tests

* Switch to registry.npmjs.org

* Clean up change

* Update copyright

* Update to check if which returns empty string

* merge rc0 changes to mpm branch (#83)

* initial commit

* npm audit fix

* add batch to tc

* chmod matlab-batch

* rearranging chmod

* still wrangling chmod

* remove pct

* remove PCT from defaults

* update tests

* cache fix for support packages

* make sure support packages path is in cachePaths if defined

* add log for supportPackagesPath

* capitalize release dir

* had wrong default dir

* testing windows thing

* remove log. use tmpdir for windows

* applying mpm fixes for mac & windows

* initial commit

* npm audit fix

* add batch to tc

* chmod matlab-batch

* rearranging chmod

* still wrangling chmod

* remove pct

* remove PCT from defaults

* update tests

* cache fix for support packages

* make sure support packages path is in cachePaths if defined

* add log for supportPackagesPath

* capitalize release dir

* had wrong default dir

* testing windows thing

* remove log. use tmpdir for windows

* applying mpm fixes for mac & windows

* Merge windows optimization to v2-rc0

* improve os specific cache dir implemenation

* try to link after install

* symlink wrong direction?

* update toolcache impl

* forgot .keep

* forgot dist

* fix typo

* debug

* more debug idk

* forgot recursive

* seeing whatever is going on with .complete file

* add tests for windows toolcache optimization

* prep for merge

* one more update before merge

* Update bat.yml to v2-rc0 for build until release

* address sam's feedback

* address mark's feedback

* fix error message

* switch statement sugar

Co-authored-by: Mark Cafaro <[email protected]>

* Accept any number of spaces in product list

Co-authored-by: Mark Cafaro <[email protected]>

---------

Co-authored-by: sameagen <[email protected]>
Co-authored-by: Mark Cafaro <[email protected]>

* Update action node version (#84)

* init update

* update bat.yml

* update bat.yml

* review comments

* updating README in preparation for matlab-actions/setup-matlab@v2 (#88)

* Update README.md

replacing v1 with v2

* removing text on platform restrictions

* replacing a verb

* updating the action description

* replacing 20b with 21a

* updating products description

* updating the cache description

* adding a placeholder section

* adding missing trademark symbol

* update the first example description

* removing a code block

* updating the last example description

* addressing review feedback

* Fix a typo.

Co-authored-by: Mark Cafaro <[email protected]>

---------

Co-authored-by: Mark Cafaro <[email protected]>

---------

Co-authored-by: Johan Pereira <[email protected]>
Co-authored-by: Andy Campbell <[email protected]>
Co-authored-by: Mark Cafaro <[email protected]>
Co-authored-by: sameagen <[email protected]>
Co-authored-by: sameagen-MW <[email protected]>
Co-authored-by: mw-hrastega <[email protected]>
  • Loading branch information
7 people authored Feb 6, 2024
1 parent 1de0dc8 commit 1d65426
Show file tree
Hide file tree
Showing 28 changed files with 4,355 additions and 7,611 deletions.
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
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&reg; code and Simulink&reg; models on a [GitHub&reg;-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&reg; 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&trade; and MATLAB Compiler&trade;.
The [Setup MATLAB](#set-up-matlab) action enables you to run MATLAB&reg; code and Simulink&reg; 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&reg;, Windows&reg;, or macOS&reg; 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&reg;-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&trade;, 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
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

0 comments on commit 1d65426

Please sign in to comment.