Merge branch 'NeuroJSON:master' into master #6
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: 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-11 = 8.1, windows-2019 = 8.3 | |
matrix: | |
os: [ubuntu-20.04, ubuntu-22.04, macos-11, 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: | | |
[[ "$RUNNER_OS" == "Linux" ]] && sudo apt-get update && sudo apt-get install -y liboctave-dev | |
[[ "$RUNNER_OS" == "macOS" ]] && brew install octave | |
if [[ "$RUNNER_OS" == "Windows" ]]; then | |
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'" | |
cp /mingw64/bin/zlib1.dll . | |
objdump -p zipmat.mex | grep "DLL Name:" | |
strip zipmat.mex | |
echo "$PWD/octave/octave-8.3.0-w64-64/mingw64/bin" >> $GITHUB_PATH | |
- 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 CXX=g++ MEXLINKOPT="-static" USERLINKOPT="-v -s" | |
otool -L zipmat.mex | |
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 | |
- name: Run octave test | |
run: | | |
octave-cli --version | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
export PATH="$PWD/octave/octave-8.3.0-w64-64/mingw64/bin":$PATH | |
fi | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
octave-cli --eval "addpath(pwd);cd test;run_zmat_test" | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
octave-cli --eval "addpath(pwd);cd test;run_zmat_test({'c','d'})" | |
else | |
octave-cli --eval "addpath(pwd);which zipmat;disp(char(zmat(zmat('test zlib'),0,'zlib')));disp(char(zmat(zmat('test gzip',1,'gzip'),0,'gzip')));disp(char(zmat(zmat('test lzma',1,'lzma'),0,'lzma')));disp(char(zmat(zmat('test blosc2lz4',1,'blosc2lz4'),0,'blosc2lz4')));" | |
fi | |
- 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 -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 | |
cp /mingw64/bin/zlib1.dll zmat/octave/${{ env.OCTAVE_ARCH }} | |
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-11' || 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-11, windows-2019] | |
defaults: | |
run: | |
shell: bash | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- 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-10 CXX=g++10 MEXLINKOPT="-static-libstdc++" | |
otool -L zipmat.mex* | |
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* | |
- name: Run MATLAB examples | |
uses: matlab-actions/run-command@v1 | |
with: | |
command: addpath(pwd);cd test;run_zmat_test | |
- 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-11' || 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' | |
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 }} |