Skip to content

Commit

Permalink
summaries: cope with changing SHA between jobs
Browse files Browse the repository at this point in the history
That can happen, e.g. when modifying the commit messages.

We can take the path before running each test instead of taking it at
the end.

Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
  • Loading branch information
matttbe committed Nov 7, 2024
1 parent c31475f commit 0c138d2
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ is_mode_btf() {
[[ "${1}" == "btf-"* ]]
}

_get_results_dir_common() {
echo "${RESULTS_DIR_BASE}/$(git rev-parse --short HEAD || echo "UNKNOWN")"
# $1: mode
_get_results_dir() {
echo "${RESULTS_DIR_BASE}/$(git rev-parse --short HEAD || echo "UNKNOWN")/${1}"
}

setup_env() { local mode
Expand Down Expand Up @@ -274,7 +275,7 @@ setup_env() { local mode
# The CI doesn't need to access to the outside world, so no '--net'
else
# avoid override
RESULTS_DIR="$(_get_results_dir_common)/${mode}"
RESULTS_DIR="$(_get_results_dir "${mode}")"
rm -rf "${RESULTS_DIR}"
mkdir -p "${RESULTS_DIR}"

Expand Down Expand Up @@ -1664,16 +1665,15 @@ print_conclusion() { local rc=${1}
fi
}

# $@: mode
print_summaries() { local mode results
# $@: result paths
print_summaries() { local result
set +x
results="$(_get_results_dir_common)"

_print_line
echo

for mode in "${@}"; do
case "$(cat "${results}/${mode}/conclusion.txt")" in
for result in "${@}"; do
case "$(cat "${result}/conclusion.txt")" in
*": Success"*)
echo -ne "\n${COLOR_GREEN}"
;;
Expand All @@ -1684,16 +1684,16 @@ print_summaries() { local mode results
echo -ne "\n${COLOR_RED}"
;;
esac
cat "${results}/${mode}/summary.txt" || echo "Error: no summary"
cat "${result}/summary.txt" || echo "Error: no summary"

echo -ne "${COLOR_RESET}\n"
_print_line
echo
done

echo -ne "\n${COLOR_BLUE}"
for mode in "${@}"; do
cat "${results}/${mode}/conclusion.txt" || echo "Error: No conclusion"
for result in "${@}"; do
cat "${result}/conclusion.txt" || echo "Error: No conclusion"
done
echo -ne "${COLOR_RESET}"
}
Expand Down Expand Up @@ -1788,16 +1788,20 @@ case "${INPUT_MODE}" in
;;
"expect" | "all" | "expect-all" | "auto-all")
rc=0
results=("$(_get_results_dir "normal")")
INPUT_MODE="auto-normal" "${0}" "${@}" || rc=${?}
results+=("$(_get_results_dir "debug")")
INPUT_MODE="auto-debug" "${0}" "${@}" || rc=${?}
print_summaries "normal" "debug"
print_summaries "${results[@]}"
exit ${rc}
;;
"expect-btf-all" | "auto-btf-all" )
rc=0
results=("$(_get_results_dir "btf-normal")")
INPUT_MODE="auto-btf-normal" "${0}" "${@}" || rc=${?}
results+=("$(_get_results_dir "btf-debug")")
INPUT_MODE="auto-btf-debug" "${0}" "${@}" || rc=${?}
print_summaries "btf-normal" "btf-debug"
print_summaries "${results[@]}"
exit ${rc}
;;
"make")
Expand Down

0 comments on commit 0c138d2

Please sign in to comment.