From 91145dc1dac50fd8b645d3a8fd25f3c49126da72 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Fri, 10 May 2024 19:16:39 -0500 Subject: [PATCH] Splitting docs push --- CMakeLists.txt | 6 +- cmake/HPX_UpdateGitDocs.cmake | 132 ++++++++++++++++++++-------------- docs/CMakeLists.txt | 2 +- tools/hpxdep/CMakeLists.txt | 2 +- 4 files changed, 87 insertions(+), 55 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18a08b2ee53e..e54ff6059481 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,10 @@ set(HPX_VERSION_TAG "-rc2") set(HPX_VERSION "${HPX_VERSION_MAJOR}.${HPX_VERSION_MINOR}.${HPX_VERSION_SUBMINOR}" ) +set(HPX_VERSION_FULL + "${HPX_VERSION_MAJOR}.${HPX_VERSION_MINOR}.${HPX_VERSION_SUBMINOR}${HPX_VERSION_TAG}" +) + set(HPX_LIBRARY_VERSION "${HPX_VERSION}") set(HPX_SOVERSION ${HPX_VERSION_MAJOR}) set(HPX_PACKAGE_NAME HPX) @@ -2327,7 +2331,7 @@ if(HPX_WITH_GIT_BRANCH AND ((NOT HPX_WITH_GIT_TAG) OR "${HPX_WITH_GIT_TAG}x" ) string(REGEX MATCH "^release-[0-9]+.[0-9]+.X$" matched ${HPX_WITH_GIT_BRANCH}) if(matched) - set(HPX_WITH_GIT_TAG "v${HPX_VERSION}") + set(HPX_WITH_GIT_TAG "v${HPX_VERSION_FULL}") hpx_info("Setting HPX_WITH_GIT_TAG to: " "${HPX_WITH_GIT_TAG}") endif() endif() diff --git a/cmake/HPX_UpdateGitDocs.cmake b/cmake/HPX_UpdateGitDocs.cmake index e21fba2d7d20..d022ce48bf62 100644 --- a/cmake/HPX_UpdateGitDocs.cmake +++ b/cmake/HPX_UpdateGitDocs.cmake @@ -16,6 +16,60 @@ if(NOT GIT_FOUND) ) endif() +macro(add_docs what) + # add all newly generated files + execute_process( + COMMAND "${GIT_EXECUTABLE}" add ${what} + WORKING_DIRECTORY "${HPX_BINARY_DIR}/docs/gh-pages" + RESULT_VARIABLE git_add_result + ERROR_VARIABLE git_add_result_message COMMAND_ECHO STDERR + ) + if(NOT "${git_add_result}" EQUAL "0") + message( + FATAL_ERROR + "Adding files to the GitHub pages branch failed: ${git_add_result_message}." + ) + endif() +endmacro() + +macro(commit_docs message) + # check if there are changes to commit + execute_process( + COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD + WORKING_DIRECTORY "${HPX_BINARY_DIR}/docs/gh-pages" + RESULT_VARIABLE git_diff_index_result COMMAND_ECHO STDERR + ) + if(NOT "${git_diff_index_result}" EQUAL "0") + # commit changes + execute_process( + COMMAND "${GIT_EXECUTABLE}" commit -am "Updating Sphinx docs - ${message}" + WORKING_DIRECTORY "${HPX_BINARY_DIR}/docs/gh-pages" + RESULT_VARIABLE git_commit_result + ERROR_VARIABLE git_pull_result_message COMMAND_ECHO STDERR + ) + if(NOT "${git_commit_result}" EQUAL "0") + message( + FATAL_ERROR + "Committing to the GitHub pages branch failed: ${git_pull_result_message}." + ) + endif() + + # push everything up to github + execute_process( + COMMAND "${GIT_EXECUTABLE}" push --force + WORKING_DIRECTORY "${HPX_BINARY_DIR}/docs/gh-pages" + RESULT_VARIABLE git_push_result + ERROR_VARIABLE git_push_result_message COMMAND_ECHO STDERR + ) + if(NOT "${git_push_result}" EQUAL "0") + message( + FATAL_ERROR + "Pushing to the GitHub pages branch failed: ${git_push_result_message}." + ) + endif() + endif() +endmacro() + if(NOT GIT_REPOSITORY) set(GIT_REPOSITORY git@github.com:STEllAR-GROUP/hpx-docs.git --branch master) endif() @@ -34,7 +88,6 @@ if(EXISTS "${HPX_BINARY_DIR}/docs/gh-pages") ) endif() else() - message("${GIT_EXECUTABLE}") execute_process( COMMAND "${GIT_EXECUTABLE}" clone ${GIT_REPOSITORY} gh-pages RESULT_VARIABLE git_clone_result @@ -71,6 +124,8 @@ if(HPX_WITH_GIT_BRANCH) DESTINATION "${DOCS_BRANCH_DEST}" PATTERN "*.buildinfo" EXCLUDE ) + add_docs("branches/${HPX_WITH_GIT_BRANCH}/*") + commit_docs("branch (html)") endif() if("singlehtml" IN_LIST HPX_WITH_DOCUMENTATION_OUTPUT_FORMATS) file( @@ -78,17 +133,24 @@ if(HPX_WITH_GIT_BRANCH) DESTINATION "${DOCS_BRANCH_DEST}" PATTERN "*.buildinfo" EXCLUDE ) + add_docs("branches/${HPX_WITH_GIT_BRANCH}/*") + commit_docs("branch (singlehtml)") endif() if("latexpdf" IN_LIST HPX_WITH_DOCUMENTATION_OUTPUT_FORMATS) if(EXISTS "${DOCS_SOURCE}/latexpdf/latex/HPX.pdf") file(COPY "${DOCS_SOURCE}/latexpdf/latex/HPX.pdf" DESTINATION "${DOCS_BRANCH_DEST}/pdf/" ) + add_docs("branches/${HPX_WITH_GIT_BRANCH}/*") + commit_docs("branch (latexpdf)") endif() endif() + # special handling of dependency report files if(EXISTS "${DOCS_SOURCE}/report") file(COPY "${DOCS_SOURCE}/report" DESTINATION "${DOCS_BRANCH_DEST}") + add_docs("branches/${HPX_WITH_GIT_BRANCH}/*") + commit_docs("branch (depreport)") endif() endif() @@ -103,6 +165,8 @@ if(HPX_WITH_GIT_TAG) DESTINATION "${DOCS_TAG_DEST}" PATTERN "*.buildinfo" EXCLUDE ) + add_docs("tags/${HPX_WITH_GIT_TAG}/*") + commit_docs("tag (html)") endif() if("singlehtml" IN_LIST HPX_WITH_DOCUMENTATION_OUTPUT_FORMATS) file( @@ -110,6 +174,8 @@ if(HPX_WITH_GIT_TAG) DESTINATION "${DOCS_TAG_DEST}" PATTERN "*.buildinfo" EXCLUDE ) + add_docs("tags/${HPX_WITH_GIT_TAG}/*") + commit_docs("tag (singlehtml)") endif() if("latexpdf" IN_LIST HPX_WITH_DOCUMENTATION_OUTPUT_FORMATS) file( @@ -117,18 +183,22 @@ if(HPX_WITH_GIT_TAG) DESTINATION "${DOCS_TAG_DEST}/pdf/" PATTERN "*.buildinfo" EXCLUDE ) + add_docs("tags/${HPX_WITH_GIT_TAG}/*") + commit_docs("tag (latexpdf)") endif() # special handling of dependency report files if(EXISTS "${DOCS_SOURCE}/report") file(COPY "${DOCS_SOURCE}/report" DESTINATION "${DOCS_TAG_DEST}") + add_docs("tags/${HPX_WITH_GIT_TAG}/*") + commit_docs("tag (depreport)") endif() # If a tag name has been set and it is a suitable version number, we also copy # files to the "latest" directory. The regex only matches full version numbers # with three numerical components (X.Y.Z). It does not match release # candidates or other non-version tag names. - if("${HPX_WITH_GIT_TAG}" MATCHES "v[0-9]+\\.[0-9]+\\.[0-9]+$") + if("${HPX_WITH_GIT_TAG}" MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+$") message("Updating latest directory") set(DOCS_LATEST_DEST "${HPX_BINARY_DIR}/docs/gh-pages/latest") file(REMOVE_RECURSE "${DOCS_LATEST_DEST}") @@ -138,6 +208,8 @@ if(HPX_WITH_GIT_TAG) DESTINATION "${DOCS_LATEST_DEST}" PATTERN "*.buildinfo" EXCLUDE ) + add_docs("latest/*") + commit_docs("latest (html)") endif() if("singlehtml" IN_LIST HPX_WITH_DOCUMENTATION_OUTPUT_FORMATS) file( @@ -145,6 +217,8 @@ if(HPX_WITH_GIT_TAG) DESTINATION "${DOCS_LATEST_DEST}" PATTERN "*.buildinfo" EXCLUDE ) + add_docs("latest/*") + commit_docs("latest (singlehtml)") endif() if("latexpdf" IN_LIST HPX_WITH_DOCUMENTATION_OUTPUT_FORMATS) file( @@ -152,61 +226,15 @@ if(HPX_WITH_GIT_TAG) DESTINATION "${DOCS_LATEST_DEST}/pdf/" PATTERN "*.buildinfo" EXCLUDE ) + add_docs("latest/*") + commit_docs("latest (latexpdf)") endif() # special handling of dependency report files if(EXISTS "${DOCS_SOURCE}/report") file(COPY "${DOCS_SOURCE}/report" DESTINATION "${DOCS_LATEST_DEST}") + add_docs("latest/*") + commit_docs("latest (depreport)") endif() endif() endif() - -# add all newly generated files -execute_process( - COMMAND "${GIT_EXECUTABLE}" add * - WORKING_DIRECTORY "${HPX_BINARY_DIR}/docs/gh-pages" - RESULT_VARIABLE git_add_result - ERROR_VARIABLE git_pull_result_message COMMAND_ECHO STDERR -) -if(NOT "${git_add_result}" EQUAL "0") - message( - FATAL_ERROR - "Adding files to the GitHub pages branch failed: ${git_pull_result_message}." - ) -endif() - -# check if there are changes to commit -execute_process( - COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD - WORKING_DIRECTORY "${HPX_BINARY_DIR}/docs/gh-pages" - RESULT_VARIABLE git_diff_index_result COMMAND_ECHO STDERR -) -if(NOT "${git_diff_index_result}" EQUAL "0") - # commit changes - execute_process( - COMMAND "${GIT_EXECUTABLE}" commit -am "Updating Sphinx docs" - WORKING_DIRECTORY "${HPX_BINARY_DIR}/docs/gh-pages" - RESULT_VARIABLE git_commit_result - ERROR_VARIABLE git_pull_result_message COMMAND_ECHO STDERR - ) - if(NOT "${git_commit_result}" EQUAL "0") - message( - FATAL_ERROR - "Committing to the GitHub pages branch failed: ${git_pull_result_message}." - ) - endif() - - # push everything up to github - execute_process( - COMMAND "${GIT_EXECUTABLE}" push --force - WORKING_DIRECTORY "${HPX_BINARY_DIR}/docs/gh-pages" - RESULT_VARIABLE git_push_result - ERROR_VARIABLE git_pull_result_message COMMAND_ECHO STDERR - ) - if(NOT "${git_push_result}" EQUAL "0") - message( - FATAL_ERROR - "Pushing to the GitHub pages branch failed: ${git_pull_result_message}." - ) - endif() -endif() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index bc2c88e473a7..c6c273a1cabb 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -109,7 +109,7 @@ elseif(HPX_WITH_GIT_BRANCH) set(HPX_CONF_DOCUMENTATION_VERSION "${HPX_WITH_GIT_BRANCH}") else() # HPX_VERSION is always available, use as fallback - set(HPX_CONF_DOCUMENTATION_VERSION "${HPX_VERSION}") + set(HPX_CONF_DOCUMENTATION_VERSION "${HPX_VERSION_FULL}") endif() set(SPHINX_CONF_PY_DEST "${CMAKE_CURRENT_BINARY_DIR}/sphinx/conf.py") diff --git a/tools/hpxdep/CMakeLists.txt b/tools/hpxdep/CMakeLists.txt index dfaed7ce0317..facbda38f48f 100644 --- a/tools/hpxdep/CMakeLists.txt +++ b/tools/hpxdep/CMakeLists.txt @@ -25,7 +25,7 @@ elseif(HPX_WITH_GIT_BRANCH) else() # HPX_VERSION is always available, use as fallback set(HPX_DEPREPORT_VERSION "latest") - set(HPX_DEPREPORT_CAPTION "Version ${HPX_VERSION}${HPX_VERSION_TAG}") + set(HPX_DEPREPORT_CAPTION "Version ${HPX_VERSION_FULL}") endif() # cmake-format: off