Fails to export livescripts
I would like to automate building documentation by exporting livescripts to markdown for use with a static site generator. The export function requires a display (related to #51?) and therefore fails in CI.
I set up a build task makeDocs which only runs export on a GettingStarted.mlx.
The error is:
** Starting makeDocs
## -----------------------------------------------------------------------------
## Error occurred in 'makeDocs' and it did not run to completion.
## Identifier: 'cefclient:webwindow:MissingDisplay'
## Message: DISPLAY environment variable must be set to a valid X11 display.
## Stack:
I'm working on an example toolbox to test out using github actions with toolboxes (https://github.com/DavidRConnell/githubaction-toolbox-mwe). The mlx is very simple and just prints a few numbers (no plotting). I can run the makeDocs build task locally with matlab -batch 'buildtool makeDocs'. When adding the -nodisplay flag it doesn't error but it does hang and never completes the task.
As a test, I tried setting the environment variable DISPLAY=:0.0 and got the error:
** Starting makeDocs
## -----------------------------------------------------------------------------
## Error occurred in 'makeDocs' and it did not run to completion.
## Identifier: 'cefclient:webwindow:launchProcessFailed'
## Message: MATLABWindow application failed to launch. Unable to launch the MATLABWindow application. The exit code was: 267
Anyway to export examples? Not sure why this would require a display.
Hi @DavidRConnell ,
You need to create a virtual display as shown in the example below. Copy the "Start virtual display" step and put it in your workflow before calling MATLAB to export your live scripts.
name: MATLAB Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start virtual display
run: |
sudo apt-get install xvfb
Xvfb :99 &
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Setup MATLAB
uses: matlab-actions/setup-matlab@v2
- name: Run MATLAB command
uses: matlab-actions/run-command@v2
with:
command: export("sample.mlx");
- uses: actions/upload-artifact@v4
with:
path: sample.pdf
We are looking at ways of removing the display requirement for exporting live scripts in the future.
Best, Mark
That worked thank you.