11#! /usr/bin/env bash
2- set -euox pipefail
2+ set -euo pipefail
33
44# Integration build script.
55# Captures warning counts for regression tracking.
6+ #
7+ # Usage: ./integration_test.sh [--known-good <path>]
8+ # --known-good: Optional path to known_good.json file
69
710CONFIG=${CONFIG:- bl-x86_64-linux}
811LOG_DIR=${LOG_DIR:- _logs/ logs}
912SUMMARY_FILE=${SUMMARY_FILE:- _logs/ build_summary.md}
10- mkdir -p " ${LOG_DIR} " || true
13+ KNOWN_GOOD_FILE= " "
1114
15+ # maybe move this to known_good.json or a config file later
1216declare -A BUILD_TARGET_GROUPS=(
13- [baselibs ]=" @score_baselibs//score/..."
17+ [score_baselibs ]=" @score_baselibs//score/..."
1418 [score_communication]=" @score_communication//score/mw/com:com"
15- [persistency ]=" @score_persistency//src/cpp/src/... @score_persistency//src/rust/..."
19+ [score_persistency ]=" @score_persistency//src/cpp/src/... @score_persistency//src/rust/..."
1620 # [score_logging]="@score_logging//src/..."
1721 [score_orchestrator]=" @score_orchestrator//src/..."
1822 [score_test_scenarios]=" @score_test_scenarios//..."
1923 [score_feo]=" @score_feo//..."
2024)
2125
26+ # Parse command line arguments
27+ while [[ $# -gt 0 ]]; do
28+ case $1 in
29+ --known-good)
30+ KNOWN_GOOD_FILE=" $2 "
31+ shift 2
32+ ;;
33+ * )
34+ echo " Unknown option: $1 "
35+ echo " Usage: $0 [--known-good <path>]"
36+ exit 1
37+ ;;
38+ esac
39+ done
40+
41+ mkdir -p " ${LOG_DIR} " || true
42+
43+ # Function to extract commit hash from known_good.json
44+ get_commit_hash () {
45+ local module_name=$1
46+ local known_good_file=$2
47+
48+ if [[ -z " ${known_good_file} " ]] || [[ ! -f " ${known_good_file} " ]]; then
49+ echo " N/A"
50+ return
51+ fi
52+
53+ # Get the script directory
54+ local script_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
55+
56+ # Use the Python script to extract module info
57+ python3 " ${script_dir} /tools/get_module_info.py" " ${known_good_file} " " ${module_name} " " hash" 2> /dev/null || echo " N/A"
58+ }
59+
60+ # Function to extract repo URL from known_good.json
61+ get_module_repo () {
62+ local module_name=$1
63+ local known_good_file=$2
64+
65+ if [[ -z " ${known_good_file} " ]] || [[ ! -f " ${known_good_file} " ]]; then
66+ echo " N/A"
67+ return
68+ fi
69+
70+ # Get the script directory
71+ local script_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
72+
73+ # Use the Python script to extract module repo
74+ python3 " ${script_dir} /tools/get_module_info.py" " ${known_good_file} " " ${module_name} " " repo" 2> /dev/null || echo " N/A"
75+ }
76+
2277warn_count () {
2378 # Grep typical compiler and Bazel warnings; adjust patterns as needed.
2479 local file=$1
@@ -35,29 +90,41 @@ timestamp() { date '+%Y-%m-%d %H:%M:%S'; }
3590
3691echo " === Integration Build Started $( timestamp) ===" | tee " ${SUMMARY_FILE} "
3792echo " Config: ${CONFIG} " | tee -a " ${SUMMARY_FILE} "
93+ if [[ -n " ${KNOWN_GOOD_FILE} " ]]; then
94+ echo " Known Good File: ${KNOWN_GOOD_FILE} " | tee -a " ${SUMMARY_FILE} "
95+ fi
3896echo " " >> " ${SUMMARY_FILE} "
3997echo " ## Build Groups Summary" >> " ${SUMMARY_FILE} "
4098echo " " >> " ${SUMMARY_FILE} "
4199# Markdown table header
42100{
43- echo " | Group | Status | Duration (s) | Warnings | Deprecated refs |" ;
44- echo " |-------|--------|--------------|----------|-----------------|" ;
101+ echo " | Group | Status | Duration (s) | Warnings | Deprecated refs | Commit/Version | " ;
102+ echo " |-------|--------|--------------|----------|-----------------|----------------| " ;
45103} >> " ${SUMMARY_FILE} "
46104
47105overall_warn_total=0
48106overall_depr_total=0
49107
108+ # Track if any build group failed
109+ any_failed=0
110+
50111for group in " ${! BUILD_TARGET_GROUPS[@]} " ; do
51112 targets=" ${BUILD_TARGET_GROUPS[$group]} "
52113 log_file=" ${LOG_DIR} /${group} .log"
114+
53115 # Log build group banner only to stdout/stderr (not into summary table file)
54116 echo " --- Building group: ${group} ---"
117+ start_ts=$( date +%s)
118+ echo " bazel build --config " ${CONFIG} " ${targets} --verbose_failures"
55119 # GitHub Actions log grouping start
56120 echo " ::group::Bazel build (${group} )"
57- start_ts=$( date +%s)
58121 set +e
59122 bazel build --config " ${CONFIG} " ${targets} --verbose_failures 2>&1 | tee " $log_file "
60123 build_status=${PIPESTATUS[0]}
124+ # Track if any build group failed
125+ if [[ ${build_status} -ne 0 ]]; then
126+ any_failed=1
127+ fi
61128 set -e
62129 echo " ::endgroup::" # End Bazel build group
63130 end_ts=$( date +%s)
@@ -72,16 +139,37 @@ for group in "${!BUILD_TARGET_GROUPS[@]}"; do
72139 else
73140 status_symbol=" ❌(${build_status} )"
74141 fi
75- echo " | ${group} | ${status_symbol} | ${duration} | ${w_count} | ${d_count} |" | tee -a " ${SUMMARY_FILE} "
142+
143+ # Get commit hash/version for this group (group name is the module name)
144+ commit_hash=$( get_commit_hash " ${group} " " ${KNOWN_GOOD_FILE} " )
145+ repo=$( get_module_repo " ${group} " " ${KNOWN_GOOD_FILE} " )
146+
147+ # Truncate commit hash for display (first 8 chars)
148+ if [[ " ${commit_hash} " != " N/A" ]] && [[ ${# commit_hash} -gt 8 ]]; then
149+ commit_hash_display=" ${commit_hash: 0: 8} "
150+ else
151+ commit_hash_display=" ${commit_hash} "
152+ fi
153+
154+ # Only add link if KNOWN_GOOD_FILE is set
155+ if [[ -n " ${KNOWN_GOOD_FILE} " ]]; then
156+ commit_version_cell=" [${commit_hash_display} ](${repo} /tree/${commit_hash} )"
157+ else
158+ commit_version_cell=" ${commit_hash_display} "
159+ fi
160+
161+ echo " | ${group} | ${status_symbol} | ${duration} | ${w_count} | ${d_count} | ${commit_version_cell} |" | tee -a " ${SUMMARY_FILE} "
76162done
77163
78164# Append aggregate totals row to summary table
79- echo " | TOTAL | | | ${overall_warn_total} | ${overall_depr_total} |" >> " ${SUMMARY_FILE} "
80-
81- # Display the full build summary explicitly at the end
165+ echo " | TOTAL | | | ${overall_warn_total} | ${overall_depr_total} | |" >> " ${SUMMARY_FILE} "
82166echo ' ::group::Build Summary'
83167echo ' === Build Summary (echo) ==='
84168cat " ${SUMMARY_FILE} " || echo " (Could not read summary file ${SUMMARY_FILE} )"
85169echo ' ::endgroup::'
86170
87- exit 0
171+ # Report to GitHub Actions if any build group failed
172+ if [[ ${any_failed} -eq 1 ]]; then
173+ echo " ::error::One or more build groups failed. See summary above."
174+ exit 1
175+ fi
0 commit comments