From 596268a40bcc67ddf0340cd0960f5c7717056ef6 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 10 Aug 2021 09:49:43 -0600 Subject: [PATCH 01/11] Fix copy and paste error for build name in tribits_ctest_driver() test (#278) This was created by commit: 49d9c81 "tribits_ctest_driver(): Use more robust and better git commands and stronger testing (#278, TRIL-260)" Author: Roscoe A. Bartlett Date: Thu Feb 14 13:42:11 2019 -0700 A test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt --- test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt index 346397c9f..b066da0e9 100644 --- a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt @@ -453,7 +453,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_custom_branch_rem TribitsExMetaProj_ENABLE_SECONDARY_TESTED_CODE=TRUE TribitsExMetaProj_GIT_REPOSITORY_REMOTE=github TribitsExMetaProj_BRANCH=for-testing - CTEST_BUILD_NAME=CTestDriver_TribitsExMetaProj_clone_default_branch_remote + CTEST_BUILD_NAME=CTestDriver_TribitsExMetaProj_clone_custom_branch_remote ${CTEST_S_SCRIPT_ARGS} PASS_REGULAR_EXPRESSION_ALL "-- ENV_TribitsExMetaProj_BRANCH='for-testing'" From ceb31e2ef852a417a17f8d83dfd39af0b15c4aea Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 10 Aug 2021 10:05:36 -0600 Subject: [PATCH 02/11] Fix typos and comments from previous commit (#278) This were fixes from the previous comment: 49d9c81 "tribits_ctest_driver(): Use more robust and better git commands and stronger testing (#278, TRIL-260)" Author: Roscoe A. Bartlett Date: Thu Feb 14 13:42:11 2019 -0700 --- .../ctest_driver/TribitsExampleMetaProject/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt index b066da0e9..a5b267c41 100644 --- a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt @@ -264,7 +264,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re ALWAYS_FAIL_ON_NONZERO_RETURN TEST_11 - MESSAGE "Run ctest driver with an on branch 'for-testing'" + MESSAGE "Run ctest driver on branch 'for-testing'" CMND env ARGS CTEST_DASHBOARD_ROOT=PWD @@ -315,7 +315,11 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re # * Makes sure some git commit SHA1s are shown in 'Old/New revision of # repository' printouts from ctest_update(). # - # * ??? + # NOTE: The reason that so many tests are done in a single ctest test is the + # cost of the initial configure which checks the compilers which is very + # expensive. The other runs use + # CTEST_START_WITH_EMPTY_BINARY_DIRECTORY=FALSE and CTEST_WIPE_CACHE=FALSE + # to avoid this cost. # # NOTE: The reason that so many tests are done in a single ctest test is the # cost of the initial configure which checks the compilers which is very From 42b32e9c8b5f8be987f08c80303b483503416633 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 27 Jul 2021 16:56:15 -0600 Subject: [PATCH 03/11] Add support for CTEST_UPDATE_VERSION_ONLY (#154) Can turn this on for things like GitHub Actions and other processes that take care of the repo versioning. This allows you to call ctest_update() and provide a link back to the commit on GitHub but not have ctest do any update action. This also removes the CTEST_UPDATE_COMMANDS_OUTPUT_FILE file before it gets created again to avoid printing an old file when CTEST_UPDATE_VERSION_ONLY=ON (a very rare case but still confusing). Added documentation for CTEST_UPDATE_VERSION_ONLY=ON. Added test for CTEST_UPDATE_VERSION_ONLY=ON. NOTE: I was not able to add a strong test to show that the Update.txt and the ctest_update() commands file are not written. That would be a harder thing to check for in the output. --- .../TribitsExampleMetaProject/CMakeLists.txt | 65 +++++++++++++++++++ .../ctest_driver/TribitsCTestDriverCore.cmake | 63 +++++++++++++----- 2 files changed, 112 insertions(+), 16 deletions(-) diff --git a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt index a5b267c41..db59b8e12 100644 --- a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt @@ -320,6 +320,71 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re # expensive. The other runs use # CTEST_START_WITH_EMPTY_BINARY_DIRECTORY=FALSE and CTEST_WIPE_CACHE=FALSE # to avoid this cost. + + +tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_remote_CTEST_UPDATE_VERSION_ONLY + OVERALL_WORKING_DIRECTORY TEST_NAME + OVERALL_NUM_MPI_PROCS 1 + EXCLUDE_IF_NOT_TRUE ${PROJECT_NAME}_ENABLE_Fortran + + TEST_0 + MESSAGE "Run ctest driver with intial clone only of the repos on the default branch 'master' and remote 'origin'" + CMND env + ARGS + CTEST_DASHBOARD_ROOT=PWD + ${COMMON_ENV_ARGS} + TribitsExMetaProj_ENABLE_SECONDARY_TESTED_CODE=TRUE + CTEST_DO_CONFIGURE=OFF + CTEST_DO_BUILD=OFF + CTEST_DO_TEST=OFF + CTEST_BUILD_NAME=CTestDriver_TribitsExMetaProj_clone_default_branch_remote_CTEST_UPDATE_VERSION_ONLY + ${CTEST_S_SCRIPT_ARGS} + PASS_REGULAR_EXPRESSION_ALL + "CTEST_NOTES_FILES=''" + "First perform the initial checkout: .*/git. clone -o origin .*github.com.tribits/TribitsExampleMetaProject.git" + "Perform checkout in directory: .*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote_CTEST_UPDATE_VERSION_ONLY" + "Calling ctest_update[(][)] to update base source repo '.*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote_CTEST_UPDATE_VERSION_ONLY/TribitsExampleMetaProject" + "Old revision of repository is: [a-z0-9]+" + "New revision of repository is: [a-z0-9]+" + "ctest_update[(][.][.][.][)] returned '0'" + "cmake -P tribits_ctest_update_commands[.]cmake" + "Git Update PASSED!" + "TribitsExampleProject: Doing initial GIT clone/checkout from URL '.*github[.]com.tribits/TribitsExampleProject.git' to dir 'TribitsExampleProject' [.][.][.]" + "Cloning into 'TribitsExampleProject'[.][.][.]" + "TribitsExampleProjectAddons: Doing initial GIT clone/checkout from URL '.*github[.]com.tribits/TribitsExampleProjectAddons.git' to dir 'TribitsExampleProjectAddons' [.][.][.]" + "Cloning into 'TribitsExampleProjectAddons'[.][.][.]" + "CTEST_NOTES_FILES_WO_CACHE='.*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote_CTEST_UPDATE_VERSION_ONLY/BUILD/UpdateCommandsOutput.txt'" + "TRIBITS_CTEST_DRIVER: OVERALL: ALL PASSED" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_1 + MESSAGE "Run ctest driver again but this time with CTEST_UPDATE_VERSION_ONLY=ON" + CMND env + ARGS + CTEST_DASHBOARD_ROOT=PWD + ${COMMON_ENV_ARGS} + CTEST_START_WITH_EMPTY_BINARY_DIRECTORY=FALSE + CTEST_WIPE_CACHE=FALSE + TribitsExMetaProj_ENABLE_SECONDARY_TESTED_CODE=TRUE + CTEST_UPDATE_VERSION_ONLY=ON + CTEST_BUILD_NAME=CTestDriver_TribitsExMetaProj_clone_default_branch_remote_CTEST_UPDATE_VERSION_ONLY + ${CTEST_S_SCRIPT_ARGS} + PASS_REGULAR_EXPRESSION_ALL + "-- CTEST_NOTES_FILES=''" + "-- ENV_CTEST_UPDATE_VERSION_ONLY='ON'" + "-- CTEST_UPDATE_VERSION_ONLY='ON'" + "Calling ctest_update[(][)] to update base source repo '.*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote_CTEST_UPDATE_VERSION_ONLY/TribitsExampleMetaProject" + "ctest_update[(][.][.][.][)] returned '0'" + "Configure PASSED!" + "Build PASSED!" + "100% tests passed, 0 tests failed out of 11" + ALWAYS_FAIL_ON_NONZERO_RETURN + + ) + # The above test checks: + # + # * Tests the option CTEST_UPDATE_VERSION_ONLY=ON that requires all of the + # repos to be cloned and already be in the correct git state. # # NOTE: The reason that so many tests are done in a single ctest test is the # cost of the initial configure which checks the compilers which is very diff --git a/tribits/ctest_driver/TribitsCTestDriverCore.cmake b/tribits/ctest_driver/TribitsCTestDriverCore.cmake index 24f4bf6da..f26153fc2 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCore.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCore.cmake @@ -387,6 +387,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/TribitsCTestDriverCoreHelpers.cmake) # * ``CTEST_SUBMIT_CDASH_SUBPROJECTS_DEPS_FILE`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) # * ``CTEST_TEST_TYPE`` (`Determining how the results are displayed on CDash (tribits_ctest_driver())`_) # * ``CTEST_UPDATE_ARGS`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) +# * ``CTEST_UPDATE_VERSION_ONLY`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) # * ``CTEST_WIPE_CACHE`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) # * ``EXTRA_CONFIGURE_OPTIONS`` (`Setting variables in the inner CMake configure (tribits_ctest_driver())`_) # * ``EXTRA_SYSTEM_CONFIGURE_OPTIONS`` (`Setting variables in the inner CMake configure (tribits_ctest_driver())`_) @@ -811,6 +812,21 @@ include(${CMAKE_CURRENT_LIST_DIR}/TribitsCTestDriverCoreHelpers.cmake) # The default value is empty "". This is only used for the base git repo # (not the extra repos). # +# .. _CTEST_UPDATE_VERSION_ONLY: +# +# ``CTEST_UPDATE_VERSION_ONLY``: +# +# Built-in CTest variable that if set to ``TRUE`` will change the default +# behavior of ``ctest_update()`` such that it will not clone or pull from +# the remove repo or update the local branch in any way. This also skips +# any actions on extra repos and skips the creation of the ``Updates.txt`` +# or ``UpdateCommandsOutput.txt`` files. Setting this to ``TRUE`` along +# with ``CTEST_DO_UPDATES=ON`` and doing a submit to CDash will result +# "Revision" column being present with the Git SHA1 of the base repo (and a +# hyperlink to the commit in the public git repo). This is useful when +# using with a CI testing system that handles all of the git repo +# manipulation like GitHub Actions, GitLab CI, or Jenkins. +# # .. _CTEST_START_WITH_EMPTY_BINARY_DIRECTORY: # # ``CTEST_START_WITH_EMPTY_BINARY_DIRECTORY=[TRUE|FALSE]`` @@ -1569,6 +1585,9 @@ function(tribits_ctest_driver) # Flags used on update when doing a Git update set_default_and_from_env( CTEST_UPDATE_OPTIONS "") + + # Do an update only to show the version + set_default_and_from_env( CTEST_UPDATE_VERSION_ONLY FALSE ) # Do all-at-once configure, build, test and submit (or package-by-package) if ("${${PROJECT_NAME}_CTEST_DO_ALL_AT_ONCE_DEFAULT}" STREQUAL "") @@ -1912,7 +1931,9 @@ function(tribits_ctest_driver) # if the repo does not already exist! else() message("${CTEST_SOURCE_DIRECTORY} exists so skipping the initial checkout.") - set(CREATE_VC_UPDATE_FILE TRUE) + if (NOT CTEST_UPDATE_VERSION_ONLY) + set(CREATE_VC_UPDATE_FILE TRUE) + endif() endif() # @@ -1928,18 +1949,22 @@ function(tribits_ctest_driver) # "'${GIT_EXECUTABLE}'" or "\"${GIT_EXECUTABLE}\"" or it will not work and # ctest_update() will return failed! - # Provide a custom command to do the update - - set(CTEST_GIT_UPDATE_CUSTOM - "${CMAKE_COMMAND}" - -DGIT_EXE=${GIT_EXECUTABLE} - -DREMOTE_NAME=${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE} - -DBRANCH=${${PROJECT_NAME}_BRANCH} - -DUNIT_TEST_MODE=${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING} - -DOUTPUT_FILE=${CTEST_UPDATE_COMMANDS_OUTPUT_FILE} - -P ${THIS_CMAKE_CURRENT_LIST_DIR}/tribits_ctest_update_commands_wrapper.cmake - ) - message("CTEST_GIT_UPDATE_CUSTOM=${CTEST_GIT_UPDATE_CUSTOM}") + if (NOT CTEST_UPDATE_VERSION_ONLY) + # Provide a custom command to do the update + set(CTEST_GIT_UPDATE_CUSTOM + "${CMAKE_COMMAND}" + -DGIT_EXE=${GIT_EXECUTABLE} + -DREMOTE_NAME=${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE} + -DBRANCH=${${PROJECT_NAME}_BRANCH} + -DUNIT_TEST_MODE=${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING} + -DOUTPUT_FILE=${CTEST_UPDATE_COMMANDS_OUTPUT_FILE} + -P ${THIS_CMAKE_CURRENT_LIST_DIR}/tribits_ctest_update_commands_wrapper.cmake + ) + message("CTEST_GIT_UPDATE_CUSTOM=${CTEST_GIT_UPDATE_CUSTOM}") + else() + # CTest will just report the version already checked out in + # ctest_update(). + endif() endif() @@ -2063,6 +2088,10 @@ function(tribits_ctest_driver) return() endif() + if (EXISTS "${CTEST_UPDATE_COMMANDS_OUTPUT_FILE}") + file(REMOVE "${CTEST_UPDATE_COMMANDS_OUTPUT_FILE}") + endif() + message("\nCalling ctest_update() to update base source repo '${CTEST_SOURCE_DIRECTORY}' ...") ctest_update_wrapper( SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE CTEST_UPDATE_RETURN_VAL) @@ -2080,9 +2109,11 @@ function(tribits_ctest_driver) message("------------------------------------------------------------------------\n") endif() - tribits_clone_or_update_extra_repos(${CTEST_UPDATE_RETURN_VAL} LOC_UPDATE_FAILED) - if (LOC_UPDATE_FAILED) - set(UPDATE_FAILED TRUE) + if (NOT CTEST_UPDATE_VERSION_ONLY) + tribits_clone_or_update_extra_repos(${CTEST_UPDATE_RETURN_VAL} LOC_UPDATE_FAILED) + if (LOC_UPDATE_FAILED) + set(UPDATE_FAILED TRUE) + endif() endif() if (CREATE_VC_UPDATE_FILE) From fe3a5c3679ecc607f9090dce99918e5a5b9dfe56 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 27 Jul 2021 17:00:21 -0600 Subject: [PATCH 04/11] Set CTEST_CHANGE_ID (#154) It is not really possible to add a test for this. It is just a var you set and then CTest adds that to an XML file and that gets uploaded to CDash. There really is nothing to test locally. I just added reading in from env and documentation (with more detail that what is provided by offical CDash documentation). --- .../ctest_driver/TribitsCTestDriverCore.cmake | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tribits/ctest_driver/TribitsCTestDriverCore.cmake b/tribits/ctest_driver/TribitsCTestDriverCore.cmake index f26153fc2..7e01c16bf 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCore.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCore.cmake @@ -361,6 +361,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/TribitsCTestDriverCoreHelpers.cmake) # * ``CTEST_BINARY_DIRECTORY`` (`Source and Binary Directory Locations (tribits_ctest_driver())`_) # * ``CTEST_BUILD_FLAGS`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) # * ``CTEST_BUILD_NAME`` (`Determining how the results are displayed on CDash (tribits_ctest_driver())`_) +# * ``CTEST_CHANGE_ID`` (`Determining how the results are displayed on CDash (tribits_ctest_driver())`_) # * ``CTEST_CMAKE_GENERATOR`` (`Other CTest Driver options (tribits_ctest_driver())`_) # * ``CTEST_CONFIGURATION_UNIT_TESTING`` (`Other CTest Driver options (tribits_ctest_driver())`_) # * ``CTEST_COVERAGE_COMMAND`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) @@ -379,6 +380,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/TribitsCTestDriverCoreHelpers.cmake) # * ``CTEST_GENERATE_OUTER_DEPS_XML_OUTPUT_FILE`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) # * ``CTEST_MEMORYCHECK_COMMAND_OPTIONS`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) # * ``CTEST_MEMORYCHECK_COMMAND`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) +# * ``CTEST_NOTES_FILES`` (`Determining how the results are displayed on CDash (tribits_ctest_driver())`_) # * ``CTEST_PARALLEL_LEVEL`` (`Determining what testing-related actions are performed (tribits_ctest_driver())`_) # * ``CTEST_SITE`` (`Determining how the results are displayed on CDash (tribits_ctest_driver())`_) # * ``CTEST_SOURCE_DIRECTORY`` (`Source and Binary Directory Locations (tribits_ctest_driver())`_) @@ -1032,9 +1034,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/TribitsCTestDriverCoreHelpers.cmake) # **Determining how the results are displayed on CDash (tribits_ctest_driver()):** # # These options all primarily determine how VC update, configure, build, test, -# and other results and submitted and displayed on CDash (but not what CDash -# site(s) or project(s) they are submitted to). These options can all be set -# in the CTest -S script using ``set()`` statements before +# and other results submitted are displayed on CDash (but not what CDash +# site(s) or project(s) to which they are submitted, see `Specifying where the +# results go to CDash (tribits_ctest_driver())`_). These options can all be +# set in the CTest -S script using ``set()`` statements before # ``tribits_ctest_driver()`` is called and can be overridden in the env when # running the CTest -S driver script. # @@ -1121,6 +1124,19 @@ include(${CMAKE_CURRENT_LIST_DIR}/TribitsCTestDriverCoreHelpers.cmake) # and the file ``${PROJECT_NAME}RepoVersion.txt`` (gives version of all # the git repos being tested). # +# .. _CTEST_CHANGE_ID: +# +# ``CTEST_CHANGE_ID`` +# +# Built-in CTest variable that can be used to set to an integer for the +# GitHub Pull Request (PR) ID or GitLab Merge Request (MR) ID (or other +# such repository and development management system's change control ID). +# If the CDash project is properly configured to point to the GitHub or +# GitLab (or other supported) repository for the project, then CDash will +# put a hyper-linked icon beside the build name that links back to the PR +# or MR issue with that ID. It may also be used for other purposes as +# well in the future. +# # .. _Specifying where the results go to CDash (tribits_ctest_driver()): # # **Specifying where the results go to CDash (tribits_ctest_driver()):** @@ -1588,6 +1604,10 @@ function(tribits_ctest_driver) # Do an update only to show the version set_default_and_from_env( CTEST_UPDATE_VERSION_ONLY FALSE ) + + # Set the GitHub PR or GitLab MR ID (will provide link in CDash back to the + # GitHub PR or GitLab MR) + set_default_and_from_env( CTEST_CHANGE_ID "" ) # Do all-at-once configure, build, test and submit (or package-by-package) if ("${${PROJECT_NAME}_CTEST_DO_ALL_AT_ONCE_DEFAULT}" STREQUAL "") From ad565ca3a08428dfd061fc43cbf871054931d192 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 27 Jul 2021 17:10:10 -0600 Subject: [PATCH 05/11] Set CTEST_CHANGE_ID, CTEST_UPDATE_VERSION_ONLY, and CTEST_DO_UPDATES=ON (#154) --- .../github_actions/ctest_github_actions_serial_debug.cmake | 3 ++- cmake/ctest/github_actions/run_github_actions_ctest_driver.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/ctest/github_actions/ctest_github_actions_serial_debug.cmake b/cmake/ctest/github_actions/ctest_github_actions_serial_debug.cmake index 89429c51d..331019435 100644 --- a/cmake/ctest/github_actions/ctest_github_actions_serial_debug.cmake +++ b/cmake/ctest/github_actions/ctest_github_actions_serial_debug.cmake @@ -3,7 +3,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/../TribitsProjCTestDriver.cmake") set(CTEST_BUILD_NAME $ENV{CTEST_BUILD_NAME}) set(CTEST_TEST_TIMEOUT 60) -set(CTEST_DO_UPDATES OFF) +set(CTEST_DO_UPDATES TRUE) +set(CTEST_UPDATE_VERSION_ONLY TRUE) set_default_and_from_env(CTEST_BUILD_FLAGS "-j2") set_default_and_from_env(CTEST_PARALLEL_LEVEL "2") diff --git a/cmake/ctest/github_actions/run_github_actions_ctest_driver.sh b/cmake/ctest/github_actions/run_github_actions_ctest_driver.sh index a1a51ae51..c94ec092c 100755 --- a/cmake/ctest/github_actions/run_github_actions_ctest_driver.sh +++ b/cmake/ctest/github_actions/run_github_actions_ctest_driver.sh @@ -173,6 +173,7 @@ if [[ "${GITHUB_EVENT_PATH}" != "" ]] ; then echo "pull_number = '${pull_number}'" if [[ "${pull_number}" != "null" ]] ; then export CTEST_BUILD_NAME="pr-${pull_number}_${CTEST_BUILD_NAME}${CTEST_BUILD_NAME_SUFFIX}" + export CTEST_CHANGE_ID=${pull_number} fi fi echo "CTEST_BUILD_NAME = '${CTEST_BUILD_NAME}'" @@ -206,7 +207,6 @@ export TriBITS_TRACK echo "CTEST_TEST_TYPE = '${CTEST_TEST_TYPE}'" echo "TriBITS_TRACK = '${TriBITS_TRACK}'" - # # C) Run the local configure, build, test and submit using exported vars above # From 0ce719a7f9fbe655709a957cbd8009d38e4ede21 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 27 Jul 2021 17:55:36 -0600 Subject: [PATCH 06/11] Update tribits_read_ctest_tag_file() to also read model (#154) Version of CMake 3.17 (and likely earlier) added the model in addition to group to the TAG file. --- test/ctest_driver/CMakeLists.txt | 2 +- test/ctest_driver/CTestDriverUnitTests.cmake | 18 ++++++++------- .../data/dummy_build_dir/Testing/TAG | 3 ++- .../TribitsGetCTestTestXmlDir.cmake | 4 ++-- tribits/ctest_driver/TribitsReadTagFile.cmake | 23 +++++++++++++------ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/test/ctest_driver/CMakeLists.txt b/test/ctest_driver/CMakeLists.txt index bbca928b1..b7dbabf50 100644 --- a/test/ctest_driver/CMakeLists.txt +++ b/test/ctest_driver/CMakeLists.txt @@ -6,7 +6,7 @@ tribits_add_advanced_test( CTestDriverUnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/CTestDriverUnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 2" + "Final UnitTests Result: num_run = 3" "Final UnitTests Result: PASSED" ) diff --git a/test/ctest_driver/CTestDriverUnitTests.cmake b/test/ctest_driver/CTestDriverUnitTests.cmake index 05948bab4..e6ba51e5e 100644 --- a/test/ctest_driver/CTestDriverUnitTests.cmake +++ b/test/ctest_driver/CTestDriverUnitTests.cmake @@ -51,7 +51,7 @@ include(TribitsReadTagFile) include(UnitTestHelpers) -function(unittest_read_ctest_tag_file) +function(unittest_tribits_read_ctest_tag_file) message("\n***") message("*** Testing tribits_read_ctest_tag_file()") @@ -59,16 +59,18 @@ function(unittest_read_ctest_tag_file) set(TAG_FILE_IN "${CMAKE_CURRENT_LIST_DIR}/data/dummy_build_dir/Testing/TAG") - tribits_read_ctest_tag_file(${TAG_FILE_IN} BUILD_START_TIME_OUT CDASH_TRACK_OUT) + tribits_read_ctest_tag_file(${TAG_FILE_IN} buildStartTime cdashGroup cdashModel) - unittest_compare_const(BUILD_START_TIME_OUT + unittest_compare_const(buildStartTime "20101015-1112") - - unittest_compare_const(CDASH_TRACK_OUT - "My CDash Track") # NOTE: Spaces are important to test here! + unittest_compare_const(cdashGroup + "My CDash Group") # NOTE: Spaces are important to test here! + unittest_compare_const(cdashModel + "The Model") # NOTE: Spaces are important to test here! endfunction() + # # Execute the unit tests # @@ -79,11 +81,11 @@ global_set(UNITTEST_OVERALL_NUMPASSED 0) global_set(UNITTEST_OVERALL_NUMRUN 0) # Run the unit test functions -unittest_read_ctest_tag_file() +unittest_tribits_read_ctest_tag_file() message("\n***") message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(2) +unittest_final_result(3) diff --git a/test/ctest_driver/data/dummy_build_dir/Testing/TAG b/test/ctest_driver/data/dummy_build_dir/Testing/TAG index b0df6bdb8..50cb259b4 100644 --- a/test/ctest_driver/data/dummy_build_dir/Testing/TAG +++ b/test/ctest_driver/data/dummy_build_dir/Testing/TAG @@ -1,2 +1,3 @@ 20101015-1112 -My CDash Track +My CDash Group +The Model diff --git a/tribits/ctest_driver/TribitsGetCTestTestXmlDir.cmake b/tribits/ctest_driver/TribitsGetCTestTestXmlDir.cmake index 5e1e7bc97..8de1a7eb6 100644 --- a/tribits/ctest_driver/TribitsGetCTestTestXmlDir.cmake +++ b/tribits/ctest_driver/TribitsGetCTestTestXmlDir.cmake @@ -36,6 +36,6 @@ include(TribitsReadTagFile) set(TAG_FILE "${CTEST_BUILD_DIR}/Testing/TAG") -tribits_read_ctest_tag_file("${TAG_FILE}" BUILD_START_TIME CDASH_TRACK) +tribits_read_ctest_tag_file("${TAG_FILE}" buildStartTime cdashGroup cdashModel) -message("${CTEST_BUILD_DIR}/Testing/${BUILD_START_TIME}") +message("${CTEST_BUILD_DIR}/Testing/${buildStartTime}") diff --git a/tribits/ctest_driver/TribitsReadTagFile.cmake b/tribits/ctest_driver/TribitsReadTagFile.cmake index 766feb092..0c1faf03f 100644 --- a/tribits/ctest_driver/TribitsReadTagFile.cmake +++ b/tribits/ctest_driver/TribitsReadTagFile.cmake @@ -2,15 +2,24 @@ include(TribitsCMakePolicies) include(Split) +# @FUNCTION: tribits_read_ctest_tag_file() # # Read in the /Testing/TAG file contents # +# Usage:: # -function(tribits_read_ctest_tag_file TAG_FILE_IN BUILD_START_TIME_OUT CDASH_TRACK_OUT) - file(READ "${TAG_FILE_IN}" TAG_FILE_STR) - split("${TAG_FILE_STR}" "\n" TAG_FILE_STR_LIST) - list(GET TAG_FILE_STR_LIST 0 BUILD_START_TIME) - list(GET TAG_FILE_STR_LIST 1 CDASH_TRACK) - set(${BUILD_START_TIME_OUT} "${BUILD_START_TIME}" PARENT_SCOPE) - set(${CDASH_TRACK_OUT} "${CDASH_TRACK}" PARENT_SCOPE) +# tribits_read_ctest_tag_file( +# ) +# +function(tribits_read_ctest_tag_file tagFileIn + buildStartTimeOut cdashGroupOut cdashModelOut + ) + file(READ "${tagFileIn}" tagFileStr) + split("${tagFileStr}" "\n" tagFileStrList) + list(GET tagFileStrList 0 buildStartTime) + list(GET tagFileStrList 1 cdashGroup) + list(GET tagFileStrList 2 cdashModel) + set(${buildStartTimeOut} "${buildStartTime}" PARENT_SCOPE) + set(${cdashGroupOut} "${cdashGroup}" PARENT_SCOPE) + set(${cdashModelOut} "${cdashModel}" PARENT_SCOPE) endfunction() From 79a506455c8a35e786db119a093fdc19d70b05d6 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Mon, 9 Aug 2021 12:19:34 -0600 Subject: [PATCH 07/11] Implement tribits_get_cdash_build_url_from_parts() (#154) --- test/ctest_driver/CMakeLists.txt | 2 +- test/ctest_driver/CTestDriverUnitTests.cmake | 28 ++++++- .../TribitsGetCDashUrlFromTagFile.cmake | 76 +++++++++++++++++++ 3 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake diff --git a/test/ctest_driver/CMakeLists.txt b/test/ctest_driver/CMakeLists.txt index b7dbabf50..fdd4af33e 100644 --- a/test/ctest_driver/CMakeLists.txt +++ b/test/ctest_driver/CMakeLists.txt @@ -6,7 +6,7 @@ tribits_add_advanced_test( CTestDriverUnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/CTestDriverUnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 3" + "Final UnitTests Result: num_run = 4" "Final UnitTests Result: PASSED" ) diff --git a/test/ctest_driver/CTestDriverUnitTests.cmake b/test/ctest_driver/CTestDriverUnitTests.cmake index e6ba51e5e..0b1cfc5e5 100644 --- a/test/ctest_driver/CTestDriverUnitTests.cmake +++ b/test/ctest_driver/CTestDriverUnitTests.cmake @@ -47,9 +47,11 @@ set( CMAKE_MODULE_PATH ) include(GlobalSet) -include(TribitsReadTagFile) include(UnitTestHelpers) +include(TribitsReadTagFile) +include(TribitsGetCDashUrlFromTagFile) + function(unittest_tribits_read_ctest_tag_file) @@ -71,6 +73,27 @@ function(unittest_tribits_read_ctest_tag_file) endfunction() +function(unittest_tribits_get_cdash_build_url_from_parts) + + message("\n***") + message("*** Testing tribits_get_cdash_build_url_from_parts()") + message("***\n") + + tribits_get_cdash_build_url_from_parts( + INDEX_PHP_URL "mycdash/index.php" + PROJECT_NAME "my project" + SITE_NAME "my site" + BUILD_NAME "my buildname g++-2.5" + BUILD_STAMP "20210729-0024-My Group" + CDASH_BUILD_URL_OUT cdashBuildUrlOut + ) + + unittest_compare_const(cdashBuildUrlOut + "mycdash/index.php?project=my%20project&filtercount=3&showfilters=1&filtercombine=and&field1=site&compare1=61&value1=my%20site&field2=buildname&compare2=61&value2=my%20buildname%20g%2B%2B-2.5&field3=buildstamp&compare3=61&value3=20210729-0024-My%20Group") + +endfunction() + + # # Execute the unit tests # @@ -82,10 +105,11 @@ global_set(UNITTEST_OVERALL_NUMRUN 0) # Run the unit test functions unittest_tribits_read_ctest_tag_file() +unittest_tribits_get_cdash_build_url_from_parts() message("\n***") message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(3) +unittest_final_result(4) diff --git a/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake b/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake new file mode 100644 index 000000000..b31cc7565 --- /dev/null +++ b/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake @@ -0,0 +1,76 @@ +include(TribitsReadTagFile) + + +# @FUNCTION: tribits_get_cdash_build_url_from_tag_file() +# +# Create CDash index.php URL from the build parts. +# +# Usage:: +# +# tribits_get_cdash_build_url_from_tag_file( +# INDEX_PHP_URL +# PROJECT_NAME +# SITE_NAME +# BUILD_NAME +# TAG_FILE +# CDASH_BUILD_URL_OUT +# ) +# +# Note that spaces are allowed ```` or ```` and those +# will be handled correctly to produce a valid URL. +# +function(tribits_get_cdash_build_url_from_tag_file) + # ToDo: Implement! +endfunction() + + +# @FUNCTION: tribits_get_cdash_build_url_from_parts() +# +# Create CDash index.php URL from the build parts. +# +# Usage:: +# +# tribits_get_cdash_build_url_from_parts( +# INDEX_PHP_URL +# PROJECT_NAME +# SITE_NAME +# BUILD_NAME +# BUILD_STAMP +# CDASH_BUILD_URL_OUT +# ) +# +# Note that spaces are allowed ````, ```` or +# ```` and those will be handled correctly to produce a valid URL. +# +function(tribits_get_cdash_build_url_from_parts) + # Get arguments + cmake_parse_arguments( + PREFIX #prefix + "" #options + "INDEX_PHP_URL;PROJECT_NAME;SITE_NAME;BUILD_NAME;BUILD_STAMP;CDASH_BUILD_URL_OUT" #one_value_keywords + "" #multi_value_keytowrds + ${ARGN} + ) + # Do replacements for spaces and special chars in data + tribits_replace_chars_for_url("${PREFIX_PROJECT_NAME}" project) + tribits_replace_chars_for_url("${PREFIX_SITE_NAME}" site) + tribits_replace_chars_for_url("${PREFIX_BUILD_NAME}" buildname) + tribits_replace_chars_for_url("${PREFIX_BUILD_STAMP}" buildstamp) + # Build the URL + set(cdashIndexProj "${PREFIX_INDEX_PHP_URL}?project=${project}") + set(filtersPreTxt "filtercount=3&showfilters=1&filtercombine=and") + set(siteFlt "field1=site&compare1=61&value1=${site}") + set(buildnameFlt "field2=buildname&compare2=61&value2=${buildname}") + set(buildStampFlt "field3=buildstamp&compare3=61&value3=${buildstamp}") + set(cdashBuildUrl + "${cdashIndexProj}&${filtersPreTxt}&${siteFlt}&${buildnameFlt}&${buildStampFlt}") + set(${PREFIX_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE) +endfunction() + + +function(tribits_replace_chars_for_url inputStr outputStrForUrlOutVar) + set(outputStrForUrl "${inputStr}") + string(REPLACE " " "%20" outputStrForUrl "${outputStrForUrl}") + string(REPLACE "+" "%2B" outputStrForUrl "${outputStrForUrl}") + set(${outputStrForUrlOutVar} "${outputStrForUrl}" PARENT_SCOPE) +endfunction() From 0f983efc1ce15dd02c7d381283ca673ebee9ea4c Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Mon, 9 Aug 2021 12:28:51 -0600 Subject: [PATCH 08/11] Implement tribits_get_cdash_build_url_from_tag_file() (#154) --- test/ctest_driver/CMakeLists.txt | 2 +- test/ctest_driver/CTestDriverUnitTests.cmake | 26 ++++++++++++++++++- .../TribitsGetCDashUrlFromTagFile.cmake | 22 +++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/test/ctest_driver/CMakeLists.txt b/test/ctest_driver/CMakeLists.txt index fdd4af33e..27eff26f0 100644 --- a/test/ctest_driver/CMakeLists.txt +++ b/test/ctest_driver/CMakeLists.txt @@ -6,7 +6,7 @@ tribits_add_advanced_test( CTestDriverUnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/CTestDriverUnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 4" + "Final UnitTests Result: num_run = 5" "Final UnitTests Result: PASSED" ) diff --git a/test/ctest_driver/CTestDriverUnitTests.cmake b/test/ctest_driver/CTestDriverUnitTests.cmake index 0b1cfc5e5..2f5768d9f 100644 --- a/test/ctest_driver/CTestDriverUnitTests.cmake +++ b/test/ctest_driver/CTestDriverUnitTests.cmake @@ -94,6 +94,29 @@ function(unittest_tribits_get_cdash_build_url_from_parts) endfunction() +function(unittest_tribits_get_cdash_build_url_from_tag_file) + + message("\n***") + message("*** Testing tribits_get_cdash_build_url_from_tag_file()") + message("***\n") + + set(TAG_FILE "${CMAKE_CURRENT_LIST_DIR}/data/dummy_build_dir/Testing/TAG") + + tribits_get_cdash_build_url_from_tag_file( + INDEX_PHP_URL "mycdash/index.php" + PROJECT_NAME "my project" + SITE_NAME "my site" + BUILD_NAME "my buildname g++-2.5" + TAG_FILE "${TAG_FILE}" + CDASH_BUILD_URL_OUT cdashBuildUrl + ) + + unittest_compare_const(cdashBuildUrl + "mycdash/index.php?project=my%20project&filtercount=3&showfilters=1&filtercombine=and&field1=site&compare1=61&value1=my%20site&field2=buildname&compare2=61&value2=my%20buildname%20g%2B%2B-2.5&field3=buildstamp&compare3=61&value3=20101015-1112-My%20CDash%20Group") + +endfunction() + + # # Execute the unit tests # @@ -106,10 +129,11 @@ global_set(UNITTEST_OVERALL_NUMRUN 0) # Run the unit test functions unittest_tribits_read_ctest_tag_file() unittest_tribits_get_cdash_build_url_from_parts() +unittest_tribits_get_cdash_build_url_from_tag_file() message("\n***") message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(4) +unittest_final_result(5) diff --git a/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake b/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake index b31cc7565..c671c521f 100644 --- a/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake +++ b/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake @@ -20,7 +20,27 @@ include(TribitsReadTagFile) # will be handled correctly to produce a valid URL. # function(tribits_get_cdash_build_url_from_tag_file) - # ToDo: Implement! + # Get arguments + cmake_parse_arguments( + PREFIX #prefix + "" #options + "INDEX_PHP_URL;PROJECT_NAME;SITE_NAME;BUILD_NAME;TAG_FILE;CDASH_BUILD_URL_OUT" #one_value_keywords + "" #multi_value_keytowrds + ${ARGN} + ) + # Read in the tag file and get the build stamp from that + tribits_read_ctest_tag_file(${PREFIX_TAG_FILE} buildStartTime cdashGroup cdashModel) + set(buildstamp "${buildStartTime}-${cdashGroup}") + # Build the URL and return it + tribits_get_cdash_build_url_from_parts( + INDEX_PHP_URL "${PREFIX_INDEX_PHP_URL}" + PROJECT_NAME "${PREFIX_PROJECT_NAME}" + SITE_NAME "${PREFIX_SITE_NAME}" + BUILD_NAME "${PREFIX_BUILD_NAME}" + BUILD_STAMP "${buildstamp}" + CDASH_BUILD_URL_OUT cdashBuildUrl + ) + set(${PREFIX_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE) endfunction() From 687c1a3b69c5a9ab1ac18e0eda34a364748d5e22 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Mon, 9 Aug 2021 16:25:39 -0600 Subject: [PATCH 09/11] Implement tribits_get_cdash_index_php_from_drop_site_and_location() (#154) Need this for calling tribits_get_cdash_build_url_from_tag_file() from tribits_ctest_driver(). --- test/ctest_driver/CMakeLists.txt | 2 +- test/ctest_driver/CTestDriverUnitTests.cmake | 20 +++++++++++++++++- .../TribitsGetCDashUrlFromTagFile.cmake | 21 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/test/ctest_driver/CMakeLists.txt b/test/ctest_driver/CMakeLists.txt index 27eff26f0..e4b75a620 100644 --- a/test/ctest_driver/CMakeLists.txt +++ b/test/ctest_driver/CMakeLists.txt @@ -6,7 +6,7 @@ tribits_add_advanced_test( CTestDriverUnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/CTestDriverUnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 5" + "Final UnitTests Result: num_run = 6" "Final UnitTests Result: PASSED" ) diff --git a/test/ctest_driver/CTestDriverUnitTests.cmake b/test/ctest_driver/CTestDriverUnitTests.cmake index 2f5768d9f..96aacb6bf 100644 --- a/test/ctest_driver/CTestDriverUnitTests.cmake +++ b/test/ctest_driver/CTestDriverUnitTests.cmake @@ -73,6 +73,23 @@ function(unittest_tribits_read_ctest_tag_file) endfunction() +function(unittest_tribits_get_cdash_index_php_from_drop_site_and_location) + + message("\n***") + message("*** Testing tribits_get_cdash_index_php_from_drop_site_and_location()") + message("***\n") + + tribits_get_cdash_index_php_from_drop_site_and_location( + CTEST_DROP_SITE "some.site.com" + CTEST_DROP_LOCATION "/cdash/submit.php?project=SomeProject" + INDEX_PHP_URL_OUT indexPhpUrl + ) + + unittest_compare_const(indexPhpUrl "some.site.com/cdash/index.php") + +endfunction() + + function(unittest_tribits_get_cdash_build_url_from_parts) message("\n***") @@ -128,6 +145,7 @@ global_set(UNITTEST_OVERALL_NUMRUN 0) # Run the unit test functions unittest_tribits_read_ctest_tag_file() +unittest_tribits_get_cdash_index_php_from_drop_site_and_location() unittest_tribits_get_cdash_build_url_from_parts() unittest_tribits_get_cdash_build_url_from_tag_file() @@ -136,4 +154,4 @@ message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(5) +unittest_final_result(6) diff --git a/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake b/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake index c671c521f..baa30b8d1 100644 --- a/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake +++ b/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake @@ -44,6 +44,27 @@ function(tribits_get_cdash_build_url_from_tag_file) endfunction() +# @FUNCTION: tribits_get_cdash_index_php_from_drop_site_and_location() +# +# Get the CDash index.php URL from the input CTEST_DROP_SITE and +# CTEST_DROP_LOCATION vars used in a ctest -S script. +# +function(tribits_get_cdash_index_php_from_drop_site_and_location) + cmake_parse_arguments( + PREFIX #prefix + "" #options + "CTEST_DROP_SITE;CTEST_DROP_LOCATION;INDEX_PHP_URL_OUT" #one_value_keywords + "" #multi_value_keywords + ${ARGN} + ) + string(FIND "${PREFIX_CTEST_DROP_LOCATION}" "?" endOfSubmitPhpIdx) + string(SUBSTRING "${PREFIX_CTEST_DROP_LOCATION}" 0 ${endOfSubmitPhpIdx} submitPhpPart) + string(REPLACE "submit.php" "index.php" indexPhpPart "${submitPhpPart}") + set(indexPhpUrl "${PREFIX_CTEST_DROP_SITE}${indexPhpPart}") + SET(${PREFIX_INDEX_PHP_URL_OUT} "${indexPhpUrl}" PARENT_SCOPE) +endfunction() + + # @FUNCTION: tribits_get_cdash_build_url_from_parts() # # Create CDash index.php URL from the build parts. From 23189b95607dd989f0bcdb30ce41f04ad33eac28 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 28 Jul 2021 18:58:02 -0600 Subject: [PATCH 10/11] Construct and print CDash build URL and write file CDashBuildUrl.txt (#154) --- .../TribitsExampleProject/CMakeLists.txt | 54 +++++++++++ .../ctest_driver/TribitsCTestDriverCore.cmake | 19 ++-- .../TribitsCTestDriverCoreHelpers.cmake | 94 ++++++++++++++----- 3 files changed, 128 insertions(+), 39 deletions(-) diff --git a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt index a431c2b5d..b751ff64b 100644 --- a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt @@ -1207,6 +1207,60 @@ function(generate_aao_tests) # CONFIGURE_OPTIONS list is checked to make sure that it does not change # without being noticed. Follow-on tests will not check all of that. + set(cdash_url_expected_regex + "https://cdash[.]site[.]com/cdash/index[.]php[?]project=CustomTribitsExProj&filtercount=3&showfilters=1&filtercombine=and&field1=site&compare1=61&value1=My%20Site&field2=buildname&compare2=61&value2=TriBITS_CTestDriver_AAOP_CDASH_URL&field3=buildstamp&compare3=61&value3=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-Custom%20CDash%20Group" ) + # NOTE: Above, we have to repeat [0-9] 8 times and 4 times for the regex for + # the number of digits in the buildstarttime. CMake regex does not support + # \d{8}-\d{4} :-( + + tribits_add_advanced_test( CTestDriver_AAO${AAO_POSTFIX}_CDASH_URL + OVERALL_WORKING_DIRECTORY TEST_NAME + OVERALL_NUM_MPI_PROCS 1 + EXCLUDE_IF_NOT_TRUE ${PROJECT_NAME}_ENABLE_Fortran + TEST_0 + MESSAGE "Symlink TribitsExampleProject so no need to clone (which would not work)." + CMND ln + ARGS -s ${TribitsExProj_DIR} . + TEST_1 + MESSAGE "Run ctest driver testing everyting but no push." + CMND env + ARGS + CTEST_DASHBOARD_ROOT=PWD + ${AAO_COMMON_ENV_ARGS} + CTEST_PARALLEL_LEVEL=3 + CTEST_DO_SUBMIT=OFF # Never submit this + CTEST_SITE="My Site" + CTEST_DROP_SITE="cdash.site.com" + CTEST_PROJECT_NAME="CustomTribitsExProj" + CTEST_DROP_LOCATION="/cdash/submit.php?project=CustomTribitsExProj" + TribitsExProj_PACKAGES=SimpleCxx + CTEST_TEST_TYPE=Continuous + TribitsExProj_TRACK="Custom CDash Group" # Does not need to exist! + CTEST_BUILD_NAME=${PACKAGE_NAME}_CTestDriver_AAO${AAO_POSTFIX}_CDASH_URL + ${CTEST_S_SCRIPT_ARGS} + PASS_REGULAR_EXPRESSION_ALL + "NONE does not exist, skipping extra repositories" + "Final set of enabled packages: SimpleCxx 1" + "Final set of enabled SE packages: SimpleCxx 1" + "Results will be submitted on CDash at:" + "File '' does NOT exist so all tests passed" + "See results submitted on CDash at:" + "${cdash_url_expected_regex}" + "TRIBITS_CTEST_DRIVER: OVERALL: ALL PASSED" + ALWAYS_FAIL_ON_NONZERO_RETURN + TEST_2 + MESSAGE "Check that CDashBuildUrl.txt exists and lists the right URL." + CMND cat ARGS BUILD/CDashBuildUrl.txt + PASS_REGULAR_EXPRESSION_ALL + "${cdash_url_expected_regex}" + ) + # NOTE: The above test is never actually submitted to CDash, even when + # ${PACKAGE_NAME}_CTEST_DRIVER_SUBMIT_TO is set. This is so we can + # exactly control the CDash location vars and do a good test of the + # construction of the CDash URL. Note that we don't know the actual + # buildstamp because the buildstarttime changes everytime the test runs. + # We only know it is [8 digits]-[4 digits]. + tribits_add_advanced_test( CTestDriver_AAO${AAO_POSTFIX}_ST_SKIP_CTEST_ADD_TEST OVERALL_WORKING_DIRECTORY TEST_NAME diff --git a/tribits/ctest_driver/TribitsCTestDriverCore.cmake b/tribits/ctest_driver/TribitsCTestDriverCore.cmake index 7e01c16bf..2f3c6dd34 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCore.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCore.cmake @@ -146,6 +146,7 @@ set( CMAKE_MODULE_PATH "${${PROJECT_NAME}_TRIBITS_DIR}/core/utils" "${${PROJECT_NAME}_TRIBITS_DIR}/core/package_arch" "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support" + "${${PROJECT_NAME}_TRIBITS_DIR}/ctest_driver" ) include(TribitsConstants) @@ -206,7 +207,7 @@ site_name(CTEST_SITE_DEFAULT) # Get helper functions -include(${CMAKE_CURRENT_LIST_DIR}/TribitsCTestDriverCoreHelpers.cmake) +include(TribitsCTestDriverCoreHelpers) # @@ -2092,6 +2093,9 @@ function(tribits_ctest_driver) ctest_start(${CTEST_START_ARGS}) tribits_remember_if_configure_attempted() + tribits_get_build_url_and_write_to_file(CDASH_BUILD_URL + "${CTEST_BINARY_DIRECTORY}/CDashBuildUrl.txt") + tribits_print_build_url("Results will be submitted on CDash at:" "${CDASH_BUILD_URL}") message( "\n***" @@ -2365,18 +2369,7 @@ function(tribits_ctest_driver) report_queued_errors() - string(REPLACE "submit.php" - "index.php" CDASH_PROJECT_LOCATION - "${CTEST_DROP_LOCATION}") - multiline_set( SEE_CDASH_LINK_STR - "\nSee results for:\n" - " Site: ${CTEST_SITE}\n" - " Build Name: ${CTEST_BUILD_NAME}\n" - "at:\n" - " http://${CTEST_DROP_SITE}${CDASH_PROJECT_LOCATION}&display=project\n" - ) - # ToDo: Above: We would love to provide the buildID to point to the exact - # URL but CTest does not currently give that to you. + tribits_print_build_url("See results submitted on CDash at:" "${CDASH_BUILD_URL}") if ((NOT UPDATE_FAILED) AND ("${${PROJECT_NAME}_FAILED_PACKAGES}" STREQUAL "")) message( diff --git a/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake b/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake index 3b9e5bddb..4523405f7 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake @@ -38,7 +38,9 @@ # @HEADER -# +include(TribitsGetCDashUrlFromTagFile) + + # Wrapper used for unit testing purposes # macro(extrarepo_execute_process_wrapper) @@ -56,7 +58,6 @@ macro(extrarepo_execute_process_wrapper) endmacro() -# # Update an existing git repo # function(tribits_update_git_extrarepo GIT_EXE EXTRAREPO_SRC_DIR) @@ -104,7 +105,6 @@ function(tribits_update_git_extrarepo GIT_EXE EXTRAREPO_SRC_DIR) endfunction() -# # Update or clone a single extra repo # function(tribits_clone_or_update_extrarepo EXTRAREPO_NAME_IN EXTRAREPO_DIR_IN @@ -166,7 +166,6 @@ function(tribits_clone_or_update_extrarepo EXTRAREPO_NAME_IN EXTRAREPO_DIR_IN endfunction() -# # Clone or update all of the extra repos and put them on the right branch. # # NOTE: The base repo is cloned by ctest_start() and updated by ctest_update() @@ -202,7 +201,6 @@ function(tribits_clone_or_update_extra_repos CTEST_UPDATE_RETURN_VAL endfunction() -# # Create the Updates.txt file # function(tribits_create_repo_updates_file) @@ -217,7 +215,6 @@ function(tribits_create_repo_updates_file) endfunction() -# # Select the set of extra repositories # macro(tribits_setup_extrarepos) @@ -234,7 +231,6 @@ macro(tribits_setup_extrarepos) endmacro() -# # Select the list of packages # # OUTPUT: Sets ${PROJECT_NAME}_DEFAULT_PACKAGES @@ -312,7 +308,6 @@ macro(enable_package_if_not_explicitly_excluded TRIBITS_PACKAGE) endmacro() -# # Select packages set by the input # macro(enable_user_selected_packages) @@ -342,7 +337,6 @@ macro(enable_user_selected_packages) endmacro() -# # Extract the list of changed files for the main repo on put into an # modified files file. # @@ -361,7 +355,6 @@ macro(tribits_get_modified_files WORKING_DIR_IN MODIFIED_FILES_FILE_NAME_IN) endmacro() -# # Select only packages that are modified or failed in the last CI iteration # macro(enable_only_modified_packages) @@ -528,7 +521,6 @@ macro(enable_only_modified_packages) endmacro() -# # Exclude disabled packages from ${PROJECT_NAME}_EXCLUDE_PACKAGES # # NOTE: These disables need to dominate over the above enables so this code is @@ -543,7 +535,6 @@ macro(disable_excluded_packages) endmacro() -# # Remove packages that are only implicitly enabled but don't have tests # enabled. # @@ -574,7 +565,6 @@ macro(select_final_set_of_packages_to_directly_test) endmacro() -# # Set mapping of labels to subprojects (i.e. TriBITS packages) for CDash. # # NOTE: Unlike for the inner CMake configure, only subprojects that are @@ -591,7 +581,6 @@ macro(tribits_ctest_driver_set_labels_to_subprojects_mapping) endmacro() -# # Select the default generator. # macro(select_default_generator) @@ -610,7 +599,6 @@ macro(select_default_generator) endmacro() -# # Call INITIALIZE_ERROR_QUEUE once at the top of TRIBITS_CTEST_DRIVER # macro(initialize_error_queue) @@ -618,7 +606,6 @@ macro(initialize_error_queue) endmacro() -# # QUEUE_ERROR should be called only for errors that are not already reported to # the dashboard in some other way. For example, if calling ctest_submit fails, # then that failure does NOT show up on the dashboard, so it is appropriate to @@ -635,7 +622,6 @@ macro(queue_error err_msg) endmacro() -# # Call report_queued_errors() once at the bottom of tribits_ctest_driver() # macro(report_queued_errors) @@ -650,7 +636,6 @@ macro(report_queued_errors) endmacro() -# # Setup for tracking if a configure is being attempted to keep memory if it # will pass or not. # @@ -686,7 +671,6 @@ endmacro() # scope. This is needed so the below functions will see them set. -# # Determine if a past configure was attempted but did not pass # function(tribits_previous_configure_attempted_but_not_passsed @@ -712,14 +696,76 @@ function(tribits_previous_configure_attempted_but_not_passsed endfunction() -# # Remember that the configure passed for later ctest -S invocations # function(tribits_remember_configure_passed) file(WRITE "${CONFIGURE_PASSED_FILE}" "Configure Passed!") endfunction() + + +# Construct the build URL on CDash given the site name, buildname, and +# buildstamp (take from the TAG file). +# +# Usage:: +# +# tribits_get_build_url_and_write_to_file( +# +# +# ) +# +# Here, ```` returns the CDash Build URL constructed from +# the CMake vars: +# +# * ``CTEST_DROP_SITE`` +# * ``CTEST_DROP_LOCATION`` (``submit.php`` is replaced with ``index.php``) +# * ``CTEST_PROJECT_NAME`` +# * ``CTEST_SITE`` +# * ``CTEST_BUILD_NAME`` +# +# and the buildstamp read in from the file +# ``${CTEST_BINARY_DIRECTORY}/Testing/TAG``. +# +# Note that ```` will have ``https://`` added to the +# beginning of it so that GitHub Actions and other systems will put in a link +# to them. +# +# If the file name ```` is non-empty, then that CDash URL +# will be written to the file as a single line. +# +function(tribits_get_build_url_and_write_to_file cdashBuildUrlOut cdashBuildUrlFile) + tribits_get_cdash_index_php_from_drop_site_and_location( + CTEST_DROP_SITE "${CTEST_DROP_SITE}" + CTEST_DROP_LOCATION "${CTEST_DROP_LOCATION}" + INDEX_PHP_URL_OUT indexPhpUrl + ) + tribits_get_cdash_build_url_from_tag_file( + INDEX_PHP_URL "${indexPhpUrl}" + PROJECT_NAME "${CTEST_PROJECT_NAME}" + SITE_NAME "${CTEST_SITE}" + BUILD_NAME "${CTEST_BUILD_NAME}" + TAG_FILE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" + CDASH_BUILD_URL_OUT cdashBuildUrl + ) + set(cdashBuildUrl "https://${cdashBuildUrl}") + if (cdashBuildUrlFile) + file(WRITE "${cdashBuildUrlFile}" "${cdashBuildUrl}") + endif() + set(${cdashBuildUrlOut} "${cdashBuildUrl}" PARENT_SCOPE) +endfunction() + + +# Print the URL on CDash where build results can be found. # +# This will print regardless of the value of CTEST_DO_SUBMIT so not that if +# that is set to FALSE, then no results will actually be submitted there. +# +function(tribits_print_build_url msg cdashBuildUrl) + message("\n${msg}\n") + message(" ${cdashBuildUrl}\n") +endfunction() + + # Override CTEST_SUBMIT to drive multiple submits and to detect failed # submissions and track them as queued errors. # @@ -795,7 +841,6 @@ macro(tribits_ctest_submit_driver) endmacro() -# # Wrapper for ctest_update(...) for unit testing # macro(ctest_update_wrapper) @@ -808,7 +853,6 @@ macro(ctest_update_wrapper) endmacro() -# # Helper macros to pass through common CMake configure arguments used by both # package-by-pacakge approach and all-at-once approach # @@ -908,7 +952,6 @@ function(tribits_get_failed_packages_from_failed_tests endfunction() -# # Drive the configure, build, test, and submit package-by-package # # Sets ${PROJECT_NAME}_FAILED_PACKAGES as an indication if there are any @@ -1274,7 +1317,6 @@ macro(tribits_ctest_package_by_package) endmacro() -# # Drive the configure, build, test, and submit all at once for all of the # enabled packages. # @@ -1660,12 +1702,12 @@ macro(tribits_ctest_all_at_once) # those will never cause test failures. Therefore, if there are any build # or install failures, we just have to assume that any tested package # could have failed. Hense, we set the above just like for a (global) - # configure failures. Perhaps we couild read the generated *.xml files to + # configure failures. Perhaps we could read the generated *.xml files to # figure that out but that is not worth the work righ now. The only bad # consequence of this is that a CI build would end up building and testing # every package even if only one dowstream package had a build failure, # for example. That is just one of the downsides of the all-at-once - # appraoch vs the package-by-package appraoch. + # appraoch vs. the package-by-package appraoch. elseif (FAILED_TEST_LOG_FILE) tribits_get_failed_packages_from_failed_tests("${FAILED_TEST_LOG_FILE}" ${PROJECT_NAME}_FAILED_PACKAGES ) From 60bf144236a21873ccc9145c8c8b5ba39374f16b Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Mon, 9 Aug 2021 18:29:05 -0600 Subject: [PATCH 11/11] Add GHA step to print URL to results on CDash (#154) --- .github/workflows/tribits_testing.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/tribits_testing.yml b/.github/workflows/tribits_testing.yml index 377e3e625..43332aae2 100644 --- a/.github/workflows/tribits_testing.yml +++ b/.github/workflows/tribits_testing.yml @@ -83,3 +83,9 @@ jobs: --python-ver ${{ matrix.config.python }} \ --cxx-compiler-and-ver ${{ matrix.config.cxx }} \ --fortran-compiler-and-ver ${{ matrix.config.fc }} + - name: URL to results on CDash + run: | + cd .. + echo "Result on CDash are posted at:" + echo + cat tribits-build/BUILD/CDashBuildUrl.txt