Skip to content

Commit

Permalink
240129.003737.HKT get test_matlab_mac back on ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
zaikunzhang committed Jan 28, 2024
1 parent 1c564f6 commit 0e2adcc
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 52 deletions.
83 changes: 33 additions & 50 deletions .github/workflows/test_matlab_mac.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Test MATLAB, macOS
name: Test MATLAB, macOS ARM64

on:
# Trigger the workflow on push or pull request
push:
#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 0 * * *'
# Trigger the workflow manually
workflow_dispatch:
inputs:
git-ref:
Expand All @@ -16,21 +21,12 @@ run-name: ${{ github.event_name == 'workflow_dispatch' && format('Manual run {0}
jobs:
test:
name: Test MATLAB
runs-on: ${{ matrix.os }}
runs-on: [self-hosted, macOS, ARM64]
continue-on-error: true
strategy:
fail-fast: false
matrix:
os: [macos-latest]
matlab: [latest]

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: Clone Repository (Latest)
uses: actions/checkout@v4
if: github.event.inputs.git-ref == ''
Expand All @@ -56,48 +52,35 @@ jobs:
cd matlab/mex_gateways/
$SEDI "s|\(.*maybe due to overflow.*$\)|\1\nwrite(*,*) 'x = ', x; write(*,*) 'x_dp = ', x_dp|" fmxapi.F90
cat fmxapi.F90
- name: Revise postprima.m
shell: bash
run: |
cd matlab/interfaces/private/
$SEDI "s/max(\[0, chist\]) > 0)/max(\[0, chist\]) > 0)\nprobinfo.raw_data\noutput\nchist/" postprima.m
cat postprima.m
- name: Link gfortran for MATLAB on Linux
if: startsWith(matrix.os, 'ubuntu')
run: |
GFVER=${{ env.GFORTRAN_VERSION }}
if [[ "${{ matrix.os }}" = "ubuntu-20.04" ]] ; then
GFVER=11
fi
if [[ "${{ matrix.matlab }}" = "R2020b" || "${{ matrix.matlab }}" = "R2021a" || "${{ matrix.matlab }}" = "R2021b" ]] ; then
GFVER=9
fi
bash .github/scripts/link_gfortran "$GFVER"
- name: Install Intel oneAPI on macOS
if: startsWith(matrix.os, 'macos')
run: bash .github/scripts/install_oneapi_macos.sh

- name: Install Intel oneAPI on Windows
if: startsWith(matrix.os, 'windows')
#run: cmd.exe "/K" '".github\scripts\install_oneapi_windows.bat"' # As of MATLAB R2023a, oneAPI 2024 does not work. Try again later.
run: cmd.exe "/K" '".github\scripts\install_oneapi_windows.bat 2023"'

- name: Cache MATLAB # N.B.: Clear the cache when the `latest` version of MATLAB changes in March and September
uses: actions/[email protected]
with:
path: ${{ runner.tool_cache }}/MATLAB
key: ${{ matrix.os }}-${{ matrix.matlab }}

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2-beta
# - name: Revise cobylb.f
# shell: bash
# run: |
# cd fortran/classical/cobyla/
# $SEDI "s/cstrv = maxval(\[ZERO, -constr\])/cstrv = maxval([\ZERO, -constr\])\n write(*,*) 'x = ', x(1:n)\n write(*,*) 'f = ', f\n write(*,*) 'constr = ', constr(1:m)\n write(*,*) 'cstrv = ', cstrv/" cobylb.f
# cat cobylb.f

- name: Conduct the test # We do not use matlab-actions/run-command, which is not supported on macOS ARM64 as of 20240119
run: /Applications/MATLAB_R2023b.app/bin/matlab -batch "cd matlab/tests; testprima_ex();"

# 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
with:
release: ${{ matrix.matlab }}
repository: equipez/github_actions_scripts
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS
path: scripts

- name: Conduct the test
uses: matlab-actions/[email protected]
with:
command: |
cd matlab/tests; testprima_ex();
- name: Check whether the tests were successful or cancelled due to timeout
run: bash scripts/check_success_timeout_big_test ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.run_id }}
103 changes: 103 additions & 0 deletions .github/workflows/test_matlab_mac_intel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Test MATLAB, macOS Intel

on:
# Trigger the workflow on push or pull request
push:
workflow_dispatch:
inputs:
git-ref:
description: Git Ref (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}', inputs.git-ref) || '' }}


jobs:
test:
name: Test MATLAB
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
matlab: [latest]

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: Clone Repository (Latest)
uses: actions/checkout@v4
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
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: Revise fmxapi.F90
shell: bash
run: |
cd matlab/mex_gateways/
$SEDI "s|\(.*maybe due to overflow.*$\)|\1\nwrite(*,*) 'x = ', x; write(*,*) 'x_dp = ', x_dp|" fmxapi.F90
cat fmxapi.F90
- name: Revise postprima.m
shell: bash
run: |
cd matlab/interfaces/private/
$SEDI "s/max(\[0, chist\]) > 0)/max(\[0, chist\]) > 0)\nprobinfo.raw_data\noutput\nchist/" postprima.m
cat postprima.m
- name: Link gfortran for MATLAB on Linux
if: startsWith(matrix.os, 'ubuntu')
run: |
GFVER=${{ env.GFORTRAN_VERSION }}
if [[ "${{ matrix.os }}" = "ubuntu-20.04" ]] ; then
GFVER=11
fi
if [[ "${{ matrix.matlab }}" = "R2020b" || "${{ matrix.matlab }}" = "R2021a" || "${{ matrix.matlab }}" = "R2021b" ]] ; then
GFVER=9
fi
bash .github/scripts/link_gfortran "$GFVER"
- name: Install Intel oneAPI on macOS
if: startsWith(matrix.os, 'macos')
run: bash .github/scripts/install_oneapi_macos.sh

- name: Install Intel oneAPI on Windows
if: startsWith(matrix.os, 'windows')
#run: cmd.exe "/K" '".github\scripts\install_oneapi_windows.bat"' # As of MATLAB R2023a, oneAPI 2024 does not work. Try again later.
run: cmd.exe "/K" '".github\scripts\install_oneapi_windows.bat 2023"'

- name: Cache MATLAB # N.B.: Clear the cache when the `latest` version of MATLAB changes in March and September
uses: actions/[email protected]
with:
path: ${{ runner.tool_cache }}/MATLAB
key: ${{ matrix.os }}-${{ matrix.matlab }}

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2-beta
with:
release: ${{ matrix.matlab }}

- name: Conduct the test
uses: matlab-actions/[email protected]
with:
command: |
cd matlab/tests; testprima_ex();
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ to distribute this large amount of tests to multiple Team accounts as follows.

- [Tests](https://github.com/opt2ai/prima/actions) at [opt2ai/prima](https://github.com/opt2ai/prima)

- [![Test MATLAB, Linux](https://github.com/opt2ai/prima/actions/workflows/test_matlab_mac.yml/badge.svg)](https://github.com/opt2ai/prima/actions/workflows/test_matlab_mac.yml)
- [![Test MATLAB, Linux](https://github.com/opt2ai/prima/actions/workflows/test_matlab_windows.yml/badge.svg)](https://github.com/opt2ai/prima/actions/workflows/test_matlab_windows.yml)
- [![Test MATLAB, macOS Intel](https://github.com/opt2ai/prima/actions/workflows/test_matlab_mac_intel.yml/badge.svg)](https://github.com/opt2ai/prima/actions/workflows/test_matlab_mac_intel.yml)
- [![Test MATLAB, Windows](https://github.com/opt2ai/prima/actions/workflows/test_matlab_windows.yml/badge.svg)](https://github.com/opt2ai/prima/actions/workflows/test_matlab_windows.yml)

- [Tests](https://github.com/sprimalib/prima/actions) at [sprimalib/prima](https://github.com/sprimalib/prima)<a name="stress-tests"></a>

Expand Down

0 comments on commit 0e2adcc

Please sign in to comment.