Skip to content

Commit

Permalink
Merge branch 'main' into gx2f-bfield
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 5, 2023
2 parents 9f6d221 + f185bad commit 5b4b1a8
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 96 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ jobs:
&& du -sh build
- name: Coverage
run: >
pip3 install gcovr==5.0
pip3 install gcovr==6.0
&& cd build
&& /usr/bin/python3 ../CI/test_coverage
&& /usr/bin/python3 ../CI/test_coverage.py
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
Expand Down
94 changes: 0 additions & 94 deletions CI/test_coverage

This file was deleted.

86 changes: 86 additions & 0 deletions CI/test_coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env python
import sys
import os
import subprocess
import argparse
import multiprocessing as mp
import re


if not os.path.exists("CMakeCache.txt"):
print("Not in CMake build dir. Not executing")
sys.exit(1)


def check_output(*args, **kwargs):
p = subprocess.Popen(
*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs
)
p.wait()
stdout, stderr = p.communicate()
stdout = stdout.decode("utf-8")
return (p.returncode, stdout.strip())


# call helper function
def call(cmd):
print(" ".join(cmd))
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as e:
print("Failed, output: ", e.output)
raise e


p = argparse.ArgumentParser()
p.add_argument("--gcov", default=check_output(["which", "gcov"])[1])
args = p.parse_args()

ret, gcovr_exe = check_output(["which", "gcovr"])
assert ret == 0, "gcovr not installed. Use 'pip install gcovr'."

ret, gcovr_version_text = check_output(["gcovr", "--version"])
gcovr_version = tuple(
map(int, re.match("gcovr (\d+\.\d+)", gcovr_version_text).group(1).split("."))
)

extra_flags = []

print(f"Found gcovr version {gcovr_version[0]}.{gcovr_version[1]}")
if gcovr_version < (5,):
print("Consider upgrading to a newer gcovr version.")
elif gcovr_version == (5, 1):
assert False and "Version 5.1 does not support parallel processing of gcov data"
elif gcovr_version >= (6,):
extra_flags += ["--exclude-noncode-lines"]

gcovr = [gcovr_exe]

script_dir = os.path.dirname(__file__)
source_dir = os.path.abspath(os.path.join(script_dir, ".."))
coverage_dir = os.path.abspath("coverage")

if not os.path.exists(coverage_dir):
os.makedirs(coverage_dir)

excludes = ["-e", "../Tests/", "-e", ".*json\.hpp"]

# create the html report
call(
gcovr
+ ["-r", source_dir]
+ ["--gcov-executable", args.gcov]
+ ["-j", str(mp.cpu_count())]
+ excludes
+ extra_flags
+ ["--xml", "-o", "coverage/cov.xml"]
)

call(
gcovr
+ ["-r", source_dir]
+ ["-j", str(mp.cpu_count())]
+ ["--gcov-executable", args.gcov]
+ excludes
+ extra_flags
)
1 change: 1 addition & 0 deletions Examples/Python/src/Geant4Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) {
.def(py::init<>());
ACTS_PYTHON_STRUCT_BEGIN(c, Config);
ACTS_PYTHON_MEMBER(outputMaterialTracks);
ACTS_PYTHON_MEMBER(excludeMaterials);
ACTS_PYTHON_STRUCT_END();
}

Expand Down

0 comments on commit 5b4b1a8

Please sign in to comment.