Skip to content

Commit 132e683

Browse files
authored
Merge pull request #553 from Remi-Gau/fix_test_main
[INFRA] fix tests main
2 parents 0911819 + 9cc7d0e commit 132e683

File tree

11 files changed

+93
-23
lines changed

11 files changed

+93
-23
lines changed

.github/workflows/matlab_workflow_script.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
cd(fullfile(root_dir, 'MOxUnit', 'MOxUnit'));
1010
run moxunit_set_path();
1111

12-
cd(fullfile(root_dir));
12+
cd(root_dir);
1313
initCppSpm();
1414
addpath(fullfile(root_dir, 'tests', 'utils'));
15+
16+
cd demos/MoAE;
17+
download_moae_ds(true);
18+
19+
cd(root_dir);
1520
run run_tests();

.github/workflows/run_tests.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,14 @@ jobs:
6363
6464
- name: Update octave path
6565
run: |
66-
octave $OCTFLAGS --eval "initCppSpm; savepath();"
67-
octave $OCTFLAGS --eval "addpath(fullfile(pwd, 'tests', 'utils')); savepath();"
66+
octave $OCTFLAGS --eval "initCppSpm; savepath(); exit;"
67+
octave $OCTFLAGS --eval "addpath(fullfile(pwd, 'tests', 'utils')); savepath(); exit;"
6868
6969
- name: Prepare data
7070
run: |
71-
inputs_folder='demos/MoAE/inputs/'
72-
mkdir $inputs_folder
73-
curl http://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.bids.zip --output $inputs_folder'MoAEpilot.zip'
74-
unzip $inputs_folder'MoAEpilot.zip' -d $inputs_folder
75-
mv $inputs_folder/MoAEpilot $inputs_folder/raw
71+
octave $OCTFLAGS --eval "initCppSpm; cd demos/MoAE; download_moae_ds(true); exit;"
7672
cd tests
77-
sh createDummyDataSet.sh
78-
cd ..
73+
make data
7974
8075
- name: Run tests
8176
run: |

.github/workflows/run_tests_matlab.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ jobs:
3939
4040
- name: Prepare data
4141
run: |
42-
inputs_folder='demos/MoAE/inputs/'
43-
mkdir $inputs_folder
44-
curl http://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.bids.zip --output $inputs_folder'MoAEpilot.zip'
45-
unzip $inputs_folder'MoAEpilot.zip' -d $inputs_folder
46-
mv $inputs_folder/MoAEpilot $inputs_folder/raw
4742
cd tests
4843
make data
4944

.github/workflows/update_submodules.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ name: update submodules
3030
on:
3131
push:
3232
branches:
33-
- main
34-
- master
3533
- dev
3634
schedule:
3735
- cron: "0 0 1 * *"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ venv/*
2020
## visual studio code
2121
.vscode
2222

23+
cfg
24+
group
25+
2326
## MATLAB / OCTAVE gitignore template
2427

2528
# From : https://github.com/github/gitignore/blob/master/Global/MATLAB.gitignore

demos/MoAE/download.m

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
function filename = download(URL, output_dir, verbose)
2+
%
3+
% USAGE::
4+
%
5+
% filename = download(URL, output_dir, verbose)
6+
%
7+
% (C) Copyright 2021 Remi Gau
8+
if nargin < 2
9+
output_dir = pwd;
10+
end
11+
12+
msg = sprintf('Downloading dataset from:\n %s\n\n', URL);
13+
print_to_screen(msg, verbose);
14+
15+
tokens = regexp(URL, '/', 'split');
16+
protocol = tokens{1};
17+
18+
filename = tokens{end};
19+
20+
if exist(filename, 'file')
21+
delete(filename);
22+
end
23+
24+
if strcmp(protocol, 'http:')
25+
26+
if isunix()
27+
if verbose
28+
system(sprintf('wget %s', URL));
29+
else
30+
system(sprintf('wget -q %s', URL));
31+
end
32+
else
33+
urlwrite(URL, filename);
34+
end
35+
36+
% move file in case it was not downloaded in the root dir
37+
if ~exist(fullfile(output_dir, filename), 'file')
38+
print_to_screen([filename ' --> ' output_dir], verbose);
39+
movefile(filename, fullfile(output_dir, filename));
40+
end
41+
filename = fullfile(output_dir, filename);
42+
43+
else
44+
45+
ftp_server = tokens{3};
46+
ftpobj = ftp(ftp_server);
47+
48+
filename = strjoin(tokens(4:end), '/');
49+
filename = mget(ftpobj, filename, output_dir);
50+
51+
end
52+
53+
if iscell(filename)
54+
filename = filename{1};
55+
end
56+
57+
print_to_screen(' Done\n\n', verbose);
58+
59+
end
60+
61+
function print_to_screen(msg, verbose)
62+
if verbose
63+
fprintf(1, msg);
64+
end
65+
end

demos/MoAE/download_moae_ds.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ function download_moae_ds(downloadData)
1717
spm_mkdir(fullfile(working_directory, 'inputs'));
1818

1919
%% Get data
20-
fprintf('%-10s:', 'Downloading dataset...');
21-
urlwrite(URL, 'MoAEpilot.zip');
22-
fprintf(1, ' Done\n\n');
20+
filename = download(URL, fullfile(working_directory, 'inputs'), true);
2321

2422
fprintf('%-10s:', 'Unzipping dataset...');
25-
unzip('MoAEpilot.zip');
26-
movefile('MoAEpilot', fullfile(working_directory, 'inputs', 'raw'));
23+
unzip(filename);
24+
if isOctave()
25+
movefile(fullfile(working_directory, 'inputs', 'MoAEpilot'), ...
26+
fullfile(working_directory, 'inputs', 'raw'));
27+
delete(filename);
28+
else
29+
movefile('MoAEpilot', fullfile(working_directory, 'inputs', 'raw'));
30+
delete(filename);
31+
end
2732
fprintf(1, ' Done\n\n');
2833

2934
end

tests/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
*/*.json
44
group/*
55
dummyData/derivatives/cpp_spm*/sub-*/
6-
dummyData/copy/
6+
dummyData/copy/
7+
bids-examples

tests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ data:
1212
rm -f bids-examples/.gitkeep
1313
git clone https://github.com/bids-standard/bids-examples.git --depth 1
1414
cp bids-examples/synthetic/dataset_description.json bids-examples/synthetic/derivatives/fmriprep
15+
touch bids-examples/.gitkeep
1516

1617
clean_openneuro:
1718
rm -rf openneuro/*

tests/bids-examples/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)