Skip to content

Commit 07bfe5a

Browse files
committed
some build reorg
1 parent 290184c commit 07bfe5a

4 files changed

Lines changed: 45 additions & 27 deletions

File tree

.github/workflows/binary_tarballs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Upload and test GEMC binary tarballs.
22
name: Binary Tarballs
33

4+
run-name: Triggered by successful deploy workflow (${{ github.event.workflow_run.head_sha }})
5+
46
permissions:
57
actions: read
68
contents: write

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Build and publish GitHub Container Registry (GHCR) images after tests pass.
22
name: Deploy
3+
4+
run-name: Triggered by successful test workflow (${{ github.event.workflow_run.head_sha }})
35
permissions:
46
contents: write
57
packages: write

ci/build.sh

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
# git clone http://github.com/gemc/src /root/src && cd /root/src
88
# ./ci/build.sh
99

10+
# Load environment variables: log file paths, job count, helper functions.
1011
source ci/env.sh
12+
13+
# Resolve meson setup flags from the optional sanitizer argument ($1).
1114
meson_option=$(meson_setup_options $1)
1215

16+
# Print build environment summary (compiler paths, options, core count).
1317
{
1418
echo " > Geant-config: $(command -v geant4-config) : $(geant4-config --version)"
1519
echo " > Root-config: $(command -v root-config) : $(root-config --version)"
@@ -21,6 +25,7 @@ meson_option=$(meson_setup_options $1)
2125
} | tee -a "$setup_log"
2226

2327

28+
# Remove any previous install directory, then configure the build tree.
2429
{
2530
echo
2631
rm -rf $GEMC
@@ -40,6 +45,7 @@ else
4045
fi
4146

4247

48+
# Compile all targets using all available cores.
4349
echo " > Running meson compile -C build -v -j $jobs " | tee -a $compile_log
4450
meson compile -C build -v -j $jobs >> $compile_log
4551
if [ $? -ne 0 ]; then
@@ -51,6 +57,7 @@ else
5157
echo
5258
fi
5359

60+
# Install built artifacts to the configured prefix.
5461
echo " > Running meson install -C build " | tee -a $install_log
5562
meson install -C build >> $install_log
5663
if [ $? -ne 0 ]; then
@@ -62,8 +69,10 @@ else
6269
echo
6370
fi
6471

72+
# Print a summary of the installed gemc files and version.
6573
show_gemc_installation
6674

75+
# Base options shared by all meson test invocations.
6776
test_options=(
6877
-C build
6978
--print-errorlogs
@@ -72,7 +81,7 @@ test_options=(
7281
--num-processes 1
7382
)
7483

75-
# Specific tests to run when sanitizer is enabled
84+
# Subset of tests run when a sanitizer is active (keeps the suite fast and focused).
7685
sanitizer_tests=(
7786
-v
7887
test_generator_lund_file_events
@@ -81,35 +90,15 @@ sanitizer_tests=(
8190
examples_geo_basic_simple_flux_ascii_variation_default
8291
)
8392

93+
# Tests that need the CSV plugin preloaded to work under UBSan.
8494
undefined_preload_tests=(
8595
test_gstreamer_csv_verbose
8696
)
8797

88-
function run_meson_test_with_retry {
89-
local label="$1"
90-
shift
91-
92-
for attempt in 1 2; do
93-
echo " > Running ${label} (attempt ${attempt}/2):" "$@" | tee -a "$test_log"
94-
"$@" >> "$test_log"
95-
local exit_code=$?
96-
97-
if [ $exit_code -eq 0 ]; then
98-
return 0
99-
fi
100-
101-
if [ $attempt -eq 2 ]; then
102-
return $exit_code
103-
fi
104-
105-
echo " > ${label} failed; retrying once" | tee -a "$test_log"
106-
done
107-
}
108-
109-
98+
# Start with the base test options; append sanitizer-specific or verbose flag below.
11099
meson_args=( "${test_options[@]}" )
111100

112-
# if $1 is NOT one of sanitize option, run meson test
101+
# When a sanitizer is active run only the targeted subset; otherwise run all tests verbosely.
113102
case "$1" in
114103
address|thread|undefined|leak)
115104
meson_args+=( "${sanitizer_tests[@]}" )
@@ -119,8 +108,9 @@ case "$1" in
119108
;;
120109
esac
121110

122-
: > "$test_log"
123-
if ! run_meson_test_with_retry "meson test" meson test "${meson_args[@]}"; then
111+
# Clear (or create) the test log before the first test run.
112+
> "$test_log"
113+
if ! run_command_with_retry "meson test" meson test "${meson_args[@]}"; then
124114
echo " > Meson Tests failed. Log: "
125115
cat $test_log
126116
exit 1
@@ -129,12 +119,13 @@ else
129119
echo
130120
fi
131121

122+
# Under UBSan, preload the CSV plugin to avoid static-TLS exhaustion at dlopen time.
132123
if [ "$1" = "undefined" ]; then
133124
gstreamer_csv_plugin="$PWD/build/gstreamer_csv_plugin.gplugin"
134125
# UBSan on Linux can exhaust static TLS before GEMC's runtime dlopen() loads
135126
# this plugin. Preloading it makes the dynamic loader reserve TLS at process
136127
# startup while keeping the workaround scoped to the affected sanitizer test.
137-
if ! run_meson_test_with_retry "undefined sanitizer preload tests" \
128+
if ! run_command_with_retry "undefined sanitizer preload tests" \
138129
env LD_PRELOAD="$gstreamer_csv_plugin" meson test "${test_options[@]}" -v "${undefined_preload_tests[@]}"; then
139130
echo " > Meson Tests failed. Log: "
140131
cat $test_log
@@ -145,6 +136,7 @@ if [ "$1" = "undefined" ]; then
145136
fi
146137
fi
147138

139+
# Print a pass/fail summary parsed from the accumulated test log.
148140
echo " - Successful: $(grep 'Ok:' "$test_log" | awk '{sum += $2} END {print sum + 0}')" | tee -a "$test_log"
149141
echo " - Failures: $(grep 'Fail:' "$test_log" | awk '{sum += $2} END {print sum + 0}')" | tee -a "$test_log"
150142
echo " > Complete test log: $test_log"

ci/env.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,28 @@ function meson_setup_options {
8989
echo "${args[@]}"
9090
}
9191

92+
# Run any command, retrying once on failure. Appends output to $test_log.
93+
function run_command_with_retry {
94+
local label="$1"
95+
shift
96+
97+
for attempt in 1 2; do
98+
echo " > Running ${label} (attempt ${attempt}/2):" "$@" | tee -a "$test_log"
99+
"$@" >> "$test_log"
100+
local exit_code=$?
101+
102+
if [ $exit_code -eq 0 ]; then
103+
return 0
104+
fi
105+
106+
if [ $attempt -eq 2 ]; then
107+
return $exit_code
108+
fi
109+
110+
echo " > ${label} failed; retrying once" | tee -a "$test_log"
111+
done
112+
}
113+
92114
export GEMC="${SIM_HOME:?SIM_HOME not set}/gemc"
93115

94116
log_dir=$SIM_HOME/logs

0 commit comments

Comments
 (0)