Merge pull request #2391 from hzeller/feature-20250414-refine-before-submit

Refine before-submit.sh: also run under c++20 and c++23
diff --git a/.github/bin/before-submit.sh b/.github/bin/before-submit.sh
index 57c2e67..e8ba9dd 100755
--- a/.github/bin/before-submit.sh
+++ b/.github/bin/before-submit.sh
@@ -2,8 +2,6 @@
 #
 # A wrapper for all the things to do before a submit.
 
-BANT=$($(dirname $0)/get-bant-path.sh)
-
 PROJECT_ROOT=$(dirname $0)/../../
 cd ${PROJECT_ROOT}
 
@@ -21,23 +19,44 @@
 
 if [ -t 1 ]; then
   BOLD=$'\033[7m'
+  RED=$'\033[1;30;41m'
   NORM=$'\033[0m'
 else
   BOLD=""
   NORM=""
 fi
 
+FINAL_EXIT_CODE=0
+function check_exit() {
+  exit_code=$?
+  if [ ${exit_code} -ne 0 ]; then
+    FINAL_EXIT_CODE=$((FINAL_EXIT_CODE + exit_code))
+    echo "${RED} ^^ Got exit code ${exit_code} ^^ ${NORM}"
+  fi
+}
+
+echo "${BOLD}-- Build bant if not already (comp-db, build-cleaner) --${NORM}"
+BANT=$($(dirname $0)/get-bant-path.sh)
+
 # Compilation DB is needed for clang-tidy, but also
 # makes sure all external dependencies have been fetched so that
 # bant build cleaner can do a good job.
 echo "${BOLD}-- Refresh compilation db --${NORM}"
 .github/bin/make-compilation-db.sh
+check_exit
 
 echo "${BOLD}-- Run build cleaner --${NORM}"
 . <(${BANT} dwyu ...)
 
 echo "${BOLD}-- Run all tests --${NORM}"
-bazel test -c opt ...
+bazel test -c opt --test_summary=terse ...
+check_exit
+
+for cpp_standard in c++20 c++23 ; do
+  echo "${BOLD}-- Run tests wtih -std=${cpp_standard} --${NORM}"
+  bazel test -c opt --cxxopt=-std=${cpp_standard} --test_summary=terse ...
+  check_exit
+done
 
 if [ "${RUN_CLANG_TIDY}" -eq 1 ]; then
   echo "${BOLD}-- Running clang-tidy and cache results --${NORM}"
@@ -45,12 +64,21 @@
   echo "been created yet. Can't wait ? Skip with "
   echo "  $0 --skip-clang-tidy"
   .github/bin/run-clang-tidy-cached.cc
+  check_exit
 fi
 
 echo "${BOLD}-- Format code and BUILD files --${NORM}"
 .github/bin/run-format.sh
 
-echo "${BOLD}-- Check for potential problems --${NORM}"
+echo "${BOLD}-- Check for other potential problems --${NORM}"
 .github/bin/check-potential-problems.sh
+check_exit
 
-echo "Done. Check output above for any issues."
+echo "Done with before-submit checks."
+
+if [ ${FINAL_EXIT_CODE} -ne 0 ]; then
+  echo "${RED}Some failures. See in log above what's going on${NORM}"
+fi
+
+echo "Exit ${FINAL_EXIT_CODE}"
+exit ${FINAL_EXIT_CODE}