Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Setup a CMake job for MSYS2/MinGW #2917

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
75 changes: 70 additions & 5 deletions .github/workflows/run_tests_win_mingw.yml
MehdiChinoune marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

name: Run MSYS2, MinGW64-based Tests (Not Visual Studio)

env:
CPPFLAGS: "-D_BSD_SOURCE"

on: [pull_request,workflow_dispatch]

concurrency:
Expand All @@ -20,6 +17,9 @@ jobs:
build-and-test-autotools:

runs-on: windows-latest
strategy:
matrix:
msystem: [ MINGW64, UCRT64] #, CLANG64 ]
defaults:
run:
shell: msys2 {0}
Expand All @@ -29,9 +29,10 @@ jobs:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
msystem: ${{ matrix.msystem }}
update: true
install: git mingw-w64-x86_64-toolchain automake libtool autoconf make cmake mingw-w64-x86_64-hdf5 unzip mingw-w64-x86_64-libxml2 mingw-w64-x86_64-zlib
pacboy: cc:p autotools:p hdf5:p curl:p libxml2:p zlib:p blosc:p bzip2:p
install: diffutils m4 git unzip

###
# Configure and build
Expand Down Expand Up @@ -73,3 +74,67 @@ jobs:
path: |
*/*.log
*/*.trs

build-and-test-cmake:

runs-on: windows-latest
strategy:
matrix:
msystem: [ MINGW64, UCRT64] #, CLANG64 ]
defaults:
run:
shell: msys2 {0}

steps:

- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
pacboy: cc:p cmake:p hdf5:p curl:p libxml2:p zlib:p blosc:p bzip2:p
install: make m4 diffutils git unzip

###
# Configure and build
###

- name: (CMake) Configure Build
run: |
LDFLAGS="-Wl,--export-all-symbols" \
cmake \
-G"MSYS Makefiles" \
-B build \
-S . \
-DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
-DBUILD_SHARED_LIBS=ON \
-DNETCDF_ENABLE_NETCDF_4=ON \
-DNETCDF_ENABLE_DAP=ON \
-DNETCDF_BUILD_UTILITIES=ON \
-DNETCDF_ENABLE_TESTS=ON \
-DNETCDF_ENABLE_HDF5=ON \
-DNETCDF_ENABLE_DAP=TRUE \
-DNETCDF_ENABLE_NCZARR=TRUE \
-DNETCDF_ENABLE_DAP_LONG_TESTS=TRUE \
-DNETCDF_ENABLE_PLUGINS=ON
if: ${{ success() }}

- name: (CMake) Look at CMakeCache.txt if error
run: cat build/CMakeCache.txt
if: ${{ failure() }}

- name: (CMake) Print Summary
run: cat build/libnetcdf.settings

- name: (CMake) Build All
run: cmake --build build -j$(nproc)
if: ${{ success() }}

- name: (CMake) Run Tests
run: PATH=$PWD/build:$PATH ctest --test-dir build
if: ${{ success() }}

- name: (CMake) Verbose output of CTest failures
run: >-
PATH=$PWD/build:$PATH ctest --test-dir build --output-on-failure -j$(nproc) --rerun-failed -VV
if: ${{ failure() }}
8 changes: 4 additions & 4 deletions cmake/netcdf_functions_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ macro(add_bin_env_temp_large_test prefix F)
endif()

add_test(${prefix}_${F} bash "-c" "TEMP_LARGE=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${prefix}_${F}")
if(MSVC)
if(WIN32)
set_property(TARGET ${prefix}_${F} PROPERTY FOLDER "tests")
set_target_properties(${prefix}_${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
Expand Down Expand Up @@ -163,7 +163,7 @@ endmacro()
macro(add_bin_test_no_prefix F)
build_bin_test(${F} ${ARGN})
add_test(${F} ${EXECUTABLE_OUTPUT_PATH}/${F})
if(MSVC)
if(WIN32)
set_property(TEST ${F} PROPERTY FOLDER "tests/")
set_target_properties(${F} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Expand All @@ -176,7 +176,7 @@ endmacro()
# Binary tests which are used by a script looking for a specific name.
macro(build_bin_test_no_prefix F)
build_bin_test(${F})
if(MSVC)
if(WIN32)
#SET_PROPERTY(TEST ${F} PROPERTY FOLDER "tests/")
set_target_properties(${F} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Expand All @@ -201,7 +201,7 @@ macro(add_bin_test prefix F)
add_test(${prefix}_${F}
${EXECUTABLE_OUTPUT_PATH}/${prefix}_${F}
)
if(MSVC)
if(WIN32)
set_property(TEST ${prefix}_${F} PROPERTY FOLDER "tests/")
set_target_properties(${prefix}_${F}
PROPERTIES
Expand Down
4 changes: 2 additions & 2 deletions hdf4_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.hdf4)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
IF(MSVC)
IF(WIN32)
FILE(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/)
ENDIF()

IF(USE_HDF4_FILE_TESTS AND NOT MSVC)
IF(USE_HDF4_FILE_TESTS AND NOT WIN32)
build_bin_test_no_prefix(tst_interops2)
build_bin_test_no_prefix(tst_interops3)
add_bin_test(hdf4_test tst_chunk_hdf4)
Expand Down
6 changes: 3 additions & 3 deletions nc_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ set_property(TARGET nc_test PROPERTY UNITY_BUILD OFF)
# Some extra stand-alone tests
SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta tst_inq_type tst_utf8_phrases tst_global_fillval tst_max_var_dims tst_formats tst_def_var_fill tst_err_enddef tst_default_format)

IF(NOT MSVC)
IF(NOT WIN32)
SET(TESTS ${TESTS} tst_utf8_validate)
ENDIF()

Expand All @@ -77,7 +77,7 @@ ENDIF()

IF(LARGE_FILE_TESTS)
SET(TESTS ${TESTS} quick_large_files tst_big_var6 tst_big_var2 tst_big_rvar tst_big_var tst_large tst_large_cdf5)
IF(NOT MSVC)
IF(NOT WIN32)
SET(TESTS ${TESTS} large_files)
ENDIF()

Expand Down Expand Up @@ -134,7 +134,7 @@ ENDIF(NETCDF_BUILD_UTILITIES)
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
IF(MSVC)
IF(WIN32)
#MESSAGE(STATUS "XXX")
#MESSAGE(STATUS "${COPY_FILES}")
#MESSAGE(STATUS "${RUNTIME_OUTPUT_DIRECTORY}")
Expand Down
8 changes: 5 additions & 3 deletions nc_test4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ IF(USE_HDF5 AND NETCDF_ENABLE_FILTER_TESTING)
build_bin_test(test_filter_order)
build_bin_test(test_filter_repeat)
build_bin_test(tst_filter_vlen)
ADD_SH_TEST(nc_test4 tst_filter)
if(NOT MINGW)
ADD_SH_TEST(nc_test4 tst_filter)
endif()
ADD_SH_TEST(nc_test4 tst_specific_filters)
ADD_SH_TEST(nc_test4 tst_bloscfail)
ADD_SH_TEST(nc_test4 tst_filter_vlen)
Expand Down Expand Up @@ -78,7 +80,7 @@ ENDIF(${HDF5_VERSION} VERSION_GREATER "1.10.0")
BUILD_BIN_TEST(tst_empty_vlen_unlim)
ADD_SH_TEST(nc_test4 run_empty_vlen_test)

IF(NOT MSVC)
IF(NOT WIN32)
SET(NC4_TESTS ${NC4_TESTS} tst_interops5 tst_camrun)
ENDIF()

Expand All @@ -104,7 +106,7 @@ ENDIF()
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/ref_bzip2.c ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.h5 ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
IF(MSVC)
IF(WIN32)
FILE(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/)
ENDIF()

Expand Down
2 changes: 1 addition & 1 deletion ncdap_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ IF(NETCDF_ENABLE_TESTS)
ENDIF(HAVE_BASH)
ENDIF()

IF(NOT MSVC)
IF(NOT WIN32)
add_bin_env_test(ncdap t_dap3a)
add_bin_env_test(ncdap test_cvt)
add_bin_env_test(ncdap test_vara)
Expand Down
8 changes: 4 additions & 4 deletions ncdump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ endif(NETCDF_ENABLE_DAP)
####
# We have to do a little tweaking
# to remove the Release/ and Debug/ directories
# in MSVC builds. This is required to get
# in Windows builds. This is required to get
# test scripts to work.
####

if(MSVC)
if(WIN32)
macro(setbinprops name)
set_target_properties(${name}
PROPERTIES
Expand Down Expand Up @@ -127,7 +127,7 @@ endif()
target_link_libraries(tst_fileinfo netcdf ${ALL_TLL_LIBS})
ENDIF()

IF(MSVC)
IF(WIN32)
set_target_properties(rewrite-scalar
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Expand Down Expand Up @@ -180,7 +180,7 @@ endif()
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}
)
endif(USE_HDF5)
endif(MSVC)
endif(WIN32)

# Build support programs
build_bin_test_no_prefix(tst_utf8)
Expand Down
4 changes: 2 additions & 2 deletions ncgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ TARGET_LINK_LIBRARIES(ncgen netcdf ${ALL_TLL_LIBS})
####
# We have to do a little tweaking
# to remove the Release/ and Debug/ directories
# in MSVC builds. This is required to get
# in Windows builds. This is required to get
# test scripts to work.
####
IF(MSVC)
IF(WIN32)
SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
Expand Down
8 changes: 5 additions & 3 deletions nczarr_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ IF(NETCDF_ENABLE_TESTS)
TARGET_LINK_LIBRARIES(tst_pure_awssdk ${AWSSDK_CORE_LIB_FILE})
ADD_TEST(tst_pure_awssdk ${EXECUTABLE_PUTPUT_PATH}/tst_pure_awssdk)
SET(F tst_pure_awssdk)
IF(MSVC)
IF(WIN32)
SET_PROPERTY(TEST ${F} PROPERTY FOLDER "tests/")
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_CURRENT_BINARY_DIR})
ENDIF(MSVC)
ENDIF(WIN32)

SET(CMAKE_CXX_STANDARD ${TMP_CMAKE_CXX_STANDARD})
ENDIF(NETCDF_ENABLE_S3_AWS)
Expand Down Expand Up @@ -210,7 +210,9 @@ IF(NETCDF_ENABLE_TESTS)
build_bin_test(testfilter_order)
build_bin_test(testfilter_repeat)
ADD_SH_TEST(nczarr_test run_nczfilter)
ADD_SH_TEST(nczarr_test run_filter)
if(NOT MINGW)
ADD_SH_TEST(nczarr_test run_filter)
endif()
ADD_SH_TEST(nczarr_test run_specific_filters)
ADD_SH_TEST(nczarr_test run_filter_vlen)
IF(FALSE)
Expand Down
4 changes: 2 additions & 2 deletions unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ IF(USE_X_GETOPT)
ENDIF()

IF(NETCDF_ENABLE_HDF5)
IF(NOT MSVC)
IF(NOT WIN32)
add_bin_test(unit_test tst_nclist)
add_bin_test(unit_test tst_nc4internal)
ENDIF(NOT MSVC)
ENDIF(NOT WIN32)
build_bin_test(tst_reclaim ${XGETOPTSRC})
add_sh_test(unit_test run_reclaim_tests)
ENDIF(NETCDF_ENABLE_HDF5)
Expand Down
Loading