Skip to content

Refinee before-submit script. #2394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions .github/bin/before-submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ PROJECT_ROOT=$(dirname $0)/../../
cd ${PROJECT_ROOT}

RUN_CLANG_TIDY=1
RUN_ALL_CPP_STD=1
while [ $# -ne 0 ]; do
case $1 in
--skip-clang-tidy) RUN_CLANG_TIDY=0;;
--skip-cpp-std) RUN_ALL_CPP_STD=0;;
*)
echo "Unknown option $1"
exit 1
Expand All @@ -18,11 +20,12 @@ while [ $# -ne 0 ]; do
done

if [ -t 1 ]; then
BOLD=$'\033[7m'
RED=$'\033[1;30;41m'
BOLD=$'\033[1m'
INVERSE=$'\033[7m'
RED=$'\033[1;37;41m'
NORM=$'\033[0m'
else
BOLD=""
INVERSE=""
NORM=""
fi

Expand All @@ -35,42 +38,45 @@ function check_exit() {
fi
}

echo "${BOLD}-- Build bant if not already (comp-db, build-cleaner) --${NORM}"
echo "${INVERSE}-- 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}"
echo "${INVERSE}-- Refresh compilation db --${NORM}"
.github/bin/make-compilation-db.sh
check_exit

echo "${BOLD}-- Run build cleaner --${NORM}"
echo "${INVERSE}-- Run build cleaner --${NORM}"
. <(${BANT} dwyu ...)

echo "${BOLD}-- Run all tests --${NORM}"
echo "${INVERSE}-- Run all tests --${NORM}"
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_ALL_CPP_STD}" -eq 1 ]; then
echo "${BOLD}Running other c++ standards. Skip with --skip-cpp-std${NORM}"
for cpp_standard in c++20 c++23 ; do
echo "${INVERSE}-- Run tests wtih -std=${cpp_standard} --${NORM}"
bazel test -c opt --cxxopt=-std=${cpp_standard} --test_summary=terse ...
check_exit
done
fi

if [ "${RUN_CLANG_TIDY}" -eq 1 ]; then
echo "${BOLD}-- Running clang-tidy and cache results --${NORM}"
echo "${INVERSE}-- Running clang-tidy and cache results --${NORM}"
echo "This will take a while if run the first time and no cache has"
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}"
echo "${INVERSE}-- Format code and BUILD files --${NORM}"
.github/bin/run-format.sh

echo "${BOLD}-- Check for other potential problems --${NORM}"
echo "${INVERSE}-- Check for other potential problems --${NORM}"
.github/bin/check-potential-problems.sh
check_exit

Expand Down
Loading