Skip to content
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

Fails to export livescripts #121

Open
DavidRConnell opened this issue Aug 23, 2024 · 2 comments
Open

Fails to export livescripts #121

DavidRConnell opened this issue Aug 23, 2024 · 2 comments

Comments

@DavidRConnell
Copy link

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.

@mcafaro
Copy link
Member

mcafaro commented Aug 23, 2024

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

@DavidRConnell
Copy link
Author

That worked thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants