-
Notifications
You must be signed in to change notification settings - Fork 5
262 lines (256 loc) · 10.4 KB
/
run_test.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: ZMat CI
on: [push, pull_request]
jobs:
octave_test:
name: Octave tests
strategy:
# tested octave versions: ubuntu-20.04 = 5.2, ubuntu-22.04 = 6.4, macos-12 = 8.1, windows-2019 = 8.3
matrix:
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, windows-2019]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install dependencies
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get update && (sudo apt-get install -y liboctave-dev valgrind || sudo apt-get install -y octave-dev valgrind)
curl --retry 3 -kL https://github.com/upx/upx/releases/download/v4.1.0/upx-4.1.0-amd64_linux.tar.xz --output upx.tar.xz
tar -xvf upx.tar.xz
sudo mv upx-4.1.0-amd64_linux/upx /usr/bin
rm -rf upx-4.1.0-amd64_linux upx.tar.xz
fi
[[ "$RUNNER_OS" == "macOS" ]] && brew install octave upx
if [[ "$RUNNER_OS" == "Windows" ]]; then
choco install upx
which upx
curl --retry 3 -kL http://cdimage.debian.org/mirror/gnu.org/gnu/octave/windows/octave-8.3.0-w64-64.7z --output octave_8.3.0.7z
7z x octave_8.3.0.7z -ooctave -y
echo 'C:\msys64\mingw64\bin' >> $GITHUB_PATH
echo "$PWD/octave/octave-8.3.0-w64-64/mingw64/bin" >> $GITHUB_PATH
fi
- name: Install msys2 libraries (Windows only)
if: ${{ runner.os == 'Windows' }}
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-zlib
mingw-w64-x86_64-winpthreads-git
base-devel
- name: Build static library
run: |
which gcc
which g++
make -C src lib CC=gcc CXX=g++
make -C example/c all CC=gcc CXX=g++ LIBTYPE=
if [ "$RUNNER_OS" == "macOS" ]; then
DYLD_LIBRARY_PATH=lib example/c/testzmat;
else
LD_LIBRARY_PATH=lib example/c/testzmat;
fi
octave-cli --eval "fprintf(1,['OCTAVE_ARCH=' regexprep(computer('arch'), 'darwin[0-9.]+-', 'darwin-')])"
octave-cli --eval "fprintf(1,['OCTAVE_ARCH=' regexprep(computer('arch'), 'darwin[0-9.]+-', 'darwin-')])" >> $GITHUB_ENV
- name: Build dynamic library
run: |
make -C src dll CC=gcc CXX=g++
make -C example/c all CC=gcc CXX=g++ LIBTYPE=
if [ "$RUNNER_OS" == "macOS" ]; then
DYLD_LIBRARY_PATH=lib example/c/testzmat;
else
LD_LIBRARY_PATH=lib example/c/testzmat;
fi
- name: Build octave mex (Windows only)
if: ${{ runner.os == 'Windows' }}
shell: msys2 {0}
run: |
export PATH="/mingw64/bin":"$PWD/octave/octave-8.3.0-w64-64/mingw64/bin":$PATH
which gcc
gcc -v
make -C src oct CC=gcc CXX=g++ USERLINKOPT="-static-libgcc -static-libstdc++ -fstack-protector -L/mingw64/lib -Wl,-Bstatic -lz -lwinpthread -Wl,-Bdynamic -v -s '$PWD/octave/octave-8.3.0-w64-64/mingw64/lib/octave/8.3.0/liboctinterp.dll.a'"
objdump -p zipmat.mex | grep "DLL Name:"
strip zipmat.mex
echo "$PWD/octave/octave-8.3.0-w64-64/mingw64/bin" >> $GITHUB_PATH
- name: Compress octave mex (Windows only)
if: ${{ runner.os == 'Windows' }}
run: |
#upx -9 zipmat.mex || true
- name: Build octave mex (Linux and Mac)
if: ${{ runner.os != 'Windows' }}
run: |
gcc -v
if [ "$RUNNER_OS" == "macOS" ]; then
make -C src oct CC=gcc-12 CXX=g++-12 USERLINKOPT="-v -s"
otool -L zipmat.mex
#upx -9 zipmat.mex || true
else
make -C src oct CC=gcc CXX=g++ MEXLINKOPT="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lm -lpthread -Wl,-Bdynamic" USERLINKOPT="-v -s"
ldd zipmat.mex
fi
strip -S zipmat.mex
#upx -9 zipmat.mex || true
- name: Run octave test
if: ${{ runner.os != 'Linux' }}
run: |
octave-cli --version
if [ "$RUNNER_OS" == "Windows" ]; then
export PATH="$PWD/octave/octave-8.3.0-w64-64/mingw64/bin":$PATH
fi
octave-cli --eval "addpath(pwd);cd test;run_zmat_test;cd ../example;demo_zmat_basic;zmat_speedbench"
- name: Run octave test
if: ${{ runner.os == 'Linux' }}
run: |
octave-cli --version
valgrind octave-cli --eval "addpath(pwd);cd test;run_zmat_test;cd ../example;demo_zmat_basic"
octave-cli --eval "addpath(pwd);cd example;zmat_speedbench"
- name: Create package folder
run: |
mkdir packages
mkdir zmat
mkdir -p zmat/octave/${{ env.OCTAVE_ARCH }}
cp *.{m,txt,rst} zmat/
cp PKG_ADD* zmat/
cp INDEX zmat/
cp DESCRIPTION zmat/
cp COPYING zmat/
cp -a example zmat/
cp -a test zmat/
- name: Create release tag
run: perl -e "print 'RELEASE_TAG='. lc('${{ runner.os }}-${{ runner.arch }}-github-latest')" >> $GITHUB_ENV
- name: Zip zmat
run: |
mv zipmat.mex zmat/octave/${{ env.OCTAVE_ARCH }}
if [[ "$RUNNER_OS" == "Windows" ]]; then
7z a -tzip packages/zmat-octave-${{ env.RELEASE_TAG }}.zip zmat
else
zip -FSr --symlink packages/zmat-octave-${{ env.RELEASE_TAG }}.zip zmat
fi
- name: Upload zmat package
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-12' || matrix.os == 'windows-2019' }}
uses: actions/upload-artifact@v3
with:
name: all-zmat-packages
path: packages/zmat-octave-${{ env.RELEASE_TAG }}.zip
matlab_test:
name: MATLAB test
strategy:
matrix:
os: [ubuntu-20.04, macos-12, windows-2019]
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install dependencies
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
curl --retry 3 -kL https://github.com/upx/upx/releases/download/v4.1.0/upx-4.1.0-amd64_linux.tar.xz --output upx.tar.xz
tar -xvf upx.tar.xz
sudo mv upx-4.1.0-amd64_linux/upx /usr/bin || true
rm -rf upx-4.1.0-amd64_linux upx.tar.xz || true
fi
[[ "$RUNNER_OS" == "macOS" ]] && brew install upx
[[ "$RUNNER_OS" == "Windows" ]] && choco install upx
echo "installed upx"
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Install msys2 libraries (Windows only)
if: ${{ runner.os == 'Windows' }}
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-zlib
mingw-w64-x86_64-winpthreads-git
base-devel
- name: Set up mex gcc (Windows only)
if: ${{ runner.os == 'Windows' }}
run: |
echo 'MW_MINGW64_LOC=/c/msys64/mingw64' >> $GITHUB_ENV
echo 'COMPFLAGS=""' >> $GITHUB_ENV
- name: Build MATLAB mex
run: |
rm -rf private
if [[ "$RUNNER_OS" == "Windows" ]]; then
make -C src mex CC=gcc CXX=g++ MEX="cmd //s //c mex -f mexopts_msys2_gcc.xml " USERLINKOPT="-v " CXXLIBS="-Lblosc2/lib -L/blosc2/internal-complibs/zstd-1.5.2"
objdump -p zipmat.mexw* | grep "DLL Name:"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
make -C src mex CC=gcc-12 CXX=g++-12 MEXLINKOPT="-static-libstdc++"
otool -L zipmat.mex*
upx -9 zipmat.mex* || true
else
make -C src mex CC=gcc CXX=g++ MEXLINKOPT="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lz -Wl,-Bdynamic" MEX="mex -v"
ldd zipmat.mex*
fi
strip -S zipmat.mex*
upx -9 zipmat.mex* || true
- name: Run MATLAB examples
uses: matlab-actions/run-command@v1
with:
command: addpath(pwd);cd test;run_zmat_test;cd ../example;demo_zmat_basic;zmat_speedbench
- name: Create package folder
run: |
mkdir packages
mkdir zmat
mkdir -p zmat/private
mkdir -p zmat/example
cp *.{m,txt,rst} zmat/
cp -a example/*.m zmat/example
cp -a test zmat/
- name: Create release tag
run: perl -e "print 'RELEASE_TAG='. lc('${{ runner.os }}-${{ runner.arch }}-github-latest')" >> $GITHUB_ENV
- name: Zip zmat
run: |
mv zipmat.mex* zmat/private
if [[ "$RUNNER_OS" == "Windows" ]]; then
7z a -tzip packages/zmat-matlab-${{ env.RELEASE_TAG }}.zip zmat
else
zip -FSr --symlink packages/zmat-matlab-${{ env.RELEASE_TAG }}.zip zmat
fi
- name: Upload zmat package
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-12' || matrix.os == 'windows-2019' }}
uses: actions/upload-artifact@v3
with:
name: all-zmat-packages
path: packages/zmat-matlab-${{ env.RELEASE_TAG }}.zip
upload_package:
name: Upload Packages
needs: [octave_test, matlab_test]
runs-on: ubuntu-20.04
if: ${{ github.repository_owner == 'NeuroJSON' && github.event_name != 'pull_request'}}
steps:
- name: Download zmat
uses: actions/download-artifact@v3
with:
name: all-zmat-packages
path: packages
- name: Create all-in-one zmat package
run: |
cd packages
unzip -n 'zmat*.zip'
rm -rf zmat/example/c/testzmat.exe zmat/example/c/testzmat zmat/example/c/testzmat.dSYM
tree .
zip -FSr --symlink zmat-allinone-github-latest.zip zmat
rm -rf zmat
- name: Display structure of downloaded files
run: ls -R packages
- name: Copy package to server
if: ${{ github.repository_owner == 'NeuroJSON' && github.event_name != 'pull_request'}}
uses: wlixcc/SFTP-Deploy-Action@v1.2.4
with:
server: ${{ secrets.MCX_SERVER }}
username: ${{ secrets.MCX_SERVER_USER }}
ssh_private_key: ${{ secrets.MCX_SERVER_SSH_KEY }}
local_path: "packages/zmat-allinone-github-latest.zip"
remote_path: ${{ secrets.MCX_CI_PATH }}