Update timestamps for new AMANDA simulation (17/02/2015)
[u/mrichter/AliRoot.git] / test / continuous-build.cmake
CommitLineData
eee962e6 1#****Macros****
2find_program(UNAME NAMES uname)
3macro(getuname name flag)
4 exec_program("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}")
5endmacro(getuname)
6
7#****Configuration Variables****
8#Set Project Name
9set(CTEST_PROJECT_NAME "AliRoot")
10set(ALICE_ROOT $ENV{ALICE_ROOT})
11set(ALICE_INSTALL $ENV{ALICE_INSTALL})
12
13if(NOT ALICE_INSTALL)
14message(FATAL_ERROR "Please set environment variable ALICE_INSTALL to the AliRoot installation directory")
15endif(NOT ALICE_INSTALL)
16if(NOT ALICE_ROOT)
17message(FATAL_ERROR "Please set environment variable ALICE_ROOT to the AliRoot source directory")
18endif(NOT ALICE_ROOT)
19
20#Set hostname of current machine
21find_program(HOSTNAME_CMD NAMES hostname)
22exec_program(${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME)
23set(CTEST_SITE "${HOSTNAME}")
24
25#Set build name
26getuname(osname -s)
27getuname(osrel -r)
28getuname(cpu -m)
29set(CTEST_BUILD_NAME "${osname}-${cpu}-prod")
30
31#Detect SVN and Make
32find_program(CTEST_SVN_COMMAND NAMES svn)
33find_program(MAKE NAMES make)
34find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
35set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --error-limit=yes --leak-resolution=low")
36
37#AliRoot Repository and build settings
38set(ALICE_REPO "https://alisoft.cern.ch/AliRoot/trunk")
39set(MODEL "Continuous")
40
41
42#Set Nightly build start time
43set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
44set(CTEST_TEST_TIMEOUT 0)
45#Default drop site
46set(CTEST_DROP_METHOD "http")
47set(CTEST_DROP_SITE "alirootbuildcmake.cern.ch")
61aa89dd 48set(CTEST_DROP_LOCATION "/submit.php?project=AliRoot")
eee962e6 49set(CTEST_DROP_SITE_CDASH TRUE)
50
61aa89dd 51#Ctest custom settings
52set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS "1000")
53set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS "1000")
54set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "5000")
55set(CTEST_USE_LAUNCHERS ON)
56set(BUILD_JOBS 1)
57
eee962e6 58set(OLDREV 0)
59set(NEWREV 0)
60set(CYCLE 0)
61set(CLEARCYCLE 5)
62set(TESTCYCLE 2)
63#Get Revision
64execute_process(COMMAND svn info ${ALICE_ROOT} OUTPUT_VARIABLE _svn_out )
0492edf5
A
65string(REGEX REPLACE "^.*Revision: ([^\n]*).*$" "\\1" ALIROOT_REVISION ${_svn_out})
66set(OLDREV ${ALIROOT_REVISION})
67set(NEWREV ${ALIROOT_REVISION})
eee962e6 68message("Starting build of revision ${OLDREV}")
69#Setup Directories
70set(CTEST_BINARY_DIRECTORY "${ALICE_INSTALL}")
71set(CTEST_SOURCE_DIRECTORY "${ALICE_ROOT}")
72set(CTEST_DASHBOARD_ROOT "$ENV{HOME}/Dashboards")
73# set(CTEST_CHECKOUT_COMMAND "${CTEST_SVN_COMMAND} co ${ALICE_REPO} $ENV{ALICE_ROOT}")
74set(CTEST_UPDATE_COMMAND "${CTEST_SVN_COMMAND}")
75set(CTEST_CMAKE_COMMAND "\"${CMAKE_EXECUTABLE_NAME}\" -D Continuous")
eee962e6 76#CMake Generator
77set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
78
79message("Continuous Build Starting")
80
81#****Testing Process****
82while (${CTEST_ELAPSED_TIME} LESS 36000)
83
84 set (START_TIME ${CTEST_ELAPSED_TIME})
85 ctest_start (Continuous)
86
87 #Build only if new revision of source is available
88 while(${OLDREV} EQUAL ${NEWREV} AND ${CYCLE} GREATER 0)
61aa89dd 89 message("Checking for updates...")
eee962e6 90 message("Current revision : ${OLDREV}")
91 ctest_update(BUILD "${CTEST_SOURCE_DIRECTORY}")
92 execute_process(COMMAND svn info ${ALICE_ROOT} OUTPUT_VARIABLE _svn_out)
0492edf5
A
93 string(REGEX REPLACE "^.*Revision: ([^\n]*).*$" "\\1" ALIROOT_REVISION ${_svn_out})
94 set(NEWREV ${ALIROOT_REVISION})
eee962e6 95 message("New revision : ${NEWREV}")
96 if(${OLDREV} EQUAL ${NEWREV})
97 message("Source not updated, no need to build source")
98 ctest_sleep(300)
99 endif(${OLDREV} EQUAL ${NEWREV})
100 endwhile()
f04bc3d4 101 ctest_submit (PARTS Update)
61aa89dd 102
103 #Keeping track of builds
eee962e6 104 set(OLDREV ${NEWREV})
105 math(EXPR CYCLE "${CYCLE} + 1")
106 message("Build #${CYCLE} ")
107 message("Revision : ${OLDREV}")
108 set (START_TIME ${CTEST_ELAPSED_TIME})
109 math(EXPR CLEAR "${CYCLE}%${CLEARCYCLE}")
61aa89dd 110
111 #Get CTest configuration
112 include("${CTEST_SOURCE_DIRECTORY}/CTestConfig.cmake")
113
114
eee962e6 115 #Clear build directory every CLEARCYCLE build
116 if(${CLEAR} EQUAL 0)
117 message("Clearing build directory")
118 ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
119 endif(${CLEAR} EQUAL 0)
61aa89dd 120
eee962e6 121 message(STATUS "Building source")
61aa89dd 122 foreach(subproject ${CTEST_PROJECT_SUBPROJECTS})
123 set_property(GLOBAL PROPERTY SubProject ${subproject})
124 set_property(GLOBAL PROPERTY Label ${subproject})
125 #Configure
126 ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}")
127 ctest_submit(PARTS Configure)
128 set(CTEST_BUILD_TARGET "${subproject}-all")
129 set(CTEST_BUILD_COMMAND "${MAKE} -i -j${BUILD_JOBS} ${CTEST_BUILD_TARGET}")
130 ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND)
131 ctest_submit(PARTS Build)
132 endforeach(subproject)
133
134 message("Building all")
135 set_property(GLOBAL PROPERTY SubProject)
136 set_property(GLOBAL PROPERTY Label)
137 set(CTEST_BUILD_TARGET "all")
138 ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND)
139 ctest_submit(PARTS BUILD)
eee962e6 140 #Test every other build
61aa89dd 141
eee962e6 142 math(EXPR TEST "${CYCLE}%${TESTCYCLE}")
143 if(${TEST} EQUAL 0)
144 message(STATUS "Running tests")
145 ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}")
146 endif(${TEST} EQUAL 0)
147 ctest_submit ()
148 message("Build ${CYCLE} completed")
eee962e6 149endwhile()
150
151
152
153