Commit 83512cb5 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

Merge branch 'fix/ci-script-git-hash' into 'develop'

Fix/ci script git hash

Closes #1

See merge request !13
parents 8a7d4412 b258e1e6
......@@ -19,10 +19,10 @@
# Need to be defined, for the build to run.
if(NOT DEFINED CTEST_SOURCE_DIRECTORY)
message(FATAL_ERROR "Please provide the source directory of the continuous test with the CTEST_SOURCE_DIRECTORY argument")
message(FATAL_ERROR "No source directory: please provide the path to the source directory with the CTEST_SOURCE_DIRECTORY argument")
endif()
if(NOT DEFINED CTEST_BINARY_DIRECTORY)
message(FATAL_ERROR "Please provide the build directory of the continuous test with the CTEST_BINARY_DIRECTORY argument")
message(FATAL_ERROR "No build directory: please provide the path to the build directory with the CTEST_BINARY_DIRECTORY argument")
endif()
# Script configuration, depending of the build, computer running the script
......@@ -34,27 +34,14 @@ if(CAMITK_CONTINUOUS_INTEGRATION)
string(REGEX REPLACE "^.*-(.*)-.*" "\\1" ARCH "${CAMITK_CONTINUOUS_INTEGRATION}")
string(REGEX REPLACE "^.*-.*-(.*)" "\\1" BUILDTYPE "${CAMITK_CONTINUOUS_INTEGRATION}")
else()
message(FATAL_ERROR "CAMITK_CONTINUOUS_INTEGRATION value must be given as option of the ctest command calling this script.")
message(FATAL_ERROR "No CAMITK_CONTINUOUS_INTEGRATION argument: please provide a continuous integration setting with the CAMITK_CONTINUOUS_INTEGRATION argument. It should be equals to COMPILER-ARCH-BUILDTYPE.")
endif()
# Compose with those variables the CTest required ones.
site_name(CTEST_SITE)
# get the git hash
find_package(Git QUIET)
if(GIT_FOUND)
include("${CTEST_SOURCE_DIRECTORY}/sdk/cmake/modules/macros/GetGitInfo.cmake")
set(CMAKE_SOURCE_DIR ${CTEST_SOURCE_DIRECTORY})
get_git_info(${CTEST_SOURCE_DIRECTORY})
set(CURRENT_GIT_HASH ${CAMITK_GIT_ABBREVIATED_HASH})
else()
set(CURRENT_GIT_HASH "???")
endif()
# set the build name using the compiler and commit hash
set(CTEST_BUILD_NAME ${CAMITK_CONTINUOUS_INTEGRATION}-${CURRENT_GIT_HASH})
if(UNIX)
set( CTEST_CMAKE_GENERATOR "Unix Makefiles" )
set(CTEST_CMAKE_GENERATOR "Unix Makefiles" )
elseif(WIN32)
if(COMPILER MATCHES "MinGW" OR "MINGW")
set( CTEST_CMAKE_GENERATOR "MinGW Makefiles" )
......@@ -81,7 +68,7 @@ elseif(WIN32)
elseif(COMPILER MATCHES "MSVC2017" AND ARCH MATCHES "64bits")
set( CTEST_CMAKE_GENERATOR "Visual Studio 15 2017 Win64" )
else()
message(FATAL_ERROR "CTEST COMPILER ERROR : No proper compiler found, please check ctest command syntax.")
message(FATAL_ERROR "Unknow compiler: compiler \"${COMPILER}\" unkown. Please check ctest command syntax.")
endif()
endif()
......@@ -89,13 +76,19 @@ if(BUILDTYPE)
set(CTEST_BUILD_CONFIGURATION ${BUILDTYPE})
set(CTEST_CONFIGURATION_TYPE ${BUILDTYPE})
else()
message(FATAL_ERROR "NO BUILD TYPE : Please provide a build type: Debug or Release")
message(FATAL_ERROR "No build type: please provide a valid build type: Debug or Release.")
endif()
# get the git hash
find_package(Git QUIET)
if(GIT_FOUND)
include("${CTEST_SOURCE_DIRECTORY}/sdk/cmake/modules/macros/GetGitInfo.cmake")
else()
message(FATAL_ERROR "Git command not found: please install git.")
endif()
# Update source code and send reports
set( CTEST_UPDATE_COMMAND "git")
set(CTEST_GIT_COMMAND ${GIT_EXECUTABLE})
set(CTEST_UPDATE_COMMAND ${CTEST_GIT_COMMAND})
set(CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
# CMake configuration (put here all the configure flags)
set(CTEST_CONFIGURE_COMMAND "${CMAKE_COMMAND} -Wno-dev -G \"${CTEST_CMAKE_GENERATOR}\"")
......@@ -129,43 +122,51 @@ while (${CTEST_ELAPSED_TIME} LESS ${CONTINUOUS_BUILD_DURATION})
ctest_update(SOURCE ${CTEST_SOURCE_DIRECTORY} RETURN_VALUE count)
if (count GREATER 0) # We have updated source code, thus configure and build modified files
# show update reports if there is a change in the source code
ctest_submit(PARTS Update Notes)
# Configure the whole camitk project and send configure report on the server
ctest_configure()
ctest_submit(PARTS Configure)
# Get subprojects listing (automatically created at configuration step)
include("${CTEST_BINARY_DIRECTORY}/Subprojects.cmake")
# Update CDash configuration to the server
# Project.xml file is automatically generated. If someone added an extension to CamiTK, CDash will automatically be updated according to it.
# To do this, send this file to the server
ctest_submit(FILES "${CTEST_BINARY_DIRECTORY}/Project.xml")
# Build each subprojects
foreach(subproject ${CAMITK_SUBPROJECTS})
# tag sub project, tag are used to sort projects according to tests
set_property(GLOBAL PROPERTY SubProject ${subproject})
set_property(GLOBAL PROPERTY Label ${subproject})
# build each sub project
set(CTEST_BUILD_TARGET ${subproject})
ctest_build()
ctest_submit(PARTS Build)
# Run tests
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" INCLUDE_LABEL "${subproject}")
ctest_submit(PARTS Test)
endforeach(subproject)
# Install locally this build version of CamiTK
set(CTEST_BUILD_TARGET sdk_local_install)
ctest_build()
ctest_submit(PARTS Install)
# update revision number
get_git_info(${CTEST_SOURCE_DIRECTORY})
set(CURRENT_GIT_HASH ${CAMITK_GIT_ABBREVIATED_HASH})
# set the build name using the compiler and commit hash
set(CTEST_BUILD_NAME ${CAMITK_CONTINUOUS_INTEGRATION}-${CURRENT_GIT_HASH})
# show update reports if there is a change in the source code
ctest_submit(PARTS Update Notes)
# Configure the whole camitk project and send configure report on the server
ctest_configure()
ctest_submit(PARTS Configure)
# Get subprojects listing (automatically created at configuration step)
include("${CTEST_BINARY_DIRECTORY}/Subprojects.cmake")
# Update CDash configuration to the server
# Project.xml file is automatically generated. If someone added an extension to CamiTK, CDash will automatically be updated according to it.
# To do this, send this file to the server
ctest_submit(FILES "${CTEST_BINARY_DIRECTORY}/Project.xml")
# Build each subprojects
foreach(subproject ${CAMITK_SUBPROJECTS})
# tag sub project, tag are used to sort projects according to tests
set_property(GLOBAL PROPERTY SubProject ${subproject})
set_property(GLOBAL PROPERTY Label ${subproject})
# build each sub project
set(CTEST_BUILD_TARGET ${subproject})
ctest_build()
ctest_submit(PARTS Build)
# Run tests
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" INCLUDE_LABEL "${subproject}")
ctest_submit(PARTS Test)
endforeach(subproject)
# Install locally this build version of CamiTK
set(CTEST_BUILD_TARGET sdk_local_install)
ctest_build()
ctest_submit(PARTS Install)
endif ()
message(STATUS "Waiting for GIT change")
......
......@@ -37,20 +37,6 @@ endif()
# Compose with those variables the CTest required ones.
site_name(CTEST_SITE)
# get the git hash
find_package(Git QUIET)
if(GIT_FOUND)
include("${CTEST_SOURCE_DIRECTORY}/sdk/cmake/modules/macros/GetGitInfo.cmake")
set(CMAKE_SOURCE_DIR ${CTEST_SOURCE_DIRECTORY})
get_git_info(${CTEST_SOURCE_DIRECTORY})
set(CURRENT_GIT_HASH ${CAMITK_GIT_ABBREVIATED_HASH})
else()
set(CURRENT_GIT_HASH "???")
endif()
# set the build name using the compiler and commit hash
set(CTEST_BUILD_NAME ${CAMITK_CONTINUOUS_INTEGRATION}-${CURRENT_GIT_HASH})
if(UNIX)
set( CTEST_CMAKE_GENERATOR "Unix Makefiles" )
elseif(WIN32)
......@@ -90,23 +76,30 @@ else()
message(FATAL_ERROR "NO BUILD TYPE : Please provide a build type: Debug or Release")
endif()
# get the git hash
find_package(Git QUIET)
if(GIT_FOUND)
include("${CTEST_SOURCE_DIRECTORY}/sdk/cmake/modules/macros/GetGitInfo.cmake")
else()
message(FATAL_ERROR "Git command not found: please install git.")
endif()
# Update source code and send reports
set(CTEST_GIT_COMMAND ${GIT_EXECUTABLE})
if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}")
set(CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} clone https://forge.imag.fr/anonscm/git/camitk/camitk.git ${CTEST_SOURCE_DIRECTORY}")
set(CTEST_CHECKOUT_COMMAND "${GIT_EXECUTABLE} clone https://gricad-gitlab.univ-grenoble-alpes.fr/CamiTK/CamiTK.git ${CTEST_SOURCE_DIRECTORY}")
endif()
set(CTEST_UPDATE_COMMAND ${CTEST_GIT_COMMAND})
set(CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
# CMake configuration (put here all the configure flags)
set( CTEST_CONFIGURE_COMMAND "${CMAKE_COMMAND} -Wno-dev -G \"${CTEST_CMAKE_GENERATOR}\"")
set( CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION}")
set(CTEST_CONFIGURE_COMMAND "${CMAKE_COMMAND} -Wno-dev -G \"${CTEST_CMAKE_GENERATOR}\"")
set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION}")
if(COMPILER MATCHES "MSVC2010" AND ARCH MATCHES "64bits") # Do not compile MML and PhysicalModel until libxml2 MSVC2010 x64 bug remains.
set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DACTION_MML=FALSE -DCOMPONENT_MML=FALSE -DCOMPONENT_PHYSICALMODEL=FALSE")
endif()
set( CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DCEP_IMAGING=TRUE -DCEP_MODELING=TRUE -DCEP_TUTORIALS=TRUE -DAPIDOC_SDK=TRUE -DCAMITK_DISABLE_TRANSLATION=TRUE ${CTEST_SOURCE_DIRECTORY}")
set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DCEP_IMAGING=TRUE -DCEP_MODELING=TRUE -DCEP_TUTORIALS=TRUE -DAPIDOC_SDK=TRUE -DCAMITK_DISABLE_TRANSLATION=TRUE ${CTEST_SOURCE_DIRECTORY}")
# -DCAMITK_INSTALL_ROOT=${CTEST_BINARY_DIRECTORY}
# to get CDash server configuration :
......@@ -118,6 +111,14 @@ ctest_start(Nightly)
# Update source code
ctest_update(SOURCE ${CTEST_SOURCE_DIRECTORY} RETURN_VALUE count)
# update revision number
get_git_info(${CTEST_SOURCE_DIRECTORY})
set(CURRENT_GIT_HASH ${CAMITK_GIT_ABBREVIATED_HASH})
# set the build name using the compiler and commit hash
set(CTEST_BUILD_NAME ${CAMITK_CONTINUOUS_INTEGRATION}-${CURRENT_GIT_HASH})
if(count GREATER 0)
# We only show update when there is change (avoid the CDash u=1 bug with no errors report)
ctest_submit(PARTS Update Notes)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment