Skip to content

Commit

Permalink
Prevent build errors on CI
Browse files Browse the repository at this point in the history
Quickfix for OSX CI build problems.
Prevent to build ctests while version-consistency tests.
  • Loading branch information
ClausKlein authored and bernedom committed Nov 8, 2023
1 parent c6bc9aa commit 950fe5a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 27 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:

- name: macos-apple-clang
os: macos-latest
compiler-cppstd: "gnu17"

- name: windows-msvc-19
os: windows-2019
Expand Down Expand Up @@ -69,10 +70,13 @@ jobs:
run: |
conan profile detect --force
if [ "${{ matrix.compiler-name-conan }}" != "" ]; then
sed -i 's/compiler=.*/compiler=${{ matrix.compiler-name-conan }}/g' ~/.conan2/profiles/default
sed -i.bak -e 's/compiler=.*/compiler=${{ matrix.compiler-name-conan }}/g' ~/.conan2/profiles/default
fi
if [ "${{ matrix.compiler-version }}" != "" ]; then
sed -i 's/compiler.version=[0-9]\+/compiler.version=${{ matrix.compiler-version }}/g' ~/.conan2/profiles/default
sed -i.bak -e 's/compiler.version=[0-9]\+/compiler.version=${{ matrix.compiler-version }}/g' ~/.conan2/profiles/default
fi
if [ "${{ matrix.compiler-cppstd }}" != "" ]; then
sed -i.bak -e 's/compiler.cppstd=gnu[0-9]\+/compiler.cppstd=${{ matrix.compiler-cppstd }}/g' ~/.conan2/profiles/default
fi
shell: bash

Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ project(
LANGUAGES CXX)

include(GNUInstallDirs)
include(CTest)

option(SI_INSTALL_LIBRARY
"Enable installing of SI library into default locations"
Expand Down Expand Up @@ -44,7 +43,9 @@ target_include_directories(

target_compile_features(SI INTERFACE cxx_std_17)

if(BUILD_TESTING AND SI_BUILD_TESTING)
if(SI_BUILD_TESTING)
enable_testing()

include(Catch)
add_subdirectory(test)
endif()
Expand Down
20 changes: 10 additions & 10 deletions test/compilation-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ buildSingleTarget()
if [ "${2}" == "DEFAULTBUILD" ]; then
cmake ${ROOT_DIR}/test/src/compilation_tests/ -B${BUILD_DIR} -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DCMAKE_BUILD_TYPE=Release -G Ninja > /dev/null
assertEquals "Configuration successful" 0 $?

else
cmake ${ROOT_DIR}/test/src/compilation_tests/ -B${BUILD_DIR} -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-DSI_DISABLE_IMPLICIT_RATIO_CONVERSION" -G Ninja > /dev/null
assertEquals "Configuration successful" 0 $?
fi

cmake --build ${BUILD_DIR} --config Release --target $1 > /dev/null
RESULT=$?

if [ "${3}" == "PASS" ]; then
assertEquals "Building successful" 0 $RESULT
else
Expand All @@ -27,14 +27,14 @@ buildSingleTarget()
}

oneTimeSetUp(){

BUILD_DIR=$(mktemp -d)
conan install . --output-folder=${BUILD_DIR} --build=missing --settings=build_type=Release 2>&1> /dev/null

# install SI
cmake ${ROOT_DIR} -B${BUILD_DIR} -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DBUILD_TESTING=off -DCMAKE_BUILD_TYPE=Release -G Ninja > /dev/null
cmake ${ROOT_DIR} -B${BUILD_DIR} -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DSI_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -G Ninja > /dev/null
cmake --build ${BUILD_DIR} --config Release --target install > /dev/null

if [ -d ${BUILD_DIR} ]; then
rm -rf ${BUILD_DIR}
fi
Expand All @@ -52,15 +52,15 @@ tearDown(){
}

testSISelfSuccessfulCompilationWhenDefaultInvocation() {

cmake ${ROOT_DIR} -B${BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${BUILD_DIR} -G Ninja > /dev/null
assertEquals "Configuration successful" 0 $?
cmake --build ${BUILD_DIR} --config Release > /dev/null
assertEquals "Building successful" 0 $?
}

testSISelfFailedCompilationWhenImplicitConversionDisabled() {

cmake ${ROOT_DIR} -B${BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_CXX_FLAGS="-DSI_DISABLE_IMPLICIT_RATIO_CONVERSION" -G Ninja > /dev/null
assertEquals "Configuration successful" 0 $?
cmake --build ${BUILD_DIR} --config Release
Expand Down Expand Up @@ -347,4 +347,4 @@ testCompilationSucceedsWhenNumberParserDoesNotOverflow()


# Load shUnit2.
. shunit2
. shunit2
24 changes: 12 additions & 12 deletions test/installation-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,42 @@ tearDown() {
if [ -d ${SI_BUILD_DIR} ]; then
rm -rf ${SI_BUILD_DIR}
fi

if [ -d ${INSTALL_PATH} ]; then
rm -rf ${INSTALL_PATH}
fi

if [ -d ${BUILD_DIR} ]; then
rm -rf ${BUILD_DIR}
fi
}

testPureCmakeInstallation() {
# install SI
cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DBUILD_TESTING=off -DCMAKE_BUILD_TYPE=Release
cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DSI_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build ${SI_BUILD_DIR} --config Release --target install
assertEquals "Installation build successful" 0 $?
cmake ${ROOT_DIR}/test/installation-tests -B${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH}
cmake --build ${BUILD_DIR}
assertEquals "build against installation successful" 0 $?

}

testPureCmakeInstallationWithInstallOptionTurnedOff() {
# install SI
cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DBUILD_TESTING=off -DSI_INSTALL_LIBRARY=OFF -DCMAKE_BUILD_TYPE=Release
cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DSI_BUILD_TESTING=OFF -DSI_INSTALL_LIBRARY=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build ${SI_BUILD_DIR} --config Release --target install
assertNotEquals "Installation build successful" 0 $?

DIRECTORY_CONTENTS=$(ls -A ${INSTALL_PATH})
EMPTY=""
assertEquals "Installation directory is empty" "${EMPTY}" "${DIRECTORY_CONTENTS}"

}

testCpackInstallation() {
# install SI
cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCPACK_PACKAGE_FILE_NAME=install-SI -DBUILD_TESTING=off -DCMAKE_BUILD_TYPE=Release
cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCPACK_PACKAGE_FILE_NAME=install-SI -DSI_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build ${SI_BUILD_DIR} --config Release --target package
assertEquals "Installation build successful" 0 $?
if [ "${OS_NAME}" = "Linux" ] || [ "${OS_NAME}" = "Darwin" ]; then
Expand All @@ -63,13 +63,13 @@ testCpackInstallation() {
# echo "done"
return
fi

assertEquals "Installation script successful" 0 $?

cmake ${ROOT_DIR}/test/installation-tests -B${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH}
cmake --build ${BUILD_DIR}
assertEquals "build against installation successful" 0 $?

}


Expand All @@ -78,7 +78,7 @@ testUsageAsSubdirectory() {
cmake ${ROOT_DIR}/test/installation-test-subdirectory -B${BUILD_DIR} -DCMAKE_BUILD_TYPE=Release
cmake --build ${BUILD_DIR}
assertEquals "build against installation successful" 0 $?

}

# Load shUnit2.
Expand Down
2 changes: 1 addition & 1 deletion test/version-consistency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ testVersionNumberConsistency() {
CHANGELOG_VERSION=$(sed -n -E '/## [0-9]+\.[0-9]+\.[0-9]+/p' ${ROOT_DIR}/CHANGELOG.md | head -1 | grep -E -o '[0-9]+\.[0-9]+\.[0-9]+')
ORIG_DIR=$(pwd)

cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DBUILD_TESTING=off -DCMAKE_BUILD_TYPE=Debug >/dev/null
cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DSI_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Debug >/dev/null
cd ${SI_BUILD_DIR}
CMAKE_VERSION=$(cmake --system-information | grep -E "VERSION:STATIC" | grep -E -o '[0-9]+\.[0-9]+\.[0-9]+')
cd ${ORIG_DIR}
Expand Down

0 comments on commit 950fe5a

Please sign in to comment.