From 26119918e24ae2c861cc8cf8982bc9c6fedc3ce9 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Wed, 18 Sep 2024 11:46:03 -0400 Subject: [PATCH] Add Azure Build bots to EbsdLib Signed-off-by: Michael Jackson --- .azure/azure_ci_build.cmake | 39 +++++++ .azure/azure_ci_configure.cmake | 79 +++++++++++++ .azure/azure_ci_test.cmake | 26 +++++ .azure/pipelines/azure-pipelines.yml | 161 +++++++++++++++++++++++++++ 4 files changed, 305 insertions(+) create mode 100644 .azure/azure_ci_build.cmake create mode 100644 .azure/azure_ci_configure.cmake create mode 100644 .azure/azure_ci_test.cmake create mode 100644 .azure/pipelines/azure-pipelines.yml diff --git a/.azure/azure_ci_build.cmake b/.azure/azure_ci_build.cmake new file mode 100644 index 0000000..5382583 --- /dev/null +++ b/.azure/azure_ci_build.cmake @@ -0,0 +1,39 @@ + +#================================================================================================== +# Define these variables +#================================================================================================== +# get_filename_component(HOST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) +## This is the Fully Qualified host name of your system +set(CTEST_SITE "$ENV{AGENT_NAME}.bluequartz.net") +## The name for this build. Combine the build type, compiler, and OS into a single string +set(CTEST_BUILD_NAME "$ENV{PRESET_NAME}-$ENV{BUILD_BUILDNUMBER}-PR$ENV{SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}") +## The type of build we are going to do "Release | Debug" +#set(CTEST_CONFIGURATION_TYPE Release) +## The type of generator we are going to use "Make | Ninja | NMake | JOM" +set(CTEST_CMAKE_GENERATOR "Ninja") + +#================================================================================================== +# Append to the existing CTEST TAG +#================================================================================================== +ctest_start(Experimental ${CTEST_SOURCE_DIR} ${CTEST_BINARY_DIRECTORY} APPEND) + +#================================================================================================== +# Build the project +#================================================================================================== +ctest_build(BUILD ${CTEST_BINARY_DIRECTORY} + CONFIGURATION ${CTEST_CONFIGURATION_TYPE} + NUMBER_ERRORS ctest_build_errors + NUMBER_WARNINGS ctest_build_warnings + RETURN_VALUE ctest_build_result + CAPTURE_CMAKE_ERROR ctest_cmake_result + ) +ctest_submit(PARTS Build) + +if("${ctest_build_result}" EQUAL -1 OR "${ctest_cmake_result}" EQUAL -1) + message(FATAL_ERROR "CONFIGURE ERRORS: Go to https://my.cdash.org/index.php?project=DREAM3D for more information. + Site: ${CTEST_SITE} + Build Name: ${CTEST_BUILD_NAME} + CMake returned the following error code during build: ${ctest_cmake_result} + ctest_build() returned the following error code during build: ${ctest_build_result}") +endif() + diff --git a/.azure/azure_ci_configure.cmake b/.azure/azure_ci_configure.cmake new file mode 100644 index 0000000..d388be2 --- /dev/null +++ b/.azure/azure_ci_configure.cmake @@ -0,0 +1,79 @@ + +#================================================================================================== +# Define these variables +#================================================================================================== +# get_filename_component(HOST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) +## This is the Fully Qualified host name of your system +set(CTEST_SITE "$ENV{AGENT_NAME}.bluequartz.net") +## The name for this build. Combine the build type, compiler, and OS into a single string +set(CTEST_BUILD_NAME "$ENV{PRESET_NAME}-$ENV{BUILD_BUILDNUMBER}-PR$ENV{SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}") +## The type of build we are going to do "Release | Debug" +#set(CTEST_CONFIGURATION_TYPE Release) +## The type of generator we are going to use "Make | Ninja | NMake | JOM" +set(CTEST_CMAKE_GENERATOR "Ninja") + +#================================================================================================== +# Look for a GIT command-line client. +#================================================================================================== +if(NOT DEFINED CTEST_GIT_COMMAND) + find_program(CTEST_GIT_COMMAND NAMES git git.exe git.cmd) +endif() + +if(NOT EXISTS ${CTEST_GIT_COMMAND}) + message(FATAL_ERROR "CONFIGURE ERRORS: Go to https://my.cdash.org/index.php?project=DREAM3D for more information. + Site: ${CTEST_SITE} + Build Name: ${CTEST_BUILD_NAME} + No Git Found.") +endif() + + +#================================================================================================== +# Configure the project +#================================================================================================== +file(WRITE ${CTEST_BINARY_DIRECTORY}/CMakeCache.txt " + SITE:STRING=${CTEST_SITE} + BUILDNAME:STRING=${CTEST_BUILD_NAME} + CTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS} + DART_TESTING_TIMEOUT:STRING=${CTEST_TEST_TIMEOUT} + CMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} + DART_TESTING_TIMEOUT:STRING=1500" +) + +#================================================================================================== +# Start CTest the project. This will create the TAG that is APPENEDED to for the other 2 steps in +# the process. +#================================================================================================== +ctest_start(Experimental ${CTEST_SOURCE_DIR} ${CTEST_BINARY_DIRECTORY}) + +#================================================================================================== +# Update Git Hashes for the project +#================================================================================================== +set(REPO_NAMES "s") +foreach(p ${REPO_NAMES}) + ctest_update(SOURCE ${CTEST_DASHBOARD_ROOT}/${p} + RETURN_VALUE ctest_update_result + CAPTURE_CMAKE_ERROR ctest_cmake_result) +endforeach(p ${REPO_NAMES}) +ctest_submit(PARTS Update) + + +#================================================================================================== +# Configure the project +#================================================================================================== +ctest_configure( BUILD ${CTEST_BINARY_DIRECTORY} + SOURCE ${CTEST_SOURCE_DIR} + OPTIONS "--preset ${CMAKE_PRESET_NAME}" + RETURN_VALUE ctest_configure_result + CAPTURE_CMAKE_ERROR ctest_cmake_result) + +ctest_submit(PARTS Configure Notes) +message(STATUS "ctest_configure_result: ${ctest_configure_result}") +message(STATUS " ctest_cmake_restult: ${ctest_cmake_result}") + +if("${ctest_cmake_result}" EQUAL -1 OR "${ctest_configure_result}" EQUAL -1) + message(FATAL_ERROR "CONFIGURE ERRORS: Go to https://my.cdash.org/index.php?project=DREAM3D for more information. + Site: ${CTEST_SITE} + Build Name: ${CTEST_BUILD_NAME} + CMake returned the following error code during build: ${ctest_cmake_result} + ctest_configure() returned the following error code during build: ${ctest_configure_result}") +endif() diff --git a/.azure/azure_ci_test.cmake b/.azure/azure_ci_test.cmake new file mode 100644 index 0000000..1ac58de --- /dev/null +++ b/.azure/azure_ci_test.cmake @@ -0,0 +1,26 @@ + +#================================================================================================== +# Define these variables +#================================================================================================== +# get_filename_component(HOST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) +## This is the Fully Qualified host name of your system +set(CTEST_SITE "$ENV{AGENT_NAME}.bluequartz.net") +## The name for this build. Combine the build type, compiler, and OS into a single string +set(CTEST_BUILD_NAME "$ENV{PRESET_NAME}-$ENV{BUILD_BUILDNUMBER}-PR$ENV{SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}") +## The type of build we are going to do "Release | Debug" +#set(CTEST_CONFIGURATION_TYPE Release) +## The type of generator we are going to use "Make | Ninja | NMake | JOM" +set(CTEST_CMAKE_GENERATOR "Ninja") + + +#================================================================================================== +# Append to the existing CTEST TAG +#================================================================================================== +ctest_start(Experimental ${CTEST_SOURCE_DIR} ${CTEST_BINARY_DIRECTORY} APPEND) + + +#================================================================================================== +# Run the unit tests +#================================================================================================== +ctest_test(${CTEST_TEST_ARGS} APPEND) +ctest_submit(PARTS Test) diff --git a/.azure/pipelines/azure-pipelines.yml b/.azure/pipelines/azure-pipelines.yml new file mode 100644 index 0000000..61acc05 --- /dev/null +++ b/.azure/pipelines/azure-pipelines.yml @@ -0,0 +1,161 @@ +#================================================================================================== +# Building against a branch *other* than `develop` on EbsdLib. There are a few items that will +# need to be changed. +# +# [1] Under `resources->repository->name` you will need to put your fork. +# You will also need to add another attribute to the `repository` for the branch/ref from github +# [2] Under the `jobs->job->variables` section you will need to adjust the "EbsdLib_origin_name" +# variable to match your fork. +#================================================================================================== + +resources: + repositories: + - repository: EbsdLib + type: github + endpoint: BlueQuartzSoftware + name: BlueQuartzSoftware/EbsdLib + +trigger: + - develop + +jobs: +- job: + strategy: + matrix: + # macOS: + # imageName: Darwin + # preset_name: ci-macos-x64 + # home_dir: /Users/buildbot + Windows: + imageName: Windows_NT + preset_name: ci-windows-v143 + home_dir: C:/Users/buildbot + Linux: + imageName: Linux + preset_name: ci-linux-x64 + home_dir: /home/buildbot + python_dir: /opt/local/anaconda3/envs/dream3d/bin + + pool: + name: BlueQuartz-CI-Cluster + demands: + - Agent.OS -equals $(imageName) + - BQ.PROXMOX + + workspace: + clean: all + + timeoutInMinutes: 120 + + variables: + EbsdLib_source_dir: $(Build.Repository.LocalPath) + model_type: Experimental + build_type: Release + EbsdLib_origin_name: bluequartzsoftware + EbsdLib_branch_name: develop + + steps: + - checkout: self + submodules: true + + - powershell: | + try { + echo System.PullRequest.SourceBranch=$(System.PullRequest.SourceBranch) + echo System.PullRequest.PullRequestNumber=$(System.PullRequest.PullRequestNumber) + } catch { + } + echo Build.SourceBranchName=$(Build.SourceBranchName) + echo Build.Repository.Name=$(Build.Repository.Name) + echo Build.Repository.Uri=$(Build.Repository.Uri) + echo Build.Repository.LocalPath=$(Build.Repository.LocalPath) + echo Build.BuildNumber=$(Build.BuildNumber) + echo Agent.WorkFolder=$(Agent.WorkFolder) + echo Agent.OS=$(Agent.OS) + echo preset_name=$(preset_name) + displayName: 'Dump Azure Variables' + +#================================================================================================== +# Change from the default https checkout to a git remote with ssh +# The build bots have appropriate ssh keys to make this work +# This also allows CDash to get the real git commit that we are on for DREAM3DNX +#================================================================================================== + - powershell: | + cd $(EbsdLib_source_dir) + git config core.sshCommand "ssh -i $(home_dir)/.ssh/id_rsa" + git remote rename origin azure + git remote add origin ssh://git@github.com/$(EbsdLib_origin_name)/EbsdLib + git fetch origin + displayName: Update EbsdLib Repo + + +#================================================================================================== +# CDash Section: +# In this section we are going to call `ctest` 3 times in order to separate out the output from +# each CDash stage: Configure,Update :: Build :: Testing +# This makes the output easier to parse through for the testing. +#================================================================================================== + + - powershell: | + $UpdatedPath = '$(python_dir)' + [IO.Path]::PathSeparator + [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Process) + [System.Environment]::SetEnvironmentVariable('PATH', $UpdatedPath, [System.EnvironmentVariableTarget]::Process) + cd $(Build.BinariesDirectory) + ctest -VV -DCTEST_SOURCE_DIR=$(EbsdLib_source_dir) -DCTEST_BINARY_DIRECTORY=$(Build.BinariesDirectory) -Ddashboard_model=Experimental -DCTEST_DASHBOARD_ROOT=$(Build.Repository.LocalPath) -DCMAKE_PRESET_NAME="$(preset_name)" -DCTEST_CONFIGURATION_TYPE=Release -S $(EbsdLib_source_dir)/.azure/azure_ci_configure.cmake + displayName: CDash Update/Configure + + - powershell: | + cd $(Build.BinariesDirectory) + ctest -VV -DCTEST_SOURCE_DIR=$(EbsdLib_source_dir) -DCTEST_BINARY_DIRECTORY=$(Build.BinariesDirectory) -Ddashboard_model=Experimental -DCTEST_DASHBOARD_ROOT=$(Build.Repository.LocalPath) -DCMAKE_PRESET_NAME="$(preset_name)" -DCTEST_CONFIGURATION_TYPE=Release -S $(EbsdLib_source_dir)/.azure/azure_ci_build.cmake + displayName: CDash Build + + - powershell: | + cd $(Build.BinariesDirectory) + ctest -VV -DCTEST_SOURCE_DIR=$(EbsdLib_source_dir) -DCTEST_BINARY_DIRECTORY=$(Build.BinariesDirectory) -Ddashboard_model=Experimental -DCTEST_DASHBOARD_ROOT=$(Build.Repository.LocalPath) -DCMAKE_PRESET_NAME="$(preset_name)" -DCTEST_CONFIGURATION_TYPE=Release -S $(EbsdLib_source_dir)/.azure/azure_ci_test.cmake + displayName: CDash Test + +#================================================================================================== +# CPack Section +#================================================================================================== + - powershell: | + cd $(Build.BinariesDirectory) + cpack -C $(build_type) --verbose + displayName: Packing EbsdLib + +#================================================================================================== +# Publish Test Results +#================================================================================================== + - task: PublishTestResults@2 + inputs: + testResultsFormat: CTest + testResultsFiles: $(Build.BinariesDirectory)/Testing/*/Test.xml + testRunTitle: CTest_$(Agent.Name)_$(Agent.OS) + failTaskOnFailedTests: true + displayName: Publish Commercial Test Results + + # - script: | + # cmake -S $(EbsdLib_source_dir) -B $(Build.BinariesDirectory)-Free -G Ninja -DDREAM3D_ENABLE_DOCUMENTATION=OFF -DDREAM3D_ENABLE_COMMERCIAL_BUILD=OFF -DCMAKE_BUILD_TYPE:STRING=$(build_type) -DDREAM3D_DATA_DIR=$(dream3d_data_dir) -C $(Agent.WorkFolder)/NX.cmake -DEbsdLib_EXTRA_PLUGINS="Core;ITKImageProcessing;OrientationAnalysis" -DCTEST_BUILD_NAME:STRING="NX-Free-$(Agent.MachineName)-$(Agent.OS)-$(Build.SourceBranchName)_$(Build.BuildNumber)" + # displayName: Configure Free DREAM3D + + # - script: | + # cmake --build $(Build.BinariesDirectory)-Free --config $(build_type) --target all + # displayName: Build Free DREAM3D + + # - script: | + # cd $(Build.BinariesDirectory)-Free + # cpack -C $(build_type) --verbose + # continueOnError: false + # displayName: Packing Free DREAM3D + + # - script: | + # cd $(Build.BinariesDirectory)-Free + # ctest -C $(build_type) -D Experimental --timeout 7200 -DCTEST_SITE:STRING=$(Agent.MachineName).bluequartz.net -Ddashboard_source_name:STRING=DREAM3D + # continueOnError: true + # displayName: Testing Free DREAM3D + + # - task: PublishTestResults@2 + # inputs: + # testResultsFormat: CTest + # testResultsFiles: $(Build.BinariesDirectory)-Free/Testing/*/Test.xml + # testRunTitle: CTest_$(Agent.Name)_$(Agent.OS) + # failTaskOnFailedTests: true + # displayName: Publish Free Test Results + \ No newline at end of file