diff --git a/.github/workflows/root-ci.yml b/.github/workflows/root-ci.yml index 5f464b1979722..32dfb441361a8 100644 --- a/.github/workflows/root-ci.yml +++ b/.github/workflows/root-ci.yml @@ -420,6 +420,11 @@ jobs: CONTAINER_IMAGE: "registry.cern.ch/root-ci/${{ matrix.image }}:buildready" #KEEP IN SYNC WITH ABOVE CONTAINER_OPTIONS: "--security-opt label=disable --rm ${{ matrix.property == 'gpu' && '--device nvidia.com/gpu=all' || '' }}" #KEEP IN SYNC WITH ABOVE + env: + BUILD_DIR: /github/home/ROOT-CI/build + INSTALL_DIR: /github/home/ROOT-CI/install + POST_INSTALL_DIR: /github/home/ROOT-CI/PostInstall + steps: - name: Configure large ccache if: ${{ matrix.is_special }} @@ -563,6 +568,21 @@ jobs: run: | ccache -s || true + - name: Install + run: "cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }}" + + - name: Post-install build + run: | + cmake -S test/PostInstall/ -B ${{ env.POST_INSTALL_DIR }} -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }}; + cmake --build ${{ env.POST_INSTALL_DIR }}; + + - name: Post-install test + working-directory: ${{ env.POST_INSTALL_DIR }} + run: ctest -j $(nproc) + + - name: Check installed headers + run: bash test/PostInstall/check-headers.sh ${{ env.INSTALL_DIR }}/include + event_file: # For any event that is not a PR, the CI will always run. In PRs, the CI # can be skipped if the tag [skip-ci] or [skip ci] is written in the title. diff --git a/test/PostInstall/CMakeLists.txt b/test/PostInstall/CMakeLists.txt new file mode 100644 index 0000000000000..50a98b1ff5722 --- /dev/null +++ b/test/PostInstall/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.20 FATAL_ERROR) + +project(PostInstall) + +find_package(ROOT REQUIRED) + +add_executable(readHSimple readHSimple.cxx) +target_link_libraries(readHSimple PUBLIC ROOT::Hist ROOT::RIO) + +include(CTest) + +if(BUILD_TESTING) + add_test(NAME run-hsimple + COMMAND ${ROOT_BINDIR}/root.exe -b -q -l -e ".x ${CMAKE_SOURCE_DIR}/../../tutorials/hsimple.C" -e "return" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + add_test(NAME read-hsimple + COMMAND $ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + set_tests_properties(run-hsimple PROPERTIES FIXTURES_SETUP HSIMPLE) + set_tests_properties(read-hsimple PROPERTIES FIXTURES_REQUIRED HSIMPLE) +endif() diff --git a/test/PostInstall/check-headers.sh b/test/PostInstall/check-headers.sh new file mode 100644 index 0000000000000..821deda11af06 --- /dev/null +++ b/test/PostInstall/check-headers.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Adapted from the XRootD project with friendly permission from G. Amadio. +# +# This script checks that each installed ROOT header can be included individually +# without errors. The intention is to identify which headers may have missing +# includes, missing forward declarations, or missing header dependencies, that is, +# headers from ROOT which it includes, but were not installed by the install target. + +# We need to split CXXFLAGS +# shellcheck disable=SC2086 + +: "${CXX:=c++}" +: "${CXXFLAGS:=-std=c++17 -Wall -Wextra -Wno-unused-parameter -Wno-unused-const-variable}" +: "${INCLUDE_DIR:=${1}}" +: "${NCPU:=$(getconf _NPROCESSORS_ONLN)}" + +if ! command -v "${CXX}" >/dev/null; then + echo "Please set CXX to a valid compiler" + exit 2 +fi +if [ ! -d "${INCLUDE_DIR}" ]; then + echo "Usage: ${0} " + echo "Alternatively, set INCLUDE_DIR in the environment" + exit 2 +fi + + +# Check all installed headers for include errors. +HEADERS=$(find "${INCLUDE_DIR}" -type f -name '*.h*') + +xargs -P ${NCPU:-1} -n 1 "${CXX}" -fsyntax-only -x c++ ${CXXFLAGS} -I"${INCLUDE_DIR}" <<< "${HEADERS}" || exit 1 + diff --git a/test/PostInstall/readHSimple.cxx b/test/PostInstall/readHSimple.cxx new file mode 100644 index 0000000000000..8ddb6e8ed8068 --- /dev/null +++ b/test/PostInstall/readHSimple.cxx @@ -0,0 +1,19 @@ +#include +#include + +int main() +{ + TFile file("hsimple.root", "READ"); + if (!file.IsOpen()) + return 1; + + TH1 *histo = file.Get("hpx"); + if (!histo) + return 2; + + if (histo->GetEntries() != 25000) + return 3; + histo->Print(); + + return 0; +}