GitHub Action to configure MATLAB
Configures MATLAB by defining environment variables and optionally installing some 3rd party solvers.
Optionally installs the MATLAB interface for COIN-OR's IPOPT and
defines the IPOPT_PATH
environment variable to point to the directory
containing the IPOPT MEX- and M-files.
Optionally installs the MATLAB interface for OSQP and defines the
OSQP_PATH
environment variable to point to the directory containing the
OSQP MEX- and M-files.
Sets the following environment variables.
MATLAB_REL
set to the release name (e.g.'R2021a'
) of installed MATLABMATLAB_VER
set to the version (e.g.'9.1.0'
) of installed MATLAB,ML_NAME
set toMATLAB
ML_VER
set to same asMATLAB_VER
ML_CMD
set to/usr/local/MATLAB/${MATLAB_REL}/bin/matlab -nojvm -batch
ML_PATHVAR
set toMATLABPATH
IPOPT_PATH
set to$HOME/build/ipopt
(ifipopt
input istrue
)OSQP_PATH
set to$HOME/build/osqp-matlab
(ifosqp
input istrue
) (currently set equal to release name instead)
Note: This action depends on MATLAB being installed first, using
matlab-actions/setup-matlab
and currently, as of Aug 25, 2021, works
on ubuntu-18.04
, ubuntu-20.04
and ubuntu-latest
.
os
- (default'ubuntu-latest'
) required ifipopt
istrue
to distinguishubuntu-18.04
fromubuntu-20.04
/ubuntu-latest
nojvm
- (defaulttrue
) set tofalse
to exclude the-nojvm
flag from the definition ofML_CMD
ipopt
- (defaultfalse
) if true, include IPOPT interface in~/build/ipopt
ipopt-cached
- (defaultfalse
) install IPOPT interface from cached build, if true andipopt
istrue
osqp
- (defaultfalse
) if true, include OSQP interface, in~/build/osqp-matlab
osqp-cached
- (defaultfalse
) install OSQP interface from cached build, if true andosqp
istrue
None.
Default Inputs
steps:
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Configure MATLAB
uses: MATPOWER/action-configure-matlab@v1
- name: MATLAB ${{ env.ML_VER }} Installed
run: $ML_CMD ver
- name: Run MATLAB script with path
run: |
export MY_PATH=<path-to-my-MATLAB-code>
env $ML_PATHNAME=$MY_PATH $ML_CMD <my-MATLAB-script>
With support for JVM, IPOPT, and OSQP
strategy:
fail-fast: false
matrix:
platform: [matlab]
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Cache IPOPT interface
id: cache-ipopt
env:
cache-name: ipopt
uses: actions/cache@v3
with:
path: ~/build/ipopt
key: ${{ env.cache-name }}-${{ matrix.platform }}-${{ matrix.os }}
- name: Cache OSQP interface
id: cache-osqp
env:
cache-name: osqp
uses: actions/cache@v3
with:
path: ~/build/osqp-matlab
key: ${{ env.cache-name }}-${{ matrix.platform }}-${{ matrix.os }}
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Configure MATLAB
if: matrix.platform == 'matlab'
uses: MATPOWER/action-configure-matlab@v1
with:
os: ${{ matrix.os }}
nojvm: false
ipopt: ${{ env.INCLUDE_IPOPT == 1 }}
ipopt-cached: ${{ steps.cache-ipopt.outputs.cache-hit == 'true' }}
osqp: ${{ env.INCLUDE_OSQP == 1 }}
osqp-cached: ${{ steps.cache-osqp.outputs.cache-hit == 'true' }}
- name: MATLAB ${{ env.ML_VER }} Installed
run: $ML_CMD ver
- name: Run MATLAB script with path
run: |
$ML_CMD "fprintf('OSQP Version %s installed\n', osqp().version)"
export MY_PATH=<path-to-my-MATLAB-code>
env $ML_PATHNAME=$MY_PATH $ML_CMD <my-MATLAB-script>