Skip to content

Commit 6c39a9f

Browse files
authored
[INFRA] run matlab CI on windows and macOS (#994)
* split octave and matlab tests * FCI * [DATALAD] Recorded changes * update submodules * skip coverage on windows * update CPP ROI * misc * update octache and spm_2_bids * update cpp_roi * fix doc install * fix typo * adapt for windows * adapt for windows * update bids matlab * fix tests and set up * update submodules * change prepare data on windows * add more informative errors * use temp dir * fix typo * fix typo * fix tests
1 parent 1dbbd07 commit 6c39a9f

File tree

22 files changed

+288
-83
lines changed

22 files changed

+288
-83
lines changed

.github/workflows/tests_matlab.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
name: tests matlab
3+
4+
# Uses the cron schedule for github actions
5+
#
6+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events
7+
#
8+
# ┌───────────── minute (0 - 59)
9+
# │ ┌───────────── hour (0 - 23)
10+
# │ │ ┌───────────── day of the month (1 - 31)
11+
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
12+
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
13+
# │ │ │ │ │
14+
# │ │ │ │ │
15+
# │ │ │ │ │
16+
# * * * * *
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
on:
23+
push:
24+
branches: ['*']
25+
pull_request:
26+
branches: ['*']
27+
schedule:
28+
- cron: 0 0 1,15 * *
29+
30+
# Allows you to run this workflow manually from the Actions tab
31+
workflow_dispatch:
32+
33+
jobs:
34+
35+
test:
36+
37+
if: github.repository_owner == 'cpp-lln-lab'
38+
39+
strategy:
40+
matrix:
41+
test_type: [system]
42+
script: [moae, facerep, fmriprep]
43+
os: [ubuntu-latest, macos-latest, windows-latest]
44+
include:
45+
- test_type: unit
46+
os: ubuntu-latest
47+
- test_type: unit
48+
os: macos-latest
49+
- test_type: unit
50+
os: windows-latest
51+
fail-fast: false
52+
53+
runs-on: ${{ matrix.os }}
54+
55+
steps:
56+
57+
- name: ${{ matrix.test_type }} test
58+
if: matrix.test_type == 'system'
59+
run: echo ${{ matrix.test_type }} test ${{ matrix.script }}
60+
61+
- name: Install dependencies
62+
if: matrix.os == 'ubuntu-latest'
63+
run: |
64+
sudo apt-get -y -qq update
65+
sudo apt-get -y install unzip wget
66+
67+
- name: Install Node
68+
uses: actions/setup-node@v3
69+
with:
70+
node-version: 18
71+
72+
- name: Install python
73+
uses: actions/setup-python@v4
74+
with:
75+
python-version: '3.11'
76+
77+
- name: Clone bidspm
78+
uses: actions/checkout@v3
79+
with:
80+
submodules: recursive
81+
fetch-depth: 0
82+
83+
- name: Install validators
84+
run: make install
85+
86+
- name: Install SPM
87+
run: |
88+
git clone https://github.com/spm/spm12.git --depth 1
89+
90+
- name: Copy Macs toolbox to SPM inputs_folder on unix
91+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
92+
run: cp -rv lib/MACS spm12/toolbox/MACS
93+
- name: Copy Macs toolbox to SPM inputs_folder on windows
94+
if: matrix.os == 'windows-latest'
95+
run: Copy-Item -Recurse -Verbose -Path ".\lib\MACS" -Destination ".\spm12\toolbox\MACS"
96+
97+
- name: Get moae fmriprep data from OSF on unix
98+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
99+
run: |
100+
mkdir -p demos/MoAE/inputs/
101+
cd demos/MoAE/inputs/
102+
wget https://osf.io/vufjs/download
103+
unzip download
104+
mv moae_fmriprep fmriprep
105+
- name: Get moae fmriprep data from OSF on windows
106+
if: matrix.os == 'windows-latest'
107+
run: |
108+
New-Item -ItemType Directory -Path ".\demos\MoAE\inputs\" -Force
109+
Set-Location -Path ".\demos\MoAE\inputs\"
110+
Invoke-WebRequest -Uri "https://osf.io/vufjs/download" -OutFile "download"
111+
Expand-Archive -Path ".\download" -DestinationPath ".\"
112+
Rename-Item -Path ".\moae_fmriprep" -NewName "fmriprep"
113+
114+
- name: Prepare test data unix
115+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
116+
run: |
117+
cd tests
118+
make data
119+
- name: Prepare test data windows
120+
if: matrix.os == 'windows-latest'
121+
run: |
122+
cd tests
123+
make create_dummy_dataset
124+
make bids_examples
125+
Invoke-WebRequest -Uri "https://files.de-1.osf.io/v1/resources/3vufp/providers/osfstorage/62ab741be6f3ec09a7e48d13/?zip=" -OutFile "moae_spm12.zip"
126+
New-Item -ItemType Directory -Path "data/MoAE/derivatives/spm12" -Force
127+
Expand-Archive -Path "./moae_spm12.zip" -DestinationPath "./data/MoAE/derivatives/spm12"
128+
129+
- name: Install Moxunit and MOcov
130+
run: |
131+
git clone https://github.com/MOxUnit/MOxUnit.git --depth 1
132+
git clone https://github.com/MOcov/MOcov.git --depth 1
133+
134+
- name: Install MATLAB
135+
uses: matlab-actions/[email protected]
136+
with:
137+
release: R2022b
138+
139+
- name: Run unit tests MATLAB
140+
if: matrix.test_type == 'unit'
141+
uses: matlab-actions/[email protected]
142+
with:
143+
command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run tests_matlab;
144+
145+
- name: Check unit tests
146+
if: matrix.test_type == 'unit' && ( matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' )
147+
run: grep -q 0 test_report.log || { echo "Some tests failed. Check the 'Run tests' step to know which ones." >&2; exit 1; }
148+
- name: Check logs windows
149+
if: matrix.test_type == 'unit' && matrix.os == 'windows-latest'
150+
run: |
151+
if (-not (Get-Content test_report.log | Select-String -Pattern "0")) {
152+
throw "Some tests failed. Check the 'Run tests' step to know which ones."
153+
}
154+
155+
- name: Code coverage matlab
156+
if: matrix.test_type == 'unit' && ( matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' )
157+
uses: codecov/codecov-action@v3
158+
with:
159+
file: coverage.xml
160+
flags: ${{ matrix.os }}_matlab-${{ matrix.version }}
161+
name: codecov-matlab
162+
fail_ci_if_error: false
163+
# token: ${{ secrets.CODECOV_TOKEN }} # not required but might help API rate limits
164+
165+
166+
- name: Run system tests MATLAB ${{ matrix.script }}
167+
if: matrix.test_type == 'system'
168+
uses: matlab-actions/[email protected]
169+
with:
170+
command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run system_tests_${{ matrix.script }};

.github/workflows/tests.yml renamed to .github/workflows/tests_octave.yml

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: tests
2+
name: tests octave
33

44
# Uses the cron schedule for github actions
55
#
@@ -43,21 +43,17 @@ jobs:
4343

4444
strategy:
4545
matrix:
46-
platform: [matlab, octave]
4746
test_type: [system]
4847
script: [moae, facerep, fmriprep]
4948
include:
5049
- test_type: unit
51-
platform: matlab
52-
- test_type: unit
53-
platform: octave
5450
fail-fast: false
5551

5652
steps:
5753

58-
- name: ${{ matrix.platform }} - ${{ matrix.test_type }} test
54+
- name: ${{ matrix.test_type }} test
5955
if: matrix.test_type == 'system'
60-
run: echo ${{ matrix.platform }} ${{ matrix.test_type }} test ${{ matrix.script }}
56+
run: echo ${{ matrix.test_type }} test ${{ matrix.script }}
6157

6258
- name: Install dependencies
6359
run: |
@@ -109,7 +105,6 @@ jobs:
109105
git clone https://github.com/MOcov/MOcov.git --depth 1
110106
111107
- name: Install octave
112-
if: matrix.platform == 'octave'
113108
run: |
114109
sudo apt-get -y -qq update
115110
sudo apt-get -y install \
@@ -124,56 +119,37 @@ jobs:
124119
make -C MOcov install
125120
126121
- name: Compile SPM
127-
if: matrix.platform == 'octave'
128122
run: |
129123
make -C spm12/src PLATFORM=octave distclean
130124
make -C spm12/src PLATFORM=octave
131125
make -C spm12/src PLATFORM=octave install
132126
octave $OCTFLAGS --eval "addpath(fullfile(pwd, 'spm12')); savepath();"
133127
134128
- name: Run unit tests Octave
135-
if: matrix.platform == 'octave' && matrix.test_type == 'unit'
129+
if: matrix.test_type == 'unit'
136130
run: |
137131
octave $OCTFLAGS --eval "addpath(fullfile(pwd, 'tests', 'utils')); savepath();"
138132
octave $OCTFLAGS --eval "bidspm(); cd demos/MoAE; download_moae_ds(true);"
139133
cd .github/workflows
140134
octave $OCTFLAGS --eval "tests_octave;"
141135
142-
- name: Install MATLAB
143-
if: matrix.platform == 'matlab'
144-
uses: matlab-actions/[email protected]
145-
with:
146-
release: R2020a
147-
148-
- name: Run unit tests MATLAB
149-
if: matrix.platform == 'matlab' && matrix.test_type == 'unit'
150-
uses: matlab-actions/[email protected]
151-
with:
152-
command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run tests_matlab;
153-
154136
- name: Check unit tests
155137
if: matrix.test_type == 'unit'
156138
run: |
157139
cat test_report.log | grep 0
158140
159-
- name: Code coverage ${{ matrix.platform }}
141+
- name: Code coverage
160142
if: matrix.test_type == 'unit'
161143
uses: codecov/codecov-action@v3
162144
with:
163145
file: coverage.xml
164-
flags: ${{ matrix.platform }}
165-
name: codecov-${{ matrix.platform }}
146+
flags: octave
147+
name: codecov-octave
166148
fail_ci_if_error: false
167149
# token: ${{ secrets.CODECOV_TOKEN }} # not required but might help API rate limits
168150

169151
- name: Run system tests octave ${{ matrix.script }}
170-
if: matrix.platform == 'octave' && matrix.test_type == 'system'
152+
if: matrix.test_type == 'system'
171153
run: |
172154
cd /home/runner/work/bidspm/bidspm/.github/workflows
173155
octave $OCTFLAGS --eval "run system_tests_${{ matrix.script }};"
174-
175-
- name: Run system tests MATLAB ${{ matrix.script }}
176-
if: matrix.platform == 'matlab' && matrix.test_type == 'system'
177-
uses: matlab-actions/[email protected]
178-
with:
179-
command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run system_tests_${{ matrix.script }};

.github/workflows/validation.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,3 @@ jobs:
3131
use-quiet-mode: yes
3232
use-verbose-mode: yes
3333
config-file: .github/workflows/mlc_config.json
34-
35-
codespell:
36-
runs-on: ubuntu-latest
37-
steps:
38-
- uses: actions/checkout@v3
39-
- uses: codespell-project/actions-codespell@master

bidspm.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,11 +589,16 @@ function run_tests()
589589
folderToCover = fullfile(pwd, 'src');
590590
testFolder = fullfile(pwd, 'tests', subfolder);
591591

592-
success = moxunit_runtests(testFolder, ...
593-
'-verbose', '-recursive', '-with_coverage', ...
594-
'-cover', folderToCover, ...
595-
'-cover_xml_file', 'coverage.xml', ...
596-
'-cover_html_dir', fullfile(pwd, 'coverage_html'));
592+
if ispc
593+
success = moxunit_runtests(testFolder, ...
594+
'-verbose', '-recursive');
595+
else
596+
success = moxunit_runtests(testFolder, ...
597+
'-verbose', '-recursive', '-with_coverage', ...
598+
'-cover', folderToCover, ...
599+
'-cover_xml_file', 'coverage.xml', ...
600+
'-cover_html_dir', fullfile(pwd, 'coverage_html'));
601+
end
597602

598603
if success
599604
system('echo 0 > test_report.log');

demos/MoAE/test_moae.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151

5252
%% preproc
5353
bids_dir = fullfile(WD, 'inputs', 'raw');
54-
output_dir = fullfile(WD, 'outputs', 'derivatives');
54+
output_dir = fullfile(tempname, 'outputs', 'derivatives');
55+
mkdir(output_dir);
5556

5657
bidspm(bids_dir, output_dir, 'subject', ...
5758
'participant_label', {'01'}, ...
@@ -83,8 +84,6 @@
8384

8485
cd(WD);
8586

86-
rmdir(fullfile(WD, 'outputs', 'derivatives'), 's');
87-
8887
% with Octave running more n-1 loop in CI is fine
8988
% but not running crashes with a segmentation fault
9089
% /home/runner/work/_temp/fb8e9d58-fa9f-4f93-8c96-387973f3632e.sh: line 2:

demos/openneuro/Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ data_ds001734:
4343
data_ds002799:
4444
mkdir -p inputs
4545
cd inputs && datalad install ///openneuro/ds002799
46-
cd inputs/ds002799/derivatives/fmriprep
47-
datalad get sub-292/*/func/*MNI152NLin2009cAsym*
48-
datalad get sub-292/*/func/*tsv
49-
datalad get sub-30[27]/*/func/*MNI152NLin2009cAsym*
50-
datalad get sub-30[27]/*/func/*tsv
46+
datalad get -d inputs/ds002799 inputs/ds002799/derivatives/fmriprep/sub-292/*/func/*MNI152NLin2009cAsym*
47+
datalad get -d inputs/ds002799 inputs/ds002799/derivatives/fmriprep/sub-292/*/func/*tsv
48+
datalad get -d inputs/ds002799 inputs/ds002799/derivatives/fmriprep/sub-30[27]/*/func/*MNI152NLin2009cAsym*
49+
datalad get -d inputs/ds002799 inputs/ds002799/derivatives/fmriprep/sub-30[27]/*/func/*tsv

lib/CPP_ROI

lib/octache

0 commit comments

Comments
 (0)