Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ea8bfd7
change workflow settings for testing
stellaprins Jul 28, 2025
abbfda7
remove test info for failed tests
stellaprins Jul 28, 2025
5d90eae
run workflow on all tests
stellaprins Jul 28, 2025
aff0b7e
refactor workflow: separate show test results and create artifact steps
stellaprins Jul 29, 2025
7d4678c
enhance display of results
stellaprins Jul 29, 2025
5d6576f
Merge branch 'ucl-bug:main' into sp/improve_CI_output_2
stellaprins Jul 29, 2025
cf0fc46
exit if test fails
stellaprins Jul 29, 2025
02f24e6
Merge branch 'sp/improve_CI_output_2' of https://github.com/stellapri…
stellaprins Jul 29, 2025
9aac0c4
run kWaveDiffusion_compare_3D_heterog tests
stellaprins Jul 29, 2025
d30bac8
replace exit with error for failed unit tests in CI integration
stellaprins Jul 29, 2025
6196596
add spacing before error message for failed unit tests in CI integration
stellaprins Jul 29, 2025
d46e934
remove unnecessary display messages after saving unit test results
stellaprins Jul 29, 2025
094d890
add failure messages and change exit to error for failed unit tests i…
stellaprins Jul 29, 2025
4764e9f
non zero exit status
stellaprins Jul 29, 2025
ceed84b
add message before exit to indicate CI detection of failed tests
stellaprins Jul 29, 2025
78621de
run on all tests
stellaprins Jul 29, 2025
1e0aeef
adjust formatting
stellaprins Jul 30, 2025
0fb5149
correct workflow triggers
stellaprins Jul 30, 2025
c808a3d
add regression tests workflow
stellaprins Jul 30, 2025
9fcad9c
only do the first regression test
stellaprins Jul 30, 2025
7c0c9bc
add optional argument to display results in runRegressionTests function
stellaprins Jul 30, 2025
959d80e
add test_info array and save error strings for regression tests
stellaprins Jul 30, 2025
e647731
add show_results to saved variables in runRegressionTests function
stellaprins Jul 30, 2025
d69208e
refactor: update regression test functions and add artifact saving
stellaprins Jul 30, 2025
b6927b0
fix: correct function name to show_test_results in unit tests workflow
stellaprins Jul 30, 2025
5875b42
reorganize regression test workflow
stellaprins Jul 30, 2025
e4b39ea
update runRegressionTests function to return test_struct
stellaprins Jul 30, 2025
ccaa55e
add path for show_test_results
stellaprins Jul 30, 2025
9163567
save artifact for regression tests
stellaprins Jul 30, 2025
988ff7f
add show_test_results path
stellaprins Jul 30, 2025
3e91729
save regression test results in test_struct.mat
stellaprins Jul 30, 2025
c965284
fix runRegressionTests input
stellaprins Jul 30, 2025
b59cde1
add all tests to one workflow
stellaprins Jul 30, 2025
5a0c32a
remove addpath
stellaprins Jul 30, 2025
df789bc
rename test workflow and add paths
stellaprins Jul 30, 2025
6f77485
add path for Generate data (regression tests)
stellaprins Jul 30, 2025
a778121
run on all regression and unit tests
stellaprins Jul 30, 2025
5931aac
replace runUnitTests_artifact with save_artifact and remove unused re…
stellaprins Jul 30, 2025
b30fe10
add correct triggers
stellaprins Jul 30, 2025
35de69d
Merge branch 'main' of https://github.com/ucl-bug/k-wave into sp/CI_r…
stellaprins Jul 30, 2025
b49cb3a
swap around the list of failed tests and summary (N failed / passed)
stellaprins Jul 30, 2025
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
125 changes: 125 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Run Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
with:
products: Signal_Processing_Toolbox
cache: true

- name: Run unit tests
uses: matlab-actions/run-command@v2
with:
command: |
addpath("${{ github.workspace }}/k-Wave");
cd("${{ github.workspace }}/k-Wave/testing/unit");
test_struct = runUnitTests("",false);
save('test_struct.mat', 'test_struct');
startup-options: -nojvm -logfile output.log

- name: Create artifact
uses: matlab-actions/run-command@v2
with:
command: |
addpath("${{ github.workspace }}/k-Wave/testing");
cd("${{ github.workspace }}/k-Wave/testing/unit");
load('test_struct.mat', 'test_struct');
save_artifact(test_struct);
startup-options: -nojvm

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: unit_test_results
path: ${{ github.workspace }}/k-Wave/testing/unit/test_results.json

- name: Test results
uses: matlab-actions/run-command@v2
with:
command: |
addpath("${{ github.workspace }}/k-Wave/testing");
cd("${{ github.workspace }}/k-Wave/testing/unit");
load('test_struct.mat', 'test_struct');
show_test_results(test_struct);
disp(' ');
disp('NOTE:');
disp('Test output details are in the "Run unit tests" section of the workflow.');
disp('You can also download a JSON summary from the "Upload Artifact" section in your CI logs or dashboard.');
startup-options: -nojvm

regression-tests:
name: Regression tests
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
with:
products: Signal_Processing_Toolbox
cache: true

- name: Generate data
uses: matlab-actions/run-command@v2
with:
command: |
addpath("${{ github.workspace }}/k-Wave");
cd("${{ github.workspace }}/k-Wave/testing/regression");
generateRegressionData
startup-options: -nojvm

- name: Run regression tests
uses: matlab-actions/run-command@v2
with:
command: |
addpath("${{ github.workspace }}/k-Wave");
cd("${{ github.workspace }}/k-Wave/testing/regression");
test_struct = runRegressionTests("${{ github.workspace }}/k-Wave/testing/regression",false);
save('test_struct.mat', 'test_struct');
startup-options: -nojvm

- name: Create artifact
uses: matlab-actions/run-command@v2
with:
command: |
addpath("${{ github.workspace }}/k-Wave/testing");
cd("${{ github.workspace }}/k-Wave/testing/regression");
load('test_struct.mat', 'test_struct');
save_artifact(test_struct);
startup-options: -nojvm

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: regression_test_results
path: ${{ github.workspace }}/k-Wave/testing/regression/test_results.json

- name: Test results
uses: matlab-actions/run-command@v2
with:
command: |
addpath("${{ github.workspace }}/k-Wave/testing");
cd("${{ github.workspace }}/k-Wave/testing/regression");
load('test_struct.mat', 'test_struct');
show_test_results(test_struct);
disp(' ');
disp('NOTE:');
disp('Test output details are in the "Run regression tests" section of the workflow.');
disp('You can also download a JSON summary from the "Upload Artifact" section in your CI logs or dashboard.');
startup-options: -nojvm
60 changes: 0 additions & 60 deletions .github/workflows/unit_tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions k-Wave/testing/regression/generateRegressionData.m
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@
load([tempdir 'generate_regression_data_TEMP_VARS']);

% move to the testing directory
if ~exist(testing_dir, 'dir'), mkdir(testing_dir); end
cd(testing_dir);

% generate computer info and add precision
Expand Down
93 changes: 32 additions & 61 deletions k-Wave/testing/regression/runRegressionTests.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function runRegressionTests(data_folder)
function test_struct = runRegressionTests(data_folder, show_results)
%RUNREGRESSIONTESTS Run MATLAB regression tests.
%
% DESCRIPTION:
Expand All @@ -18,6 +18,7 @@ function runRegressionTests(data_folder)
%
% INPUTS:
% data_folder - string of folder containing regression data
% show_results - logical flag to display results (default: true)
%
% ABOUT:
% author - Bradley Treeby
Expand All @@ -44,6 +45,11 @@ function runRegressionTests(data_folder)
%#ok<*NASGU>
%#ok<*IDISVAR>

% Set defaults for optional arguments
if nargin < 2 || isempty(show_results)
show_results = true;
end

% start the timer
regression_start_time = datetime('now');

Expand Down Expand Up @@ -77,6 +83,9 @@ function runRegressionTests(data_folder)
% keep a list of whether the test passed or failed
test_result = false(num_files, 1);

% preallocate cell array for test_info with empty strings by default
test_info = repmat({''}, num_files, 1);

% =========================================================================
% RUN TESTS
% =========================================================================
Expand All @@ -93,7 +102,7 @@ function runRegressionTests(data_folder)
save(temp_var_filename, ...
'DOUBLE_COMPARISON_THRESHOLD', 'SINGLE_COMPARISON_THRESHOLD', ...
'regression_test_folder', 'temp_var_filename', 'regression_start_time', ...
'filename_index', 'filenames', 'fn', 'num_files', 'test_result');
'filename_index', 'filenames', 'fn', 'num_files', 'test_result', 'show_results');

% display the filename
disp(' ');
Expand Down Expand Up @@ -238,10 +247,14 @@ function runRegressionTests(data_folder)
test_pass = true;
fprintf('passed');
end
% save the error string
error_str = sprintf(' (L_inf = %e)\n', L_inf);

% display the error
fprintf(' (L_inf = %e)\n', L_inf);

fprintf('%s', error_str);

% save L_inf as test_info
test_info{filename_index} = error_str;
end

% clear the variables just in case
Expand All @@ -256,69 +269,27 @@ function runRegressionTests(data_folder)

% store test result
test_result(filename_index) = test_pass_overall;

end

% =========================================================================
% DISPLAY SUMMARY
% CREATE OUTPUT
% =========================================================================

% get information about PC
completion_time = scaleTime(seconds(datetime('now') - regression_start_time));
comp_info = getComputerInfo;
info = comp_info;
info.completion_time = completion_time;

% get k-Wave version
eval('cur_dir = pwd; cd(getkWavePath(''private'')); kwave_ver = getkWaveVersion; cd(cur_dir);');

% display test header
disp(' ');
disp('-------------------------------------------------------------------------------------');
disp(' _ __ __ _____ _ ');
disp(' | | __ \ \ / /_ ___ _____ |_ _|__ ___| |_ ___ _ __ ');
disp(' | |/ /___\ \ /\ / / _` \ \ / / _ \ | |/ _ \/ __| __/ _ \ ''__|');
disp(' | <_____\ V V / (_| |\ V / __/ | | __/\__ \ || __/ | ');
disp(' |_|\_\ \_/\_/ \__,_| \_/ \___| |_|\___||___/\__\___|_| ');
disp(' ');
disp('-------------------------------------------------------------------------------------');
disp(' ');
disp(['DATE: ' comp_info.date]);
disp(['HOST NAME: ' comp_info.computer_name]);
disp(['USER NAME: ' comp_info.user_name]);
disp(['O/S TYPE: ' comp_info.operating_system_type]);
disp(['O/S: ' comp_info.operating_system]);
disp(['MATLAB VERSION: ' comp_info.matlab_version]);
disp(['TESTED K-WAVE VERSION: ' kwave_ver]);
disp(['TESTS COMPLETED IN: ' scaleTime(seconds(datetime('now') - regression_start_time))]);
disp(' ');

% display individual test results
disp('REGRESSION TEST RESULTS:');
for filename_index = 1:length(filenames)

% trim the filename and add number
fn = filenames{filename_index};
fn = [num2str(filename_index, '%02.f') ' ' fn(1:end - 4), ':'];

% add some spaces to align results
fn = sprintf('%-50s', fn);

% append the test result
if test_result(filename_index)
disp([' ' fn 'passed']);
else
disp([' ' fn 'failed']);
end
end

% display test summary
disp(' ');
if all(test_result)
disp('ALL REGRESSION TESTS PASSED!');
else
disp('REGRESSION TEST FAILED...');
end
% create results struct
test_struct = struct( ...
'info', info, ...
'results', struct('test', filenames(:), 'pass', num2cell(test_result(:)), 'test_info', test_info(:)) ...
);

disp(' ');
disp('-------------------------------------------------------------------------------------');
% =========================================================================
% SHOW RESULTS
% =========================================================================

% remove temp data
delete(temp_var_filename);
if show_results
show_test_results(test_struct);
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function runUnitTests_artifact(test_struct)
%RUNUNITTESTS_ARTIFACT
function save_artifact(test_struct)
%SAVE_ARTIFACT
%
% DESCRIPTION:
% runUnitTests_actions processes the provided test_struct, saves the results
% save_artifact processes the provided test_struct, saves the results
% as a test_results.json artifact.
%

Expand Down
Loading
Loading