Skip to content

Commit 42358f1

Browse files
committed
feat(ci): enhance log artifacts for Sponge and improve readability
1 parent e19f676 commit 42358f1

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

.kokoro/system.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ run_package_test() {
121121
return $res
122122
}
123123

124+
# Analyzes results of parallel test runs, prints summary, and dumps failed logs
124125
reap_parallel_results() {
125126
local retval=0
126127
local failed_count=0
@@ -131,6 +132,7 @@ reap_parallel_results() {
131132
return 1
132133
fi
133134

135+
# Count failed packages by checking for .failed marker files
134136
for failed in "$LOG_DIR"/*.failed; do
135137
if [ -f "$failed" ]; then
136138
failed_count=$((failed_count + 1))
@@ -158,7 +160,11 @@ reap_parallel_results() {
158160
echo "--------------------------------------------------"
159161
echo "LOGS FOR: $pkg"
160162
echo "--------------------------------------------------"
161-
cat "$LOG_DIR/$pkg.log"
163+
if [ -n "$KOKORO_ARTIFACTS_DIR" ] && [ -f "$KOKORO_ARTIFACTS_DIR/$pkg/sponge_log.log" ]; then
164+
cat "$KOKORO_ARTIFACTS_DIR/$pkg/sponge_log.log"
165+
else
166+
cat "$LOG_DIR/$pkg.log"
167+
fi
162168
echo ""
163169
fi
164170
done
@@ -249,7 +255,25 @@ export LOG_DIR
249255
export -f run_package_test
250256
export system_test_script PROJECT_ROOT KOKORO_GFILE_DIR
251257

252-
printf '%s\n' "${PACKAGES_TO_TEST[@]}" | xargs -P "$MAX_JOBS" -I {} bash -c 'run_package_test "{}" > "$LOG_DIR/{}.log" 2>&1 || touch "$LOG_DIR/{}.failed"'
258+
# Stream package names to xargs for parallel execution
259+
# -P "$MAX_JOBS" controls concurrency
260+
# -I {} replaces {} with the package name
261+
printf '%s\n' "${PACKAGES_TO_TEST[@]}" \
262+
| xargs -P "$MAX_JOBS" -I {} \
263+
bash -c '
264+
pkg="$1"
265+
# Determine log location: prefer Sponge artifacts directory if available
266+
if [ -n "$KOKORO_ARTIFACTS_DIR" ]; then
267+
pkg_log_dir="$KOKORO_ARTIFACTS_DIR/$pkg"
268+
mkdir -p "$pkg_log_dir" || { touch "$LOG_DIR/$pkg.failed"; exit 1; }
269+
log_file="$pkg_log_dir/sponge_log.log"
270+
else
271+
log_file="$LOG_DIR/$pkg.log"
272+
fi
273+
274+
# Run test; if it fails, create a .failed file to signal failure to the reaper
275+
run_package_test "$pkg" > "$log_file" 2>&1 || touch "$LOG_DIR/$pkg.failed"
276+
' _ "{}"
253277

254278
reap_parallel_results || RETVAL=1
255279

0 commit comments

Comments
 (0)