Recursive test, MATLAB #255
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Recursive test, MATLAB | |
| on: | |
| # Trigger the workflow on push or pull request | |
| #push: | |
| #pull_request: # DANGEROUS! MUST be disabled for self-hosted runners! | |
| # Trigger the workflow by cron. The default time zone of GitHub Actions is UTC. | |
| schedule: | |
| - cron: '0 14 1-31/2 * *' | |
| # Trigger the workflow manually | |
| workflow_dispatch: | |
| inputs: | |
| git-ref: | |
| description: Git Ref (Optional) | |
| required: false | |
| random-seed: | |
| description: Random Seed (Optional) | |
| required: false | |
| dimension: | |
| description: Dimension (Optional) | |
| required: false | |
| depth: | |
| description: Depth of recursion (Optional) | |
| required: false | |
| # Show the git ref in the workflow name if it is invoked manually. | |
| run-name: ${{ github.event_name == 'workflow_dispatch' && format('Manual run {0} , seed {1}, dimension {2}, recursion depth {3}', inputs.git-ref, inputs.random-seed, inputs.dimension, inputs.depth) || '' }} | |
| jobs: | |
| test: | |
| name: Recursive test of PRIMA | |
| runs-on: ${{ matrix.os }} | |
| continue-on-error: true | |
| strategy: | |
| fail-fast: false | |
| # The matrix is essentially the same as that of stress_test_matlab.yml, except for test | |
| matrix: | |
| os: [ubuntu-latest, macos-13, windows-latest] | |
| matlab: [R2023a, latest] | |
| solver: [uobyqa, newuoa, bobyqa, lincoa, cobyla] | |
| ######################################################################################## | |
| # PRIMA is not recursion-safe on Ubuntu with MATLAB R2025a due to a bug of MATLAB. | |
| # Review and update this part when new releases of MATLAB becomes the latest. | |
| exclude: | |
| - os: ubuntu-latest | |
| matlab: latest | |
| include: | |
| - os: ubuntu-latest | |
| matlab: R2024b | |
| solver: uobyqa | |
| - os: ubuntu-latest | |
| matlab: R2024b | |
| solver: newuoa | |
| - os: ubuntu-latest | |
| matlab: R2024b | |
| solver: bobyqa | |
| - os: ubuntu-latest | |
| matlab: R2024b | |
| solver: lincoa | |
| - os: ubuntu-latest | |
| matlab: R2024b | |
| solver: cobyla | |
| ######################################################################################## | |
| steps: | |
| - name: Set http.postBuffer and core.compression | |
| # This is a workaround for random "early EOF" of checkout. | |
| # See https://github.com/actions/checkout/issues/748, https://github.com/actions/checkout/issues/1379 | |
| if: startsWith(matrix.os, 'windows') | |
| run: git config --global http.postBuffer 1048576000 && git config --global core.compression 0 | |
| - name: Run `sudo apt update -y` | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: sudo apt update -y # Otherwise, free-disk-space or other actions relying on `apt` may fail | |
| - name: Free disk space | |
| uses: jlumbroso/free-disk-space@main | |
| if: startsWith(matrix.os, 'ubuntu') | |
| with: | |
| # all of these default to true, but feel free to set to "false" if necessary for your workflow | |
| android: true | |
| dotnet: true | |
| haskell: true | |
| large-packages: true | |
| docker-images: true | |
| swap-storage: false # Important, or the runner may be shut down due to memory starvation. | |
| - name: Clone Repository (Latest) | |
| uses: actions/checkout@v4.2.2 | |
| if: github.event.inputs.git-ref == '' | |
| with: | |
| submodules: recursive | |
| # ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS | |
| # As of 231227, checkout with ssh fails frequently on Windows runners. | |
| - name: Clone Repository (Custom Ref) | |
| uses: actions/checkout@v4.2.2 | |
| if: github.event.inputs.git-ref != '' | |
| with: | |
| ref: ${{ github.event.inputs.git-ref }} | |
| submodules: recursive | |
| # ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS | |
| # As of 231227, checkout with ssh fails frequently on Windows runners. | |
| - name: Miscellaneous setup | |
| run: bash .github/scripts/misc_setup | |
| - name: Set up gfortran on Linux | |
| if: startsWith(matrix.os, 'ubuntu') | |
| uses: fortran-lang/setup-fortran@main | |
| with: | |
| compiler: gcc | |
| version: ${{ env.GFORTRAN_VERSION }} | |
| - name: Check gfortran version on Linux | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: which gfortran && gfortran --version | |
| - name: Decide the version of oneAPI to use | |
| shell: bash | |
| run: | | |
| ONEAPI_VERSION= | |
| if [[ "${{ matrix.os }}" = "windows-"* ]] ; then | |
| if [[ "${{ matrix.matlab }}" = "R2020"* || "${{ matrix.matlab }}" = "R2021"* || "${{ matrix.matlab }}" = "R2022"* || "${{ matrix.matlab }}" = "R2023"* ]] ; then | |
| ONEAPI_VERSION=2023 | |
| fi | |
| fi | |
| echo "ONEAPI_VERSION=$ONEAPI_VERSION" >> $GITHUB_ENV | |
| echo "ONEAPI_VERSION:" $ONEAPI_VERSION | |
| - name: Install Intel oneAPI on macOS | |
| if: startsWith(matrix.os, 'macos') | |
| run: bash .github/scripts/install_oneapi_macos.sh $ONEAPI_VERSION | |
| - name: Install Intel oneAPI on Windows | |
| if: startsWith(matrix.os, 'windows') | |
| run: cmd.exe "/K" '".github\scripts\install_oneapi_windows.bat %ONEAPI_VERSION%"' | |
| - name: Set up MATLAB with optimization toolbox | |
| uses: matlab-actions/setup-matlab@v2.5.0 | |
| with: | |
| release: ${{ matrix.matlab }} | |
| cache: true | |
| products: Optimization_Toolbox Parallel_Computing_Toolbox | |
| - name: Conduct the test | |
| uses: matlab-actions/run-command@v2.2.1 | |
| with: | |
| command: | | |
| ver; | |
| root_dir = pwd(); | |
| cd(fullfile(root_dir, 'matlab/tests')); | |
| options = struct(); | |
| if ~isempty('${{ inputs.random-seed }}') | |
| options.seed = str2num('${{ inputs.random-seed }}'); | |
| end | |
| if ~isempty('${{ inputs.dimension }}') | |
| options.n = str2num('${{ inputs.dimension }}'); | |
| end | |
| if ~isempty('${{ inputs.depth }}') | |
| options.depth = str2num('${{ inputs.depth }}'); | |
| end | |
| options | |
| % Conduct the test multiple times, in case some errors occur not during the first time but later. | |
| try | |
| recursive('${{ matrix.solver }}', options); | |
| options.compile = false; | |
| % Test parallel invocation of the solvers | |
| parfor i = 1 : 2 | |
| recursive('${{ matrix.solver }}', options); | |
| end | |
| catch exception | |
| % Copy the crash dump files to root_dir if exceptions occur. | |
| copy_crash_dump_files(root_dir, true) | |
| dir(root_dir) | |
| rethrow(exception); | |
| end | |
| - name: Store artifacts | |
| uses: actions/upload-artifact@v4.3.1 | |
| if: always() # Always run even if the workflow is canceled manually or due to overtime. | |
| with: | |
| name: ${{ matrix.solver }} | |
| path: | | |
| matlab_crash_dump* | |
| # The following job check whether the tests were successful or cancelled due to timeout. | |
| # N.B.: Remember to specify `continue-on-error: true` for the job of the tests. | |
| check_success_timeout: | |
| runs-on: ubuntu-latest | |
| if: ${{ !cancelled() }} | |
| needs: test | |
| steps: | |
| - name: Clone the GitHub actions scripts | |
| uses: actions/checkout@v4.2.2 | |
| with: | |
| repository: equipez/github_actions_scripts | |
| ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS | |
| path: scripts | |
| - name: Check whether the tests were successful or cancelled due to timeout | |
| run: bash scripts/check_success_timeout ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.run_id }} |