Skip to content

Commit 5c4a43d

Browse files
committed
fix tests in CI
1 parent 98a690a commit 5c4a43d

18 files changed

+155
-114
lines changed

.github/workflows/miss_hit_quality.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616

1717
steps:
1818

19-
- uses: actions/checkout@v2
19+
- name: Install CPP_ROI
20+
uses: actions/checkout@v3
2021
with:
2122
submodules: true
2223
fetch-depth: 1

.github/workflows/miss_hit_style.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616

1717
steps:
1818

19-
- uses: actions/checkout@v2
19+
- name: Install CPP_ROI
20+
uses: actions/checkout@v3
2021
with:
2122
submodules: true
2223
fetch-depth: 1

.github/workflows/run_tests.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: tests and coverage with matlab
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
- main
8+
- master
9+
pull_request:
10+
branches: ['*']
11+
schedule:
12+
- cron: "1 1 1 * *"
13+
14+
# Allows you to run this workflow manually from the Actions tab
15+
workflow_dispatch:
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-20.04
20+
21+
steps:
22+
- name: Install MATLAB
23+
uses: matlab-actions/setup-matlab@v1.0.1
24+
with:
25+
# MATLAB release to set up R2020a
26+
release: R2020a
27+
28+
- name: Install CPP_ROI
29+
uses: actions/checkout@v3
30+
with:
31+
submodules: true
32+
fetch-depth: 1
33+
34+
- name: Install SPM
35+
run: |
36+
git clone https://github.com/spm/spm12.git --depth 1
37+
38+
- name: Install Moxunit and MOcov
39+
run: |
40+
git clone https://github.com/MOxUnit/MOxUnit.git --depth 1
41+
git clone https://github.com/MOcov/MOcov.git --depth 1
42+
43+
- name: Add bids-matlab
44+
run: |
45+
git clone https://github.com/bids-standard/bids-matlab.git --depth 1
46+
47+
- name: Run commands
48+
uses: matlab-actions/run-command@v1.0.1
49+
with:
50+
command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run tests_matlab;
51+
52+
- name: Run tests
53+
run: |
54+
cat test_report.log | grep 0
55+
bash <(curl -s https://codecov.io/bash)
56+
57+
- name: Code coverage
58+
uses: codecov/codecov-action@v1
59+
with:
60+
file: coverage.xml # optional
61+
flags: unittests # optional
62+
name: codecov-umbrella # optional
63+
fail_ci_if_error: true # optional (default = false)

.github/workflows/tests_matlab.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%
2+
% (C) Copyright 2022 CPP ROI developers
3+
4+
root_dir = getenv('GITHUB_WORKSPACE');
5+
6+
addpath(fullfile(root_dir, 'spm12'));
7+
addpath(fullfile(root_dir, 'bids-matlab'));
8+
addpath(fullfile(root_dir, 'MOcov', 'MOcov'));
9+
10+
cd(fullfile(root_dir, 'MOxUnit', 'MOxUnit'));
11+
run moxunit_set_path();
12+
13+
cd(fullfile(root_dir));
14+
15+
initCppRoi();
16+
17+
run run_tests();

src/atlas/returnAtlasDir.m renamed to atlas/returnAtlasDir.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
%
1111
% (C) Copyright 2021 CPP ROI developers
1212

13-
atlasDir = fullfile(rootDir(), 'atlas');
13+
atlasDir = fileparts(mfilename('fullpath'));
1414

1515
if nargin > 0
1616

initCppRoi.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function initCppRoi()
55
global CPP_ROI_INITIALIZED
66
global CPP_ROI_PATHS
77

8-
if isempty(CPP_ROI_INITIALIZED)
8+
if isempty(CPP_ROI_INITIALIZED) || ~CPP_ROI_INITIALIZED
99

1010
% directory with this script becomes the current directory
1111
thisDirectory = fileparts(mfilename('fullpath'));
@@ -18,6 +18,8 @@ function initCppRoi()
1818
CPP_ROI_PATHS = genpath(fullfile(thisDirectory, 'src'));
1919
CPP_ROI_PATHS = cat(2, CPP_ROI_PATHS, pathSep, ...
2020
fullfile(thisDirectory, 'lib', 'marsbar-0.44'));
21+
CPP_ROI_PATHS = cat(2, CPP_ROI_PATHS, pathSep, ...
22+
fullfile(thisDirectory, 'atlas'));
2123
addpath(CPP_ROI_PATHS, '-begin');
2224

2325
marsbar('on');

run_tests.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
testFolder = fullfile(fileparts(mfilename('fullpath')), 'tests');
1010

11+
addpath(fullfile(testFolder, 'utils'));
12+
1113
folderToCover = fullfile(testFolder, '..', 'src');
1214

1315
success = moxunit_runtests( ...

src/utils/cppRoiRoot.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function pth = cppRoiRoot()
2+
%
3+
%
4+
% USAGE::
5+
%
6+
% pth = cppRoiRoot()
7+
%
8+
%
9+
% (C) Copyright 2022 CPP ROI developers
10+
11+
pth = fullfile(fileparts(mfilename('fullpath')), '..', '..');
12+
pth = spm_file(pth, 'cpath');
13+
14+
end

src/utils/rootDir.m

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/space-MNI_label-neurosynth motion_probseg.nii.gz

Whitespace-only changes.

tests/test_getLookUpTable.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ function test_lut_wang()
2323

2424
function test_lut_anat_tb()
2525

26-
lut = getLookUpTable('anatomy_toobox');
26+
if ~isGithubCi
2727

28-
assertEqual(lut.label(1), 7);
29-
assertEqual(lut.ROI{1}, 'Interposed Nucleus');
28+
lut = getLookUpTable('anatomy_toobox');
29+
30+
assertEqual(lut.label(1), 7);
31+
assertEqual(lut.ROI{1}, 'Interposed Nucleus');
32+
33+
end
3034

3135
end
3236

tests/test_thresholdToMask.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ function test_thresholdToMask_cluster()
4848

4949
function inputImage = setUp(image)
5050

51-
gzImage = spm_file(fullfile(rootDir(), 'demos', 'roi', 'inputs', image), 'cpath');
51+
rootDir = fullfile(fileparts(mfilename('fullpath')), '..');
52+
53+
gzImage = spm_file(fullfile(rootDir, 'demos', 'roi', 'inputs', image), 'cpath');
5254
[~, basename] = spm_fileparts(gzImage);
5355
gunzip(gzImage, pwd);
5456

tests/test_unit_returnAtlasDir.m

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,19 @@
88
initTestSuite;
99
end
1010

11-
function test_returnAtlasDir_no_input()
12-
13-
atlasDir = returnAtlasDir();
14-
15-
assertEqual(atlasDir, baseAtlasDir());
16-
17-
end
18-
1911
function test_returnAtlasDir_default()
2012

2113
atlasDir = returnAtlasDir('neuromorphometric');
2214

23-
assertEqual(atlasDir, baseAtlasDir());
15+
assertEqual(atlasDir, returnAtlasDir());
2416

2517
end
2618

2719
function test_returnAtlasDir_wang()
2820

2921
atlasDir = returnAtlasDir('wang');
3022

31-
expected = fullfile(baseAtlasDir(), 'visual_topography_probability_atlas');
23+
expected = fullfile(returnAtlasDir(), 'visual_topography_probability_atlas');
3224

3325
assertEqual(atlasDir, expected);
3426

@@ -43,9 +35,3 @@ function test_returnAtlasDir_anatomy_toobox()
4335
assertEqual(atlasDir, expected);
4436

4537
end
46-
47-
function baseDir = baseAtlasDir()
48-
49-
baseDir = spm_file(fullfile(rootDir(), 'atlas'), 'cpath');
50-
51-
end

tests/utils/isGithubCi.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function [IS_GITHUB, pth] = isGithubCi()
2+
%
3+
% (C) Copyright 2022 CPP ROI developers
4+
5+
IS_GITHUB = false;
6+
7+
GITHUB_WORKSPACE = getenv('HOME');
8+
9+
if strcmp(GITHUB_WORKSPACE, '/home/runner')
10+
11+
fprintf(1, '\n WE ARE RUNNING IN GITHUB CI\n');
12+
13+
IS_GITHUB = true;
14+
pth = GITHUB_WORKSPACE;
15+
16+
end
17+
18+
end

tests/utils/isOctave.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function retval = isOctave()
2+
%
3+
% Returns true if the environment is Octave.
4+
% Only in the test folder for testing purposes
5+
%
6+
% USAGE::
7+
%
8+
% retval = isOctave()
9+
%
10+
% :returns: :retval: (boolean)
11+
%
12+
% (C) Copyright 2022 CPP ROI developers
13+
14+
persistent cacheval % speeds up repeated calls
15+
16+
if isempty (cacheval)
17+
cacheval = (exist ('OCTAVE_VERSION', 'builtin') > 0);
18+
end
19+
20+
retval = cacheval;
21+
end
File renamed without changes.

0 commit comments

Comments
 (0)