Commit ae889d88 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

gitlab-ci: support submitting results to CDash

parent 0e4b5965
......@@ -27,38 +27,29 @@
# - Need to figure out how it works with gitlab-runner.
# - Is offscreen rendering suitable?
# Tags to ensure we run on SMTK-allowable runners.
.smtk_sb_tags: &smtk_sb_tags
- docker
- cmb
- linux
.fedora31: &fedora31
image: "kitware/cmb:ci-smtk-fedora31-latest"
tags: *smtk_sb_tags
tags:
- docker
- cmb
- linux
variables:
GIT_SUBMODULE_STRATEGY: recursive
CMAKE: cmake
CTEST: ctest
CMAKE_VARIABLES: >
-C /root/misc/root/smtk-deps/smtk-developer-config.cmake
-DSMTK_ENABLE_TESTING:BOOL=ON
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
-DCMAKE_C_COMPILER_LAUNCHER=sccache
CMAKE_CONFIGURATION: fedora31
SCCACHE_REDIS: redis://minmus:6379
.cmake_build_unix: &cmake_build_unix
stage: build
script:
- mkdir build
- cd build
- sccache --start-server
- sccache --show-stats
- "$CMAKE --version"
- "$LAUNCHER $CMAKE -GNinja $CMAKE_VARIABLES .."
- "$LAUNCHER $CMAKE --build . -j`nproc`"
- "$LAUNCHER $CTEST -VV -S .gitlab/ci/ctest_configure.cmake"
- "$LAUNCHER $CTEST -VV -S .gitlab/ci/ctest_build.cmake"
- sccache --show-stats
artifacts:
......@@ -87,17 +78,17 @@
- build/*/*/CTestTestfile.cmake
- build/*/*/*/CTestTestfile.cmake
- build/*/*/*/*/CTestTestfile.cmake
- build/Testing/
# CDash files.
- build/DartConfiguration.tcl
interruptible: true
.cmake_test: &cmake_test
.cmake_test_unix: &cmake_test_unix
stage: test
script:
- cd build
- "$CTEST -j`nproc` --output-on-failure"
- "$LAUNCHER $CTEST -VV -S .gitlab/ci/ctest_test.cmake"
interruptible: true
......@@ -113,7 +104,7 @@ build:fedora31:
test:fedora31:
<<:
- *fedora31
- *cmake_test
- *cmake_test_unix
dependencies:
- build:fedora31
needs:
......
set(CTEST_USE_LAUNCHERS "ON" CACHE STRING "")
set(SMTK_PUBLIC_DROP_SITE "ON" CACHE BOOL "")
set(SMTK_ENABLE_TESTING "ON" CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_sccache.cmake")
# Include the superbuild settings.
include("$ENV{SUPERBUILD_PREFIX}/smtk-developer-config.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")
set(CMAKE_C_COMPILER_LAUNCHER "sccache" CACHE STRING "")
set(CMAKE_CXX_COMPILER_LAUNCHER "sccache" CACHE STRING "")
include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
# Read the files from the build directory.
ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
include("${CMAKE_CURRENT_LIST_DIR}/ctest_submit_multi.cmake")
# Pick up from where the configure left off.
ctest_start(APPEND)
ctest_build(
RETURN_VALUE build_result)
ctest_submit_multi(PARTS Build)
if (build_result)
message(FATAL_ERROR
"Failed to build")
endif ()
include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
set(cmake_args
-C "${CMAKE_CURRENT_LIST_DIR}/configure_$ENV{CMAKE_CONFIGURATION}.cmake")
# Create an entry in CDash.
ctest_start(Experimental TRACK "${ctest_track}")
# Gather update information.
find_package(Git)
set(CTEST_UPDATE_VERSION_ONLY ON)
set(CTEST_UPDATE_COMMAND "${GIT_EXECUTABLE}")
ctest_update()
# Configure the project.
ctest_configure(
OPTIONS "${cmake_args}"
RETURN_VALUE configure_result)
# Read the files from the build directory.
ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
include("${CMAKE_CURRENT_LIST_DIR}/ctest_submit_multi.cmake")
# We can now submit because we've configured. This is a cmb-superbuild-ism.
ctest_submit_multi(PARTS Update)
ctest_submit_multi(PARTS Configure)
if (configure_result)
message(FATAL_ERROR
"Failed to configure")
endif ()
function (ctest_submit_multi)
foreach (site IN LISTS drop_sites)
foreach (variable IN ITEMS SITE METHOD LOCATION SITE_CDASH)
if (NOT DEFINED "CTEST_DROP_${variable}_${site}")
message(SEND_ERROR
"The ${site} site is missing the CTEST_DROP_${variable} "
"setting.")
endif ()
set("CTEST_DROP_${variable}" "${CTEST_DROP_${variable}_${site}}")
endforeach ()
ctest_submit(${ARGN})
endforeach ()
endfunction ()
include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
# Read the files from the build directory.
ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
include("${CMAKE_CURRENT_LIST_DIR}/ctest_submit_multi.cmake")
# Pick up from where the configure left off.
ctest_start(APPEND)
include(ProcessorCount)
ProcessorCount(nproc)
ctest_test(
PARALLEL_LEVEL "${nproc}"
RETURN_VALUE test_result)
ctest_submit_multi(PARTS Test)
if (test_result)
message(FATAL_ERROR
"Failed to test")
endif ()
if (NOT DEFINED ENV{GITLAB_CI})
message(FATAL_ERROR
"This script assumes it is being run inside of GitLab-CI")
endif ()
# Set up the source and build paths.
set(CTEST_SOURCE_DIRECTORY "$ENV{CI_PROJECT_DIR}")
set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build")
if ("$ENV{CMAKE_CONFIGURATION}" STREQUAL "")
message(FATAL_ERROR
"The CMAKE_CONFIGURATION environment variable is required to know what "
"cache initialization file to use.")
endif ()
# Set the build metadata.
set(CTEST_BUILD_NAME "$ENV{CI_PROJECT_NAME}-$ENV{CMAKE_CONFIGURATION}")
set(CTEST_SITE "gitlab-ci")
# Default to Release builds.
if (NOT "$ENV{CMAKE_BUILD_TYPE}" STREQUAL "")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_BUILD_TYPE}")
endif ()
if (NOT CTEST_BUILD_CONFIGURATION)
set(CTEST_BUILD_CONFIGURATION "Release")
endif ()
# Default to using Ninja.
if (NOT "$ENV{CMAKE_GENERATOR}" STREQUAL "")
set(CTEST_CMAKE_GENERATOR "$ENV{CMAKE_GENERATOR}")
endif ()
if (NOT CTEST_CMAKE_GENERATOR)
set(CTEST_CMAKE_GENERATOR "Ninja")
endif ()
# Determine the track to submit to.
set(ctest_track "Experimental")
if (NOT "$ENV{CI_MERGE_REQUEST_ID}" STREQUAL "")
set(ctest_track "merge-requests")
elseif (NOT "$ENV{CI_PROJECT_PATH}" STREQUAL "")
if (ENV{CI_COMMIT_REF_NAME} STREQUAL "master")
set(ctest_track "master")
elseif (ENV{CI_COMMIT_REF_NAME} STREQUAL "release")
set(ctest_track "release")
endif ()
endif ()
Markdown is supported
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