Use run-command to avoid specifying matlab path #75
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: pySpinW | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master, development] | ||
types: [opened, reopened, synchronize] | ||
workflow_dispatch: | ||
jobs: | ||
compile_mex: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
matlab_version: [latest] | ||
include: | ||
- os: macos-latest | ||
INSTALL_DEPS: brew install llvm libomp | ||
fail-fast: true | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Check out SpinW | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up MATLAB | ||
uses: matlab-actions/setup-matlab@v1 # v1.1.0 required for Windows/MacOS support | ||
with: | ||
release: ${{ matrix.matlab_version }} | ||
- name: Remove old mex # This is due to find not working :-/ # find ${{ github.workspace }} -name "*.mex*" -type f -delete | ||
run: | | ||
rm external/chol_omp/chol_omp.mexa64 | ||
rm external/chol_omp/chol_omp.mexmaci64 | ||
rm external/chol_omp/chol_omp.mexw64 | ||
rm external/eig_omp/eig_omp.mexa64 | ||
rm external/eig_omp/eig_omp.mexmaci64 | ||
rm external/eig_omp/eig_omp.mexw64 | ||
rm external/mtimesx/sw_mtimesx.mexa64 | ||
rm external/mtimesx/sw_mtimesx.mexmaci64 | ||
rm external/mtimesx/sw_mtimesx.mexw64 | ||
- name: Run MEXing | ||
uses: matlab-actions/run-command@v1 | ||
with: | ||
command: "addpath(genpath('swfiles')); addpath(genpath('external')); sw_mex('compile', true, 'test', false, 'swtest', false);" | ||
- name: Upload MEX results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: MEX | ||
path: ${{ github.workspace }}/external/**/*.mex* | ||
build_ctfs: | ||
needs: compile_mex | ||
strategy: | ||
matrix: | ||
matlab_version: [R2021b, R2022a, R2022b, R2023a, R2023b] | ||
runs-on: self-hosted | ||
steps: | ||
- name: Check out SpinW | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Download MEX artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: MEX | ||
path: ${{ github.workspace }}/external | ||
- name: Build ctf | ||
uses: matlab-actions/run-command@v1 | ||
with: | ||
command: "run -nodisplay -r "cd python; build_ctf.m; exit" | ||
- name: Upload CTF results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: CTF | ||
path: ${{ github.workspace }}/python/ctf/*.ctf | ||
build_wheel: | ||
runs-on: ubuntu-latest | ||
needs: build_ctfs | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout SpinW | ||
uses: actions/checkout@v3 | ||
- name: Download CTF artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: CTF | ||
path: python/ctf | ||
- name: Set up Python environment | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: Move files | ||
run: | | ||
cd python | ||
echo "PYSPINW_VERSION=$( cat pyproject.toml | grep "version = \"" | awk -F'"' '$0=$2' | sed 's/ //g' )" >> $GITHUB_ENV | ||
mkdir pyspinw/ctfs | ||
mv ctf/*.ctf pyspinw/ctfs | ||
- name: Build Wheel | ||
run: | | ||
cd ${{ github.workspace }}/python | ||
python -m pip wheel --no-deps --wheel-dir build . | ||
- name: Set up MATLAB | ||
uses: matlab-actions/setup-matlab@v1 # v1.1.0 required for Windows/MacOS support | ||
with: | ||
release: latest | ||
- name: Run python test | ||
run: | | ||
pip install scipy | ||
cd ${{ github.workspace }}/python | ||
pip install build/*whl | ||
cd tests | ||
python -m unittest | ||
- name: Create wheel artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pySpinW Wheel | ||
path: ${{ github.workspace }}/python/build/*.whl | ||
- name: Upload release wheels | ||
if: ${{ github.event_name == 'release' }} | ||
run: | | ||
pip3 install requests | ||
python3 release.py --notest --github --token=${{ secrets.GH_TOKEN }} |