diff --git a/.github/workflows/run_demos.m b/.github/workflows/run_demos.m deleted file mode 100644 index 15563e4..0000000 --- a/.github/workflows/run_demos.m +++ /dev/null @@ -1,8 +0,0 @@ -root_dir = getenv('GITHUB_WORKSPACE'); - -cd(fullfile(root_dir)); - -setup(); - -run matlab/examples/example1; -run matlab/examples/example2; \ No newline at end of file diff --git a/.github/workflows/run_demos_ci.m b/.github/workflows/run_demos_ci.m new file mode 100644 index 0000000..5cc0271 --- /dev/null +++ b/.github/workflows/run_demos_ci.m @@ -0,0 +1,22 @@ +% run demos with moxunit in github CI + +root_dir = getenv('GITHUB_WORKSPACE'); + +% MOxUnit and MOcov need to be in the matlab path +addpath(fullfile(root_dir, 'MOcov', 'MOcov')); +cd(fullfile(root_dir, 'MOxUnit', 'MOxUnit')); +run moxunit_set_path(); + +% add glm single to path +cd(root_dir) +setup(); + +this_folder = fileparts(mfilename('fullpath')); +test_folder = this_folder; +success = moxunit_runtests(test_folder, '-verbose', '-recursive'); + +if success + system('echo 0 > test_report.log'); +else + system('echo 1 > test_report.log'); +end diff --git a/.github/workflows/run_demos_matlab.yml b/.github/workflows/run_demos_matlab.yml index de8f345..3156175 100644 --- a/.github/workflows/run_demos_matlab.yml +++ b/.github/workflows/run_demos_matlab.yml @@ -20,6 +20,9 @@ name: MATLAB demos on: schedule: - cron: "0 0 1,15 * *" + push: + # TODO only run on master branch on push + branches: ["*"] jobs: demos: @@ -29,18 +32,22 @@ jobs: - name: Install MATLAB uses: matlab-actions/setup-matlab@v1.0.1 with: - # MATLAB release to set up R2020a release: R2020a - name: Shallow clone GLMsingle uses: actions/checkout@v3 with: submodules: true - fetch-depth: 0 + fetch-depth: 0 # 0 means we only get the last commit, not the whole git history + + - name: Install Moxunit and MOcov + run: | + git clone https://github.com/MOxUnit/MOxUnit.git --depth 1 + git clone https://github.com/MOcov/MOcov.git --depth 1 - name: Run commands uses: matlab-actions/run-command@v1.0.1 with: command: - cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); - run run_demos; + cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); + run run_demos_ci; diff --git a/.github/workflows/tests_matlab.m b/.github/workflows/run_tests_ci.m similarity index 71% rename from .github/workflows/tests_matlab.m rename to .github/workflows/run_tests_ci.m index 6ae96d9..95ea322 100644 --- a/.github/workflows/tests_matlab.m +++ b/.github/workflows/run_tests_ci.m @@ -1,3 +1,5 @@ +% run tests with code coverage via the run_tests scripts in the root folder. + root_dir = getenv('GITHUB_WORKSPACE'); % MOxUnit and MOcov need to be in the matlab path @@ -5,7 +7,5 @@ cd(fullfile(root_dir, 'MOxUnit', 'MOxUnit')); run moxunit_set_path(); -% adds GLM single to the path and runs all the tests -cd(fullfile(root_dir)); -setup(); +cd(root_dir) run run_tests(); diff --git a/.github/workflows/run_tests_matlab.yml b/.github/workflows/run_tests_matlab.yml index dc0fb1d..f62fdc0 100644 --- a/.github/workflows/run_tests_matlab.yml +++ b/.github/workflows/run_tests_matlab.yml @@ -40,14 +40,14 @@ jobs: - name: Download data run: make tests/data/nsdcoreexampledataset.mat - - name: Run commands + - name: Run tests uses: matlab-actions/run-command@v1.0.1 with: command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); - run tests_matlab; + run run_tests_ci; - - name: Run tests + - name: Check logs run: | cat test_report.log | grep 0 bash <(curl -s https://codecov.io/bash) diff --git a/.github/workflows/test_demos.m b/.github/workflows/test_demos.m new file mode 100644 index 0000000..be3cc99 --- /dev/null +++ b/.github/workflows/test_demos.m @@ -0,0 +1,32 @@ +function test_suite = test_demos %#ok<*STOUT> + + try % assignment of 'localfunctions' is necessary in Matlab >= 2016 + test_functions = localfunctions(); %#ok<*NASGU> + catch % no problem; early Matlab versions can use initTestSuite fine + end + + initTestSuite; + +end + +function test_demo1() + + run(fullfile(root_dir(), 'matlab', 'examples', 'example1')); + +end + +function test_demo2() + + run(fullfile(root_dir(), 'matlab', 'examples', 'example2')); + +end + +function value = root_dir() + + value = getenv('GITHUB_WORKSPACE'); + + if isempty(value) + value = fullfile(fileparts(mfilename('fullpath')), '..', '..'); + end + +end diff --git a/run_tests.m b/run_tests.m index ed4221c..9ee5f41 100644 --- a/run_tests.m +++ b/run_tests.m @@ -1,5 +1,7 @@ function run_tests() + % run tests with code coverage + tic; cd(fileparts(mfilename('fullpath')));