RELEASE v0.1.6 #124
Workflow file for this run
This file contains 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: libpymcr | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
types: [opened, reopened, synchronize] | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
py_version: | |
type: choice | |
options: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
concurrency : | |
group: ${{ github.workflow }}-${{ github.ref == 'refs/head/main' && github.run_number || github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash -l {0} | |
env: | |
# Matlab only provides binaries for 64-bit systems - so force x86_64 builds in "tag" | |
JSONSTR: | | |
{ | |
"pyvers": { | |
"push": ["3.8"], | |
"pull_request": ["3.8"], | |
"release": ["3.7", "3.8", "3.9", "3.10", "3.11"], | |
"workflow_dispatch": ["WORKFLOW_PYVER"] | |
}, | |
"os_map": { | |
"ubuntu-22.04": { | |
"mlver": "R2020a", | |
"tag": "manylinux_x86_64", | |
"mlprefix": "/host/" | |
}, | |
"windows-2022": { | |
"mlver": "R2021a", | |
"tag": "win_amd64", | |
"mlprefix": "" | |
}, | |
"macos-12": { | |
"mlver": "R2020a", | |
"tag": "macosx_x86_64", | |
"mlprefix": "" | |
} | |
} | |
} | |
# Must match what is stored in the gists | |
MCRVER: R2020a | |
jobs: | |
cache_matlab: | |
name: Create Matlab cache, ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, windows-2022, macos-12] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Cache MCR | |
if: ${{ matrix.os != 'ubuntu-22.04' }} | |
id: cache-mcr | |
uses: actions/cache@v3 | |
with: | |
path: mcr | |
key: ${{ runner.os }}-matlab-${{ env.MCRVER }}-mcr | |
lookup-only: true | |
- name: Cache gists | |
id: cache-gists | |
uses: actions/cache@v3 | |
with: | |
path: gists | |
key: ${{ runner.os }}-gists | |
lookup-only: true | |
- name: Download gists | |
if: ${{ steps.cache-gists.outputs.cache-hit != 'true' }} | |
run: | | |
mkdir -p gists | |
pip3 install requests | |
python3 gist_test_ctf.py --get --token=${{ secrets.GH_GIST_TOKEN }} --dir gists | |
- name: Install Mac MCR | |
if: ${{ matrix.os == 'macos-12' && steps.cache-mcr.outputs.cache-hit != 'true' }} | |
run: | | |
mkdir -p mcr | |
unzip -d . -q gists/pace_neutrons_installer.zip | |
sudo ./pace_neutrons_installer/Contents/MacOS/setup -mode silent -agreeToLicense yes | |
sleep 10 | |
while [[ ! -z $(ps aux |grep installer | grep mathworks) ]]; do sleep 10; done | |
cp -r /Applications/MATLAB/MATLAB_Runtime/v98/* mcr/ | |
- name: Install Win MCR | |
if: ${{ matrix.os == 'windows-2022' && steps.cache-mcr.outputs.cache-hit != 'true' }} | |
run: | | |
mkdir -p mcr | |
powershell -Command "gists\pace_neutrons_installer.exe -mode silent -agreeToLicense yes" | |
sleep 10 | |
powershell -Command "while(Get-Process pace_neutrons_installer -ErrorAction SilentlyContinue) { Start-Sleep -Seconds 10 }" | |
cp -r /c/Program\ Files/MATLAB/MATLAB\ Runtime/v98/* mcr/ | |
build_and_test: | |
name: Build and test, ${{ matrix.os }}, py${{ matrix.pyver }} | |
needs: cache_matlab | |
# OS strategy matrix must match key in JSONSTR.os_map above | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, windows-2022, macos-12] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup variables | |
run: | | |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
export JSONSTR=$(echo $JSONSTR | sed s/WORKFLOW_PYVER/${{ github.event.inputs.py_version }}/) | |
fi | |
export EVENTTYPE=${{ github.event_name }} | |
if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ github.event.pull_request.title }}" == *"RELEASE"* ]]; then | |
python3 release.py --version_check | |
export EVENTTYPE=release | |
fi | |
echo CIBW=`echo $JSONSTR | jq ".os_map[\"${{ matrix.os }}\"].tag as \\\$tag| .pyvers[\"$EVENTTYPE\"] | [.[] | \ | |
capture(\"(?<maj>[0-9]+)\\\\\\.(?<min>[0-9]+)\") | \"cp\(.maj)\(.min)-\(\\\$tag)\"] | @sh" | sed s/[\"\']//g` >> $GITHUB_ENV | |
echo PYVERS=`echo $JSONSTR | jq ".pyvers[\"$EVENTTYPE\"] | @sh"` >> $GITHUB_ENV | |
export MLVER=`echo $JSONSTR | jq ".os_map[\"${{ matrix.os }}\"].mlver" | sed s/\"//g` | |
echo MLVER=$MLVER >> $GITHUB_ENV | |
echo MLPREFIX=`echo $JSONSTR | jq ".os_map[\"${{ matrix.os }}\"].mlprefix" | sed s/\"//g` >> $GITHUB_ENV | |
echo "HOSTDIRECTORY=`pwd`" >> $GITHUB_ENV | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
echo "MATLABEXECUTABLE=/usr/local/MATLAB/$MLVER/bin/matlab" >> $GITHUB_ENV; | |
else | |
echo "MATLABEXECUTABLE=`pwd`/mcr/bin/matlab" >> $GITHUB_ENV; | |
fi | |
env | |
- name: Set up MATLAB | |
if: ${{ matrix.os == 'ubuntu-22.04' }} | |
uses: matlab-actions/[email protected] | |
with: | |
release: ${{ env.MLVER }} | |
- uses: actions/cache/restore@v3 | |
if: ${{ matrix.os != 'ubuntu-22.04' }} | |
with: | |
path: mcr | |
key: ${{ runner.os }}-matlab-${{ env.MCRVER }}-mcr | |
fail-on-cache-miss: true | |
- uses: actions/cache/restore@v3 | |
with: | |
path: gists | |
key: ${{ runner.os }}-gists | |
fail-on-cache-miss: true | |
- uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: ${{ env.CIBW }} | |
CIBW_ENVIRONMENT: >- | |
MATLABEXECUTABLE="${{ env.MLPREFIX }}${{ env.MATLABEXECUTABLE }}" | |
HOSTDIRECTORY="${{ env.MLPREFIX }}${{ env.HOSTDIRECTORY }}" | |
CIBW_BUILD_VERBOSITY: 1 | |
MACOSX_DEPLOYMENT_TARGET: "10.15" | |
- uses: mamba-org/provision-with-micromamba@main | |
with: | |
environment-file: false | |
cache-downloads: true | |
- name: Install wheels and run test | |
run: | | |
# set -e makes sure the script fails if any command in the loop fails | |
set -e | |
cp -f gists/* test/ | |
for pyver in $(echo $PYVERS | sed s/[\"\']//g); do | |
$MAMBA_EXE create -n py$pyver -c conda-forge python=$pyver numpy six | |
eval "$($MAMBA_EXE shell activate py$pyver)" | |
python -m pip install wheelhouse/*cp$(echo $pyver | sed s/\\.//)* | |
cd test | |
# Sometimes the test results in a segfault on exit | |
python run_test.py || true | |
test -f success | |
cd .. | |
done | |
- name: Upload release wheels | |
if: ${{ github.event_name == 'release' }} | |
run: | | |
pip3 install requests | |
python3 release.py --notest --github --token=${{ secrets.GH_GIST_TOKEN }} | |
#- name: Setup tmate | |
# if: ${{ failure() }} | |
# uses: mxschmitt/action-tmate@v3 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.os }}_artifacts.zip | |
path: | | |
wheelhouse/* | |
**/*.mex[awmaci]*64 |