From 7be30eff26c8b2e70aae62330e16126054ef93ed Mon Sep 17 00:00:00 2001 From: Will Graham <32364977+willGraham01@users.noreply.github.com> Date: Wed, 10 May 2023 12:24:58 +0100 Subject: [PATCH] Update CI to produce unit test `.mat` and `.hdf5` data (#289) * Move content of benchmark_scripts readme into doc/developers * Update CI attempt 1 * Actually use the right syntax * Force python version to prevent MacOS using python2.7 * Rename files to better match the data they produce * Aplease windows syntax * Remove pip cache due to known windows bug: https://github.com/actions/setup-python/issues/436 --- .github/workflows/ci.yml | 24 +++++++++++++++--- doc/developers.md | 6 ++--- ..._object_data.m => create_bad_class_data.m} | 0 ...tdms_object_data.m => create_class_data.m} | 0 ..._hdf5_data.py => create_hdf5_test_file.py} | 0 .../unit/benchmark_scripts/setup_unit_tests.m | 4 +-- .../unit_test_data/hdf5_test_file.hdf5 | Bin 5024 -> 0 bytes 7 files changed, 25 insertions(+), 9 deletions(-) rename tdms/tests/unit/benchmark_scripts/{create_bad_tdms_object_data.m => create_bad_class_data.m} (100%) rename tdms/tests/unit/benchmark_scripts/{create_tdms_object_data.m => create_class_data.m} (100%) rename tdms/tests/unit/benchmark_scripts/{create_hdf5_data.py => create_hdf5_test_file.py} (100%) delete mode 100644 tdms/tests/unit/benchmark_scripts/unit_test_data/hdf5_test_file.hdf5 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03071ef72..80a88328a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,10 +54,10 @@ jobs: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v1.2.3 - - name: Produce MATLAB unit test data - uses: matlab-actions/run-command@v1 + - name: Setup Python + uses: actions/setup-python@v4 with: - command: cd('tdms/tests/unit/benchmark_scripts/'), setup_unit_tests + python-version: '3.9' # ------------------------------------------------------------------------------- # Ubuntu @@ -65,7 +65,7 @@ jobs: if: ${{ contains(matrix.os, 'ubuntu') }} run: | sudo apt-get update - sudo apt-get install libfftw3-dev libhdf5-dev libgomp1 python3 + sudo apt-get install libfftw3-dev libhdf5-dev libgomp1 # ------------------------------------------------------------------------------- # Windows @@ -125,6 +125,20 @@ jobs: run: | cmake --build . --config ${{ matrix.build_type }} + # ------------------------------------------------------------------------------- + # Unit tests + - name: Produce MATLAB unit test data + if: matrix.build_testing == 'ON' + uses: matlab-actions/run-command@v1 + with: + command: cd('tdms/tests/unit/benchmark_scripts/'), setup_unit_tests + + - name: Produce hdf5 unit test data + if: matrix.build_testing == 'ON' + run: | + pip install -r ${{ github.workspace }}/tdms/tests/requirements.txt + python ${{ github.workspace }}/tdms/tests/unit/benchmark_scripts/create_hdf5_test_file.py + - name: Run TDMS unit tests if: matrix.build_testing == 'ON' working-directory: ${{ runner.workspace }}/build @@ -133,6 +147,8 @@ jobs: export OMP_NUM_THREADS=1 ctest -C ${{ matrix.build_type }} --output-on-failure --extra-verbose + # ------------------------------------------------------------------------------- + # Upload build artefact for system tests - name: Tar the build result to maintain permissions # https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files # https://github.com/actions/upload-artifact/issues/38 diff --git a/doc/developers.md b/doc/developers.md index 4d256c86b..3bbc2506a 100644 --- a/doc/developers.md +++ b/doc/developers.md @@ -225,10 +225,10 @@ A number of unit tests require the presence of a `.mat` or `.hdf5` file to read/ The locations of these files are coded into `tests/include/unit_test_utils.h`, but the files themselves are not committed to the repository. You can create the data files locally by running the `setup_unit_tests.m` and `create_hdf5_data.py` scripts locally when you wish to run the unit tests - the CI does this automatically on GitHub. Additional data can be "added" to that available to the unit tests by editing the content of the following scripts: -- `create_hdf5_data.py` : Produces `hdf5_test_file.hdf5`; used when testing read/writing from `.hdf5` files. +- `create_hdf5_test_file.py` : Produces `hdf5_test_file.hdf5`; used when testing read/writing from `.hdf5` files. - `create_structure_array.m` : Produces `structure_array.mat`; used when testing reading/writing MATLAB `struct` arrays. -- `create_tdms_object_data.m` : Produces `class_data.mat`; used when testing reading/writing `tdms` objects to/from `.mat` files. -- `create_bad_tdms_object_data.m` : Produces `bad_class_data.mat`; used for testing failure cases when reading/writing `tdms` objects to/from `.mat` files. +- `create_class_data.m` : Produces `class_data.mat`; used when testing reading/writing `tdms` objects to/from `.mat` files. +- `create_bad_class_data.m` : Produces `bad_class_data.mat`; used for testing failure cases when reading/writing `tdms` objects to/from `.mat` files. The `benchmark_` scripts perform band-limited interpolation (BLi) using `MATLAB`'s `interp` function. `TDMS`'s interpolation schemes are based off this `MATLAB` function (specficially, in the coefficients the scheme uses to interpolate), and are thus used to benchmark the accuracy of the scheme. diff --git a/tdms/tests/unit/benchmark_scripts/create_bad_tdms_object_data.m b/tdms/tests/unit/benchmark_scripts/create_bad_class_data.m similarity index 100% rename from tdms/tests/unit/benchmark_scripts/create_bad_tdms_object_data.m rename to tdms/tests/unit/benchmark_scripts/create_bad_class_data.m diff --git a/tdms/tests/unit/benchmark_scripts/create_tdms_object_data.m b/tdms/tests/unit/benchmark_scripts/create_class_data.m similarity index 100% rename from tdms/tests/unit/benchmark_scripts/create_tdms_object_data.m rename to tdms/tests/unit/benchmark_scripts/create_class_data.m diff --git a/tdms/tests/unit/benchmark_scripts/create_hdf5_data.py b/tdms/tests/unit/benchmark_scripts/create_hdf5_test_file.py similarity index 100% rename from tdms/tests/unit/benchmark_scripts/create_hdf5_data.py rename to tdms/tests/unit/benchmark_scripts/create_hdf5_test_file.py diff --git a/tdms/tests/unit/benchmark_scripts/setup_unit_tests.m b/tdms/tests/unit/benchmark_scripts/setup_unit_tests.m index f8ae1c0b6..e38e5b14d 100644 --- a/tdms/tests/unit/benchmark_scripts/setup_unit_tests.m +++ b/tdms/tests/unit/benchmark_scripts/setup_unit_tests.m @@ -3,7 +3,7 @@ end create_structure_array; -create_tdms_object_data; -create_bad_tdms_object_data; +create_class_data; +create_bad_class_data; exit; diff --git a/tdms/tests/unit/benchmark_scripts/unit_test_data/hdf5_test_file.hdf5 b/tdms/tests/unit/benchmark_scripts/unit_test_data/hdf5_test_file.hdf5 deleted file mode 100644 index c96da6360da2a34823babfd58eee815736a94a87..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5024 zcmeHKOHKko5UplJN7Mw=1u-s&F@^)MV8@t%VWmc0xC4|)B=M8LXjrnu9Y=8KQ9K4m z@CMjD^=cA_fWd^Q*geU-uIlQBemth%JXgy{8>yWXndZ8*MCq_Aw-MUQ7H1@u@j5yR z*ayBQxTDBiL|NoBSU+BOaaO62u9Wo!F^z^v?zxh%_^%kKRt`_ihA**e(bF4rCSh$$Ug!q8{7Sz?2-oU&#vfoo%H#SiVqbmeN4ELoUk49u zt>93-M0bs#-Rjnw506*3zAg&<`;H!uV$pX_7Kq{b@k!ZeSag?zZe?Cv$Fb=)1Otka z{44=+3MZOUoLEPlprg+@Gm_TCGxuItk<^jNClZNpqKkDL)mseP@(2iybh0}p_NHt+T2b1Yg0ECZGS%YbFzZ!<9NE7>V2wug})kaJ)B zfyBmv8SjwEl_H;6Sfj!S24b?`98U0?-5(`%oDY6eQVu&L*}wQBi3Q{N@AKoqO4Vb0 J+{EJfh9ASvY!?6k