Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to automate tests (#6) #9

Merged
merged 31 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
90a25c7
Simple wrapping workflow
johmedr Nov 19, 2024
09c3834
Merge pull request #8 from spm/main
johmedr Nov 21, 2024
ba5f123
Create run_unit_tests.yml
johmedr Nov 21, 2024
17d5478
Update run_unit_tests.yml
johmedr Nov 21, 2024
3ed6092
Update run_unit_tests.yml
johmedr Nov 21, 2024
23f0309
Update run_unit_tests.yml with Matlab Paths
johmedr Nov 21, 2024
868b349
Update run_unit_tests.yml
johmedr Nov 21, 2024
d4238fe
Update run_unit_tests.yml to Cache matlab
johmedr Nov 21, 2024
d538ea5
Update run_unit_tests.yml with Paths
johmedr Nov 21, 2024
6170387
Update run_unit_tests.yml with License
johmedr Nov 21, 2024
a954913
Update run_unit_tests.yml - remove python cache
johmedr Nov 21, 2024
3515ed2
Update run_unit_tests.yml - Moved LD_LIBRARY_PATH
johmedr Nov 21, 2024
84bb490
Update run_unit_tests.yml
johmedr Nov 21, 2024
1abf411
Update run_unit_tests.yml - Add Matlab_Compiler as dependency
johmedr Nov 21, 2024
de8e03f
Update run_unit_tests.yml
johmedr Nov 21, 2024
fb18a10
Update run_unit_tests.yml
johmedr Nov 21, 2024
65c46e8
Update run_unit_tests.yml
johmedr Nov 21, 2024
45537f5
Update run_unit_tests.yml
johmedr Nov 21, 2024
a82590b
Update run_unit_tests.yml
johmedr Nov 21, 2024
caabd62
Update run_unit_tests.yml
johmedr Nov 21, 2024
10f9659
Update run_unit_tests.yml
johmedr Nov 21, 2024
f2482ac
Update run_unit_tests.yml
johmedr Nov 21, 2024
c865c91
Update run_unit_tests.yml
johmedr Nov 21, 2024
c66706e
Update run_unit_tests.yml
johmedr Nov 21, 2024
c2da4f1
Update run_unit_tests.yml
johmedr Nov 21, 2024
cb9d43e
Update README.md
johmedr Nov 21, 2024
69454f8
Update run_unit_tests.yml
johmedr Nov 21, 2024
5b27a92
Update run_unit_tests.yml
johmedr Nov 21, 2024
26f7da8
Update run_unit_tests.yml
johmedr Nov 21, 2024
9f14a1e
Update run_unit_tests.yml
johmedr Nov 21, 2024
28d1edd
Update run_unit_tests.yml
johmedr Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Unit tests
on:
workflow_dispatch:
push:
pull_request:

env:
MLM_LICENSE_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN }}

jobs:
unit-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: False
matrix:
matlab: ["latest"]
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
include:
- os: ubuntu-latest
os_name: Linux
platform: Linux
- os: macos-13
os_name: macOS_Intel
platform: Mac
- os: macos-latest
os_name: macOS_Apple_Silicon
platform: Mac
- os: windows-latest
os_name: Windows
platform: Windows

steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Check out SPM Python
uses: actions/checkout@v4

- name: Install SPM Python
run: python -m pip install -e .

# Setup MATLAB and Runtime
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
with:
release: ${{matrix.matlab}}
cache: True
products: |
MATLAB_Compiler
MATLAB_Compiler_SDK

- name: Extract MATLAB path to file
uses: matlab-actions/run-command@v2
with:
command: |
fileID = fopen('matlab_path.txt', 'w');
matlabpath = matlabroot;
matlabpath = strrep(matlabpath, filesep, '/');
matlabpath = strrep(matlabpath, '\', '\\');
matlabpath = strrep(matlabpath, 'C:', '/c/');
matlabpath = strrep(matlabpath, 'D:', '/d/');
fprintf(fileID, matlabpath);
fclose(fileID);
# sometimes this step hangs when closing matlab, automatically terminating after 2 minutes solves the issue
timeout-minutes: 2
continue-on-error: true

- name: Set environment variable with MATLAB path
shell: bash # Works on Windows as well because of shell: bash
run: |
matlab_path=$(cat matlab_path.txt)
echo "MATLAB_PATH=$matlab_path" >> $GITHUB_ENV

- name: Run tests (Mac Apple Silicon)
if: matrix.os_name == 'macOS_Apple_Silicon'
run: |
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\
${{ env.MATLAB_PATH }}/runtime/maca64:\
${{ env.MATLAB_PATH }}/bin/maca64:\
${{ env.MATLAB_PATH }}/sys/os/maca64:\
${{ env.MATLAB_PATH }}/extern/bin/maca64"
export PYTHONHOME=${{ env.pythonLocation }}
mwpython -m unittest discover tests -v

- name: Run tests (Mac Intel)
if: matrix.os_name == 'macOS_Intel'
run: |
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\
${{ env.MATLAB_PATH }}/runtime/maci64:\
${{ env.MATLAB_PATH }}/bin/maci64:\
${{ env.MATLAB_PATH }}/sys/os/maci64:\
${{ env.MATLAB_PATH }}/extern/bin/maci64"
export PYTHONHOME=${{ env.pythonLocation }}
mwpython -m unittest discover tests -v

- name: Run tests (Windows)
if: matrix.os_name == 'Windows'
shell: bash
run: |
export PATH="${{ env.MATLAB_PATH }}/runtime/win64:\
${{ env.MATLAB_PATH }}/bin/win64:\
${{ env.MATLAB_PATH }}/sys/os/win64:\
${{ env.MATLAB_PATH }}/extern/bin/win64\
${{ env.MATLAB_PATH }}/runtime/win32:\
${{ env.MATLAB_PATH }}/bin/win32:\
${{ env.MATLAB_PATH }}/sys/os/win32:\
${{ env.MATLAB_PATH }}/extern/bin/win32:${PATH}"
python -m unittest discover tests -v

- name: Run tests (Linux)
if: runner.os == 'Linux'
run: |
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}\
${{ env.MATLAB_PATH }}/runtime/glnxa64:\
${{ env.MATLAB_PATH }}/bin/glnxa64:\
${{ env.MATLAB_PATH }}/sys/os/glnxa64:\
${{ env.MATLAB_PATH }}/extern/bin/glnxa64"
python -m unittest discover tests -v
28 changes: 18 additions & 10 deletions .github/workflows/wrap_spm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ jobs:
wrap:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version: ["R2024b"]
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
include:
# This actions compiles by default with the newest available matlab version
version: ["latest"] # ["R2021a", "R2021b", "R2022a", "R2022b", "R2023a", "R2023b", "R2024a", "R2024b"]
os: ["ubuntu-latest", "macos-13", "macos-latest", "windows-latest"] # macos-13 has Intel architecture, macos-latest has Apple Silicon
include: # These includes are just giving the OSs additional names
- os: ubuntu-latest
os_name: Linux
- os: macos-13
os_name: macOS_Intel
- os: macos-latest
os_name: macOS_Apple_Silicon
- os: windows-latest
os_name: Windows

steps:
- name: Set up MATLAB
Expand All @@ -30,13 +36,15 @@ jobs:
- name: Run MPython
uses: matlab-actions/run-command@v2
with:
command: addpath(fullfile(pwd, .mpython)); spm_make_python;
command: |
addpath(genpath('.mpython'));
spm_make_python;


- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: runtime-${{ matrix.os }}
path: ./spm/_spm/resources/*
retention-days: 1
# - name: Upload Artifact
# uses: actions/upload-artifact@v4
# with:
# name: runtime-${{ matrix.os }}
# path: ./spm/_spm/resources/*
# retention-days: 1

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Copyright (C) 1991,1994-2024 Wellcome Centre for Human Neuroimaging
```

# Python bindings for _SPM_
[![Unit tests](https://github.com/spm/spm-python/actions/workflows/run_unit_tests.yml/badge.svg)](https://github.com/spm/spm-python/actions/workflows/run_unit_tests.yml)

## Installation instructions:
0. Install Python and Pip. Python installation made from Microsoft Store on Windows will not work (raises DeclarativeService.dll not found), intall it from Python website.
Expand Down
Loading