libpymcr #176
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.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | |
concurrency : | |
group: ${{ github.workflow }}-${{ github.ref == 'refs/head/main' && github.run_number || github.ref }} | |
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", "3.13"], | |
"pull_request": ["3.8", "3.13"], | |
"release": ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"], | |
"workflow_dispatch": ["WORKFLOW_PYVER"] | |
}, | |
"os_map": { | |
"ubuntu-24.04": { | |
"mlver": "R2021a", | |
"tag": "manylinux_x86_64", | |
"mlprefix": "/host/" | |
}, | |
"windows-2022": { | |
"mlver": "R2023a", | |
"tag": "win_amd64", | |
"mlprefix": "" | |
}, | |
"macos-13": { | |
"mlver": "R2024a", | |
"tag": "macosx_x86_64", | |
"mlprefix": "" | |
}, | |
"macos-14": { | |
"mlver": "R2024b", | |
"tag": "macosx_arm64", | |
"mlprefix": "" | |
} | |
} | |
} | |
jobs: | |
build_and_test: | |
name: Build and test, ${{ matrix.os }}, py${{ matrix.pyver }} | |
# OS strategy matrix must match key in JSONSTR.os_map above | |
strategy: | |
matrix: | |
os: [ubuntu-24.04, windows-2022, macos-13, macos-14] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
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 | |
- name: Set up MATLAB | |
uses: matlab-actions/[email protected] | |
with: | |
release: ${{ env.MLVER }} | |
products: MATLAB_Compiler_SDK | |
- name: Set Matlab env | |
run: | | |
echo "MATLABEXECUTABLE=`which matlab`" >> $GITHUB_ENV; | |
env | |
- uses: mamba-org/setup-micromamba@v1 | |
with: | |
cache-downloads: true | |
- name: Download gists | |
run: | | |
$MAMBA_EXE create -n gistsenv -c conda-forge python=3.9 numpy requests | |
eval "$($MAMBA_EXE shell activate gistsenv)" | |
mkdir -p gists | |
python gist_test_ctf.py --get --token=${{ secrets.GH_GIST_TOKEN }} --dir gists | |
- uses: pypa/[email protected] | |
if: ${{ matrix.os != 'macos-14' }} # cibuildwheel builds x86_64 on macos-14!! | |
env: | |
CIBW_BUILD: ${{ env.CIBW }} | |
CIBW_ENVIRONMENT: >- | |
MATLABEXECUTABLE="${{ env.MLPREFIX }}${{ env.MATLABEXECUTABLE }}" | |
HOSTDIRECTORY="${{ env.MLPREFIX }}${{ env.HOSTDIRECTORY }}" | |
CIBW_BUILD_VERBOSITY: 1 | |
MACOSX_DEPLOYMENT_TARGET: "11" | |
- 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 requests | |
eval "$($MAMBA_EXE shell activate py$pyver)" | |
pytag="cp$(echo $pyver | sed s/\\.//)" | |
if [[ $OSTYPE == "darwin23" ]]; then | |
echo "Compiling package for MacOS-14" | |
python -m pip install delocate | |
python -m pip wheel . --wheel-dir=dist --no-deps -v | |
delocate-wheel --require-archs arm64 -w wheelhouse -v dist/*${pytag}* | |
fi | |
python -m pip install wheelhouse/*${pytag}* | |
cd test | |
python run_test.py | |
cd .. | |
done | |
- name: Upload release wheels | |
if: ${{ github.event_name == 'release' }} | |
run: | | |
eval "$($MAMBA_EXE shell activate gistsenv)" | |
python release.py --notest --github --token=${{ secrets.GH_GIST_TOKEN }} | |
#- name: Setup tmate | |
# if: ${{ failure() }} | |
# uses: mxschmitt/action-tmate@v3 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}_artifacts.zip | |
path: | | |
wheelhouse/* | |
**/*.mex* |