Skip to content

fix(scripts): Use gh api to fetch ci logs more reliably #7133

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 2 commits into from
Apr 14, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Fix
  • Loading branch information
mafredri committed Apr 14, 2023
commit f02b74475c76f0ac2ae8b3e0e209bc417ed3a9c3
24 changes: 14 additions & 10 deletions scripts/ci-report/fetch_stats_from_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ while read -r run; do
fi
if [[ ${line} == *"##[group]"* ]]; then
log_buffer=("${line}")
continue
fi
if [[ ${#log_buffer[@]} -gt 0 ]]; then
log_buffer+=("${line}")
fi
if [[ ${line} == *"##[endgroup]"* ]]; then
if [[ ${found_step} -eq 1 ]]; then
Expand All @@ -139,9 +143,6 @@ while read -r run; do
log_buffer=()
continue
fi
if [[ ${#log_buffer[@]} -gt 0 ]]; then
log_buffer+=("${line}")
fi
# If line contains go run ./scripts/ci-report/main.go gotests.json
if [[ ${line} == *"go run ./scripts/ci-report/main.go"* ]]; then
found_step=1
Expand Down Expand Up @@ -169,16 +170,19 @@ while read -r run; do
echo "Failed to fetch log for: ${job_name} (${job_database_id}, ${job_url}), skipping..."
continue
}
log_lines="$(wc -l "${job_log}" | awk '{print $1}')"
if [[ ${log_lines} -lt 2 ]]; then
# Sometimes gh returns nothing and gives no error :'(
rm -f "${job_log}"
echo "Log is empty for: ${job_name} (${job_database_id}, ${job_url}), skipping..."
continue
fi
fi
fi

log_lines="$(wc -l "${job_log}" | awk '{print $1}')"
if [[ ${log_lines} -lt 7 ]]; then
# Sanity check in case something went wrong, the ##[group]
# and ##[endgroup] header is 6 lines and start of JSON ("{")
# makes the 7th.
rm -f "${job_log}"
echo "Log is empty for: ${job_name} (${job_database_id}, ${job_url}), skipping..."
continue
fi

if ! job_stats="$(
# Extract the stats job output (JSON) from the job log,
# discarding the timestamp and non-JSON header.
Expand Down