gitlab-ci: add scripts for use by CI
This commit is contained in:
parent
960158b90d
commit
0a5bcf97b9
3
.gitlab/ci/configure_common.cmake
Normal file
3
.gitlab/ci/configure_common.cmake
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
set(CTEST_USE_LAUNCHERS "ON" CACHE STRING "")
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/configure_sccache.cmake")
|
3
.gitlab/ci/configure_fedora31_tidy.cmake
Normal file
3
.gitlab/ci/configure_fedora31_tidy.cmake
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
set(CMake_RUN_CLANG_TIDY ON CACHE BOOL "")
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")
|
2
.gitlab/ci/configure_sccache.cmake
Normal file
2
.gitlab/ci/configure_sccache.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
set(CMAKE_C_COMPILER_LAUNCHER "sccache" CACHE STRING "")
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER "sccache" CACHE STRING "")
|
30
.gitlab/ci/ctest_build.cmake
Normal file
30
.gitlab/ci/ctest_build.cmake
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
|
||||||
|
|
||||||
|
# Read the files from the build directory.
|
||||||
|
ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
|
||||||
|
|
||||||
|
# Pick up from where the configure left off.
|
||||||
|
ctest_start(APPEND)
|
||||||
|
|
||||||
|
if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles")
|
||||||
|
include(ProcessorCount)
|
||||||
|
ProcessorCount(nproc)
|
||||||
|
set(CTEST_BUILD_FLAGS "-j${nproc}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
ctest_build(
|
||||||
|
NUMBER_WARNINGS num_warnings
|
||||||
|
RETURN_VALUE build_result)
|
||||||
|
ctest_submit(PARTS Build)
|
||||||
|
|
||||||
|
if (build_result)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Failed to build")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if ("$ENV{CTEST_NO_WARNINGS_ALLOWED}" AND num_warnings GREATER 0)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Found ${num_warnings} warnings (treating as fatal).")
|
||||||
|
endif ()
|
32
.gitlab/ci/ctest_configure.cmake
Normal file
32
.gitlab/ci/ctest_configure.cmake
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
|
||||||
|
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}")
|
||||||
|
|
||||||
|
# We can now submit because we've configured. This is a cmb-superbuild-ism.
|
||||||
|
ctest_submit(PARTS Update)
|
||||||
|
ctest_submit(PARTS Configure)
|
||||||
|
|
||||||
|
if (configure_result)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Failed to configure")
|
||||||
|
endif ()
|
6
.gitlab/ci/ctest_exclusions.cmake
Normal file
6
.gitlab/ci/ctest_exclusions.cmake
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
set(test_exclusions
|
||||||
|
)
|
||||||
|
string(REPLACE ";" "|" test_exclusions "${test_exclusions}")
|
||||||
|
if (test_exclusions)
|
||||||
|
set(test_exclusions "(${test_exclusions})")
|
||||||
|
endif ()
|
24
.gitlab/ci/ctest_test.cmake
Normal file
24
.gitlab/ci/ctest_test.cmake
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
|
||||||
|
|
||||||
|
# Read the files from the build directory.
|
||||||
|
ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
|
||||||
|
|
||||||
|
# Pick up from where the configure left off.
|
||||||
|
ctest_start(APPEND)
|
||||||
|
|
||||||
|
include(ProcessorCount)
|
||||||
|
ProcessorCount(nproc)
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/ctest_exclusions.cmake")
|
||||||
|
ctest_test(
|
||||||
|
PARALLEL_LEVEL "${nproc}"
|
||||||
|
RETURN_VALUE test_result
|
||||||
|
EXCLUDE "${test_exclusions}")
|
||||||
|
ctest_submit(PARTS Test)
|
||||||
|
|
||||||
|
if (test_result)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Failed to test")
|
||||||
|
endif ()
|
46
.gitlab/ci/gitlab_ci.cmake
Normal file
46
.gitlab/ci/gitlab_ci.cmake
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
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 ("$ENV{CI_PROJECT_PATH}" STREQUAL "cmb/smtk")
|
||||||
|
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 ()
|
Loading…
Reference in New Issue
Block a user