matlab-actions / setup-matlab

Set up your GitHub Actions workflow with a specific version of MATLAB.
BSD 3-Clause "New" or "Revised" License
76 stars 10 forks source link

Run MATLAB from shell with v2? #89

Closed rdzman closed 8 months ago

rdzman commented 8 months ago

With v1 I was able to configure my CI to use the same workflow to run my own custom test environment in both MATLAB and Octave, by launching them via the command line. For MATLAB, I used matlab -batch "myscript".

After switching to v2, I get a "License checkout failed" error when attempting to launch MATLAB from a shell.

License checkout failed.
License Manager Error -1
The license file cannot be found.

Troubleshoot this issue by visiting: 
https://www.mathworks.com/support/lme/1

Diagnostic Information:
Feature: MATLAB 
License path: /home/runner/.matlab/R2023b_licenses:/opt/hostedtoolcache/MATLAB/2023.2.999/x64/licenses/license.dat:/opt/hostedtoolcache/MATLAB/2023.2.999/x64/licenses 

Can I add a -c licensefile to the command to make it work? If so, where is the license file? If not, please tell me how I can successfully launch MATLAB from a shell script to run my custom tests.

And keep in mind that the reason I am not able to use matlab-actions/run-command is because I'm using the same workflow to run my custom test scripts on Octave. I have a lot of projects with this setup, so redesigning all of them would be prohibitive.

Any help is appreciated.

mcafaro commented 8 months ago

Hi @rdzman,

At the moment, the run-*@v2 actions (i.e. run-command@v2, run-tests@v2, and run-build@v2) are the only supported ways to run and license MATLAB for open source projects with matlab-actions/setup-matlab@v2.

We are considering ways to support shell-based workflows in the future but I do not have anything official to give you now. The run actions use a "run-matlab-command" binary behind-the-scenes that you could use as a stopgap for shell-based workflows but please note the "run-matlab-command" binary is undocumented and subject to change in the future.

- name: Setup MATLAB
  uses: matlab-actions/setup-matlab@v2
- name: Get run-matlab-command
  run: |
    wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command
    chmod +x /usr/local/bin/run-matlab-command
- name: Run MATLAB Command
  run: run-matlab-command "disp('hello world')"
rdzman commented 8 months ago

Thank you. This appears to solve the problem ... with one minor issue.

With v1, there were quite a few Matlab Toolboxes included, but when I run v2 via run-matlab-command, it is missing those toolboxes. In particular, some of my tests depend on the Optimization Toolbox and some on the Statistics and Machine Learning Toolbox.

Is there a way to include these via run-matlab-command?

mcafaro commented 8 months ago

With setup-matlab@v2, you need to specify what products you want to install with the "products" input as shown below.

- name: Set up MATLAB
  uses: matlab-actions/setup-matlab@v2-beta
  with:
    products: Optimization_Toolbox Statistics_and_Machine_Learning_Toolbox

These details will be in the action documentation when v2 is officially released shortly.

rdzman commented 8 months ago

Thank you! Exactly what I needed.

Please do let me know if/when this run-matlab-command approach is superseded by an officially supported alternative for shell-based workflows.