From a627e58a7fe03bd9c30a95cfbc34f8a481499aef Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Tue, 17 Oct 2023 16:44:19 +0200 Subject: [PATCH] Add CI tests and update to newer ACTS (#13) * Update CI * add dd4hep * require dd4hep plugin * remove unused includes * Update logging * add ci test --- .github/workflows/downstream-build.yaml | 2 +- .github/workflows/test.yml | 56 ++++++++------------ CMakeLists.txt | 5 +- geosvc.py | 3 +- k4ActsTracking/CMakeLists.txt | 1 - k4ActsTracking/src/components/ActsGeoSvc.cpp | 10 ++-- test/CMakeLists.txt | 37 +++++++++++++ test/options/geosvc.py | 35 ++++++++++++ 8 files changed, 105 insertions(+), 44 deletions(-) create mode 100644 test/CMakeLists.txt create mode 100644 test/options/geosvc.py diff --git a/.github/workflows/downstream-build.yaml b/.github/workflows/downstream-build.yaml index e763bb4..30ed5c7 100644 --- a/.github/workflows/downstream-build.yaml +++ b/.github/workflows/downstream-build.yaml @@ -11,5 +11,5 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v3 - - uses: cvmfs-contrib/github-action-cvmfs@v3 + - uses: cvmfs-contrib/github-action-cvmfs@v3.1 - uses: key4hep/key4hep-actions/downstream-build@main diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 162b911..cf21529 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,6 @@ name: linux -on: - push: - pull_request: +on: [push, pull_request] jobs: test: @@ -12,35 +10,27 @@ jobs: matrix: SETUP: ['/cvmfs/sw.hsf.org/key4hep/setup.sh', '/cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh'] steps: - - uses: actions/checkout@v2 - - uses: cvmfs-contrib/github-action-cvmfs@v2 + - uses: actions/checkout@v3 + - uses: cvmfs-contrib/github-action-cvmfs@v3.1 - name: Start container run: | - docker run -it --name CI_container -v ${GITHUB_WORKSPACE}:/Package -v /cvmfs:/cvmfs:shared -d ghcr.io/aidasoft/centos7:latest /bin/bash -# - name: CMake Configure -# run: | -# docker exec CI_container /bin/bash -c 'cd Package;\ -# mkdir -p build install;\ -# git submodule init;\ -# git submodule update;\ -# source ${{ matrix.SETUP }};\ -# cd build;\ -# cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " -G Ninja ..;' -# - name: Compile -# run: | -# docker exec CI_container /bin/bash -c 'cd ./Package;\ -# source ${{ matrix.SETUP }};\ -# cd build;\ -# ninja -k0;' -# - name: Install -# run: | -# docker exec CI_container /bin/bash -c 'cd ./Package;\ -# source ${{ matrix.SETUP }};\ -# cd build;\ -# ninja -k0 install;' -# - name: Test -# run: | -# docker exec CI_container /bin/bash -c 'cd ./Package;\ -# source ${{ matrix.SETUP }};\ -# cd build;\ -# ninja -k0 && ctest --output-on-failure;' + docker run \ + -it --name k4Acts_CI \ + -v ${{ github.workspace }}:/k4Acts \ + -v /cvmfs:/cvmfs:shared \ + -d ghcr.io/aidasoft/centos7:latest /bin/bash + - name: Compile + run: | + docker exec k4Acts_CI /bin/bash -c 'source ${{ matrix.SETUP }}; + cd k4Acts; + mkdir build install; cd build; + cmake -G Ninja -D CMAKE_INSTALL_PREFIX=$PWD/../install -D CMAKE_BUILD_TYPE=RelWithDebInfo ..; + ninja install; + ' + + - name: Run tests (CTest) + run: | + docker exec k4Acts_CI /bin/bash -c 'source ${{ matrix.SETUP }}; + cd k4Acts/build; + ctest --output-on-failure; + ' diff --git a/CMakeLists.txt b/CMakeLists.txt index a8a0c63..a993168 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,8 @@ project(k4ActsTracking) find_package(ROOT COMPONENTS RIO Tree) find_package(EDM4HEP) find_package(k4FWCore) -find_package(Acts) -find_package(ActsDD4hep) +find_package(Acts REQUIRED COMPONENTS Core PluginDD4hep) +find_package(DD4hep) #--------------------------------------------------------------- # Load macros and functions for Gaudi-based projects @@ -45,3 +45,4 @@ endif() include(CTest) add_subdirectory(k4ActsTracking) +add_subdirectory(test) diff --git a/geosvc.py b/geosvc.py index ecd55e5..fe259eb 100644 --- a/geosvc.py +++ b/geosvc.py @@ -17,7 +17,6 @@ # limitations under the License. # import os -import sys from pprint import pprint from Gaudi.Configuration import * @@ -26,7 +25,7 @@ algList = [] a = ActsGeoSvc("ActsGeoSvc") -a.detectors = ["/home/delitez/ACTS/acts/thirdparty/OpenDataDetector/xml/OpenDataDetector.xml"] +a.detectors = [f"{os.environ['OPENDATADETECTOR']}/xml/OpenDataDetector.xml"] a.debugGeometry = True a.outputFileName = "MyObjFile" from Configurables import ApplicationMgr diff --git a/k4ActsTracking/CMakeLists.txt b/k4ActsTracking/CMakeLists.txt index 35d9811..04fd4cc 100644 --- a/k4ActsTracking/CMakeLists.txt +++ b/k4ActsTracking/CMakeLists.txt @@ -25,7 +25,6 @@ gaudi_add_module(k4ActsTrackingPlugins EDM4HEP::edm4hep DD4hep::DDCore DD4hep::DDRec ActsCore ActsPluginDD4hep - ActsDD4hep::ActsDD4hep ) set(GAUDI_GENCONF_DIR "genConfDir") diff --git a/k4ActsTracking/src/components/ActsGeoSvc.cpp b/k4ActsTracking/src/components/ActsGeoSvc.cpp index dae13d0..c6f618f 100644 --- a/k4ActsTracking/src/components/ActsGeoSvc.cpp +++ b/k4ActsTracking/src/components/ActsGeoSvc.cpp @@ -21,9 +21,8 @@ #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Plugins/DD4hep/ConvertDD4hepDetector.hpp" -#include "Acts/Plugins/Json/JsonMaterialDecorator.hpp" -#include "Acts/Plugins/Json/MaterialMapJsonConverter.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" +#include "Acts/Utilities/Logger.hpp" #include "Acts/Visualization/GeometryView3D.hpp" #include "Acts/Visualization/ObjVisualization3D.hpp" #include "DD4hep/Printout.h" @@ -69,9 +68,10 @@ StatusCode ActsGeoSvc::initialize() { double layerEnvelopeZ = Acts::UnitConstants::mm; double defaultLayerThickness = Acts::UnitConstants::fm; using Acts::sortDetElementsByID; - m_trackingGeo = Acts::convertDD4hepDetector(m_dd4hepGeo->world(), m_actsLoggingLevel, bTypePhi, bTypeR, bTypeZ, - layerEnvelopeR, layerEnvelopeZ, defaultLayerThickness, - sortDetElementsByID, m_trackingGeoCtx, m_materialDeco); + auto logger = Acts::getDefaultLogger("k4ActsTracking", m_actsLoggingLevel); + m_trackingGeo = Acts::convertDD4hepDetector(m_dd4hepGeo->world(), *logger, bTypePhi, bTypeR, bTypeZ, layerEnvelopeR, + layerEnvelopeZ, defaultLayerThickness, sortDetElementsByID, + m_trackingGeoCtx, m_materialDeco); /// Setting geometry debug option if (m_debugGeometry == true) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..7f0e499 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,37 @@ +#[[ +Copyright (c) 2014-2023 Key4hep-Project. + +This file is part of Key4hep. +See https://key4hep.github.io/key4hep-doc/ for further info. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +]] +include(CTest) + +#--- The genConf directory has been renamed to genConfDir in Gaudi 35r1 +#--- See https://gitlab.cern.ch/gaudi/Gaudi/-/merge_requests/1158 +set(GAUDI_GENCONF_DIR "genConfDir") +if (${Gaudi_VERSION} VERSION_LESS 35.1) + set(GAUDI_GENCONF_DIR "genConf") +endif() + +function(set_test_env _testname) + #set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT "ROOT_INCLUDE_PATH=$<$:$/../include>:$<$:$/../include>:$ENV{ROOT_INCLUDE_PATH}") + set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}:${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}:$<$:$>:$<$:$>:$<$:$>:$ENV{LD_LIBRARY_PATH}") + set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}/${GAUDI_GENCONF_DIR}:$ENV{PYTHONPATH}") +endfunction() + +add_test(NAME LoadODD + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + COMMAND k4run options/geosvc.py) +set_test_env(LoadODD) diff --git a/test/options/geosvc.py b/test/options/geosvc.py new file mode 100644 index 0000000..fe259eb --- /dev/null +++ b/test/options/geosvc.py @@ -0,0 +1,35 @@ +# +# Copyright (c) 2014-2023 Key4hep-Project. +# +# This file is part of Key4hep. +# See https://key4hep.github.io/key4hep-doc/ for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +from pprint import pprint +from Gaudi.Configuration import * + +from Configurables import ActsGeoSvc + +algList = [] + +a = ActsGeoSvc("ActsGeoSvc") +a.detectors = [f"{os.environ['OPENDATADETECTOR']}/xml/OpenDataDetector.xml"] +a.debugGeometry = True +a.outputFileName = "MyObjFile" +from Configurables import ApplicationMgr + +ApplicationMgr(TopAlg=algList, EvtSel="NONE", EvtMax=2, ExtSvc=[ +a +], OutputLevel=INFO)