forked from tsdev/spinw
-
Notifications
You must be signed in to change notification settings - Fork 15
179 lines (173 loc) · 5.71 KB
/
build_pyspinw.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
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@v4
with:
fetch-depth: 0
- name: Install Dependencies
run: ${{ matrix.INSTALL_DEPS }}
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
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@v2
with:
command: "addpath(genpath('swfiles')); addpath(genpath('external')); sw_mex('compile', true, 'test', false, 'swtest', false);"
- name: Upload MEX results
uses: actions/upload-artifact@v4
with:
name: mex-${{ matrix.os }}
path: ${{ github.workspace }}/external/**/*.mex*
build_mltbx:
runs-on: ubuntu-latest
needs: compile_mex
permissions:
contents: write
steps:
- name: Checkout SpinW
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download MEX artifacts
uses: actions/download-artifact@v4
with:
pattern: mex-*
path: ${{ github.workspace }}/external
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
with:
release: latest
- name: Build mltbx
uses: matlab-actions/run-command@v2
with:
command: "cd mltbx; create_mltbx"
- name: Upload mltbx
uses: actions/upload-artifact@v4
with:
name: spinw.mltbx
path: ${{ github.workspace }}/mltbx/spinw.mltbx
- name: Setup tmate
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
build_ctfs:
needs: compile_mex
runs-on: self-hosted
steps:
- name: Check out SpinW
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download MEX artifacts
uses: actions/download-artifact@v4
with:
pattern: mex-*
path: ${{ github.workspace }}/external
- name: Build ctf
run: |
cd python
mkdir ctf
python mcc_all.py
- name: Upload CTF results
uses: actions/upload-artifact@v4
with:
name: ctf-all
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@v4
- name: Download CTF artifacts
uses: actions/download-artifact@v4
with:
pattern: ctf-*
path: python/ctf
- name: Download mltbx artifacts
uses: actions/download-artifact@v4
with:
pattern: spinw.mltbx
path: mltbx
- 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
find ctf/ -name "*.ctf" -exec mv '{}' pyspinw/ctfs \;
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
with:
release: R2023a
products: MATLAB_Compiler_SDK
# Cannot run matlab directly from the setup (gives license error) need to download a runner with the run-command actions
- name: Download Matlab command runner
uses: matlab-actions/run-command@v2
with:
command: "ver"
- name: Generate wrappers
run: |
python -m pip install libpymcr
wget https://gist.github.com/mducle/9186d062b42f05507d831af3d6677a5d/raw/cd0b0d3ed059f4e13d0364e98312dcddc2690ced/run_gh_matlab.sh
chmod 777 run_gh_matlab.sh
matlab2python -a swfiles -a external --preamble "import pyspinw; m = pyspinw.Matlab()" --matlabexec `pwd`/run_gh_matlab.sh
mv matlab_wrapped python/pyspinw
- name: Build Wheel
run: |
cd ${{ github.workspace }}/python
python -m pip wheel --no-deps --wheel-dir wheelhouse .
- 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@v4
with:
name: pySpinW Wheel
path: ${{ github.workspace }}/python/build/*.whl
- name: Upload release wheels
if: ${{ github.event_name == 'release' }}
run: |
python -m pip install requests
python release.py --notest --github --token=${{ secrets.GH_TOKEN }}
- name: Setup tmate
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3