Add Windows MSYS2 Jenkins build and testing support #1
All checks were successful
sgraves/cpp-build-system/pipeline/head This commit looks good
sgraves/cpp-build-system_mac/pipeline/head This commit looks good

This commit is contained in:
2025-10-18 11:26:39 -05:00
parent fe16d78ded
commit 60eec05fab
6 changed files with 302 additions and 1 deletions

137
.jenkins_msys2 Normal file
View File

@@ -0,0 +1,137 @@
#!groovy
pipeline {
agent none
environment {
PROJECT_TEST_CONFIG_DIR = "C:\\.ci\\cpp_build_system\\test"
}
options {
disableConcurrentBuilds()
skipDefaultCheckout()
timestamps()
}
stages {
stage('msys2 x86_64') {
agent any
stages {
stage('Checkout') {
steps {
script {
int maxAttempts = 6
int baseDelay = 10
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
try {
checkout scm
break
} catch (err) {
if (attempt == maxAttempts) { throw err }
int waitSec = baseDelay * (1 << (attempt - 1))
echo "Checkout failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..."
sleep time: waitSec, unit: 'SECONDS'
}
}
}
}
}
stage('msys2_x86_64_shared') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd shared "" x86_64' } }
}
}
stage('msys2_x86_64_shared_crypto') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd shared 1 x86_64' } }
}
}
stage('msys2_x86_64_shared_crypto_no_boost') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd shared 7 x86_64' } }
}
}
stage('msys2_x86_64_shared_dsm') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd shared 2 x86_64' } }
}
}
stage('msys2_x86_64_shared_sqlite') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd shared 3 x86_64' } }
}
}
stage('msys2_x86_64_shared_errors_v1') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd shared 4 x86_64' } }
}
}
stage('msys2_x86_64_shared_fmt') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd shared 5 x86_64' } }
}
}
stage('msys2_x86_64_shared_libevent') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd shared 6 x86_64' } }
}
}
stage('msys2_x86_64_static') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd static "" x86_64' } }
}
}
stage('msys2_x86_64_static_crypto') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd static 1 x86_64' } }
}
}
stage('msys2_x86_64_static_crypto_no_boost') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd static 7 x86_64' } }
}
}
stage('msys2_x86_64_static_dsm') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd static 2 x86_64' } }
}
}
stage('msys2_x86_64_static_sqlite') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd static 3 x86_64' } }
}
}
stage('msys2_x86_64_static_errors_v1') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd static 4 x86_64' } }
}
}
stage('msys2_x86_64_static_fmt') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd static 5 x86_64' } }
}
}
stage('msys2_x86_64_static_libevent') {
steps {
script { retryWithBackoff(2, 5) { cmd 'scripts\\test_msys2.cmd static 6 x86_64' } }
}
}
}
}
}
}
def retryWithBackoff(int maxAttempts, int baseDelaySeconds, Closure body) {
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
try {
body()
return
} catch (err) {
if (attempt == maxAttempts) { throw err }
int waitSec = baseDelaySeconds * (1 << (attempt - 1))
echo "Step failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..."
sleep time: waitSec, unit: 'SECONDS'
}
}
}

View File

@@ -6,6 +6,10 @@
- \#1 Add Windows MSYS2 Jenkins build and testing support
### Changes from v1.0.0-release
- Remove stray "_libevent_" inserted mid-name on macOS x86_64 Jenkins test builds
---
## v1.0.0-release

View File

@@ -18,6 +18,7 @@ create_versions_cmake
process_file .jenkins_builds
process_file .jenkins_macos
process_file .jenkins_msys2
process_file .nvimrc
process_file CMakeLists.txt
process_file config.sh

View File

@@ -52,7 +52,7 @@ elif [ "${WITH_TYPE}" == "7" ]; then
fi
if [ "${BUILD_ARCH}" != "" ]; then
NAME=${NAME}_libevent_${BUILD_ARCH}
NAME=${NAME}_${BUILD_ARCH}
fi
rm -rf "${TEST_DIR}/${NAME}"

82
scripts/test_msys2.cmd Executable file
View File

@@ -0,0 +1,82 @@
@echo off
setlocal EnableExtensions
set "SED=sed"
set "SCRIPTS_DIR=%~dp0"
pushd "%SCRIPTS_DIR%"
set "SCRIPTS_DIR=%CD%"
popd
set "SOURCE_DIR=%~dp0.."
pushd "%SOURCE_DIR%"
set "SOURCE_DIR=%CD%"
popd
set "TEST_DIR=%SOURCE_DIR%\build"
set "PLATFORM=msys2"
set "BUILD_TYPE=%~1"
set "WITH_TYPE=%~2"
if /I not "%BUILD_TYPE%"=="shared" if /I not "%BUILD_TYPE%"=="static" (
call :ERROR_EXIT "Must specify 'shared' or 'static'." 1
)
if not defined TEST_DIR (
call :ERROR_EXIT "TEST_DIR is not set." 1
)
if not exist "%TEST_DIR%" mkdir "%TEST_DIR%"
set "NAME=%PLATFORM%_%BUILD_TYPE%"
if "%WITH_TYPE%"=="1" set "NAME=%NAME%_crypto"
if "%WITH_TYPE%"=="2" set "NAME=%NAME%_dsm"
if "%WITH_TYPE%"=="3" set "NAME=%NAME%_sqlite"
if "%WITH_TYPE%"=="4" set "NAME=%NAME%_errors_v1"
if "%WITH_TYPE%"=="5" set "NAME=%NAME%_fmt"
if "%WITH_TYPE%"=="6" set "NAME=%NAME%_libevent"
if "%WITH_TYPE%"=="7" set "NAME=%NAME%_crypto_no_boost"
if exist "%TEST_DIR%\%NAME%\" rd /s /q "%TEST_DIR%\%NAME%"
pushd "%SOURCE_DIR%"
call ".\create_project.cmd" "%NAME%" "%TEST_DIR%" || (
call :ERROR_EXIT "Failed to create %PLATFORM% project." 2
)
popd
pushd "%TEST_DIR%\%NAME%"
if "%WITH_TYPE%"=="1" (
%SED% -i "s/PROJECT_ENABLE_LIBSODIUM=OFF/PROJECT_ENABLE_LIBSODIUM=ON/g" ".\config.sh"
%SED% -i "s/PROJECT_ENABLE_BOOST=OFF/PROJECT_ENABLE_BOOST=ON/g" ".\config.sh"
%SED% -i "s/PROJECT_ENABLE_JSON=OFF/PROJECT_ENABLE_JSON=ON/g" ".\config.sh"
)
if "%WITH_TYPE%"=="2" %SED% -i "s/PROJECT_ENABLE_LIBDSM=OFF/PROJECT_ENABLE_LIBDSM=ON/g" ".\config.sh"
if "%WITH_TYPE%"=="3" %SED% -i "s/PROJECT_ENABLE_SQLITE=OFF/PROJECT_ENABLE_SQLITE=ON/g" ".\config.sh"
if "%WITH_TYPE%"=="4" %SED% -i "s/PROJECT_ENABLE_V2_ERRORS=ON/PROJECT_ENABLE_V2_ERRORS=OFF/g" ".\config.sh"
if "%WITH_TYPE%"=="5" %SED% -i "s/PROJECT_ENABLE_FMT=OFF/PROJECT_ENABLE_FMT=ON/g" ".\config.sh"
if "%WITH_TYPE%"=="6" %SED% -i "s/PROJECT_ENABLE_LIBEVENT=OFF/PROJECT_ENABLE_LIBEVENT=ON/g" ".\config.sh"
if "%WITH_TYPE%"=="7" %SED% -i "s/PROJECT_ENABLE_LIBSODIUM=OFF/PROJECT_ENABLE_LIBSODIUM=ON/g" ".\config.sh"
if /I "%BUILD_TYPE%"=="shared" (
%SED% -i "s/PROJECT_STATIC_LINK=ON/PROJECT_STATIC_LINK=OFF/g" ".\config.sh"
)
call ".\scripts\make_win32.cmd" || (
call :ERROR_EXIT "build %PLATFORM% failed." 3
)
call ".\scripts\run_tests.cmd" || (
call :ERROR_EXIT "testing %PLATFORM% failed." 3
)
popd
if exist "%TEST_DIR%\%NAME%\" rd /s /q "%TEST_DIR%\%NAME%"
exit /b 0
:ERROR_EXIT
echo %~1
exit /b %~2

77
src/.jenkins_msys2 Normal file
View File

@@ -0,0 +1,77 @@
#!groovy
pipeline {
agent none
environment {
PROJECT_TEST_CONFIG_DIR = "c:\\.ci\\%PROJECT_NAME%\\test"
}
options {
disableConcurrentBuilds()
skipDefaultCheckout()
timestamps()
}
stages {
// stage('Build • Test • Deliver')
stage('Build • Test') {
agent any
stages {
stage('Checkout') {
steps {
script {
int maxAttempts = 6
int baseDelay = 10
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
try {
checkout scm
break
} catch (err) {
if (attempt == maxAttempts) { throw err }
int waitSec = baseDelay * (1 << (attempt - 1))
echo "Checkout failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..."
sleep time: waitSec, unit: 'SECONDS'
}
}
}
}
}
stage('msys2_x86_64') {
steps { script { retryWithBackoff(2, 5) { cmd 'scripts\\make_win32.cmd x86_64' } } }
}
stage('test') {
steps {
script {
retryWithBackoff(2, 5) { cmd 'scripts\\run_tests.cmd x86_64' }
}
}
}
// stage('deliver') {
// steps {
// script {
// retryWithBackoff(3, 10) { cmd 'scripts\\deliver.cmd C:\\deliver\\%PROJECT_NAME% "" x86_64' }
// }
// }
// }
}
}
}
}
def retryWithBackoff(int maxAttempts, int baseDelaySeconds, Closure body) {
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
try {
body()
return
} catch (err) {
if (attempt == maxAttempts) { throw err }
int waitSec = baseDelaySeconds * (1 << (attempt - 1))
echo "Step failed (attempt ${attempt}/${maxAttempts}). Waiting ${waitSec}s before retry..."
sleep time: waitSec, unit: 'SECONDS'
}
}
}