Skip to content

Commit

Permalink
Add CI tests and update to newer ACTS (#13)
Browse files Browse the repository at this point in the history
* Update CI

* add dd4hep

* require dd4hep plugin

* remove unused includes

* Update logging

* add ci test
  • Loading branch information
Zehvogel authored Oct 17, 2023
1 parent 7050594 commit a627e58
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/downstream-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
56 changes: 23 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: linux

on:
push:
pull_request:
on: [push, pull_request]

jobs:
test:
Expand All @@ -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;
'
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,3 +45,4 @@ endif()
include(CTest)

add_subdirectory(k4ActsTracking)
add_subdirectory(test)
3 changes: 1 addition & 2 deletions geosvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# limitations under the License.
#
import os
import sys
from pprint import pprint
from Gaudi.Configuration import *

Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion k4ActsTracking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ gaudi_add_module(k4ActsTrackingPlugins
EDM4HEP::edm4hep
DD4hep::DDCore DD4hep::DDRec
ActsCore ActsPluginDD4hep
ActsDD4hep::ActsDD4hep
)

set(GAUDI_GENCONF_DIR "genConfDir")
Expand Down
10 changes: 5 additions & 5 deletions k4ActsTracking/src/components/ActsGeoSvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
37 changes: 37 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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=$<$<TARGET_EXISTS:podio::podio>:$<TARGET_FILE_DIR:podio::podio>/../include>:$<$<TARGET_EXISTS:EDM4HEP::edm4hep>:$<TARGET_FILE_DIR:EDM4HEP::edm4hep>/../include>:$ENV{ROOT_INCLUDE_PATH}")
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}:${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}:$<$<TARGET_EXISTS:ROOT::Core>:$<TARGET_FILE_DIR:ROOT::Core>>:$<$<TARGET_EXISTS:EDM4HEP::edm4hep>:$<TARGET_FILE_DIR:EDM4HEP::edm4hep>>:$<$<TARGET_EXISTS:podio::podio>:$<TARGET_FILE_DIR:podio::podio>>:$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)
35 changes: 35 additions & 0 deletions test/options/geosvc.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a627e58

Please sign in to comment.