Skip to content

Commit

Permalink
Push waiting time logic into list-branch-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoWilken committed Nov 29, 2023
1 parent a0e9008 commit b558a01
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
9 changes: 1 addition & 8 deletions ci/build-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,14 @@ function report_state () {
pr_processing_done) prtime=$((time_now - TIME_PR_STARTED));;
esac

# If this is a rebuild, the last push time is mostly meaningless -- the PR
# hasn't been waiting since then for a check.
local waittime=
if [ -n "$LAST_PUSH_TIME" ] && [ "$BUILD_TYPE" != untested ]; then
waittime=$((time_now - LAST_PUSH_TIME))
fi

# Push to InfluxDB if configured
influxdb_push prcheck "repo=$PR_REPO" "checkname=$CHECK_NAME" \
"worker=$CHECK_NAME/$WORKER_INDEX/$WORKERS_POOL_SIZE" \
${NUM_BASE_COMMITS:+"num_base_commits=$NUM_BASE_COMMITS"} \
"prev_build=$BUILD_TYPE" \
-- "host=\"$(hostname -s)\"" "state=\"$current_state\"" \
"prid=\"$PR_NUMBER\"" ${prtime:+prtime=$prtime} ${PR_OK:+prok=$PR_OK} \
${waittime:+"waittime=$waittime"} \
${WAITING_SINCE:+waittime=$((time_now - WAITING_SINCE))} \
${HAVE_JALIEN_TOKEN:+have_jalien_token=$HAVE_JALIEN_TOKEN}

# Push to Google Analytics if configured
Expand Down
2 changes: 1 addition & 1 deletion ci/continuous-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fi
run_start_time=$(date +%s)
if [ -n "$HASHES" ]; then
# Loop through PRs we can build if there are any.
echo "$HASHES" | cat -n | while read -r BUILD_SEQ BUILD_TYPE PR_NUMBER PR_HASH env_name LAST_PUSH_TIME; do
echo "$HASHES" | cat -n | while read -r BUILD_SEQ BUILD_TYPE PR_NUMBER PR_HASH env_name WAITING_SINCE; do
# Run iterations in a subshell so environment variables are not kept across
# potentially different repos. This is an issue as env files are allowed to
# define arbitrary variables that other files (or the defaults file) might
Expand Down
15 changes: 11 additions & 4 deletions list-branch-pr
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,18 @@ def main(args):
# pr["waiting_since"] can apparently be None sometimes, which breaks
# sorting, so default to the empty string if so.
for pull in sorted(prs, key=lambda pr: pr["waiting_since"] or ""):
commit_timestr = pull["waiting_since"]
commit_time = datetime.fromisoformat(commit_timestr.replace("Z", "+00:00")) \
if commit_timestr else datetime.now(timezone.utc)
if group == "untested":
commit_timestr = pull["waiting_since"]
commit_time = datetime.fromisoformat(commit_timestr.replace("Z", "+00:00")) \
if commit_timestr else datetime.now(timezone.utc)
waiting_since = str(int(commit_time.timestamp()))
else:
# If this PR has been built before, the commit time is a bit
# meaningless -- the PR hasn't actually been waiting since
# then for this check.
waiting_since = ""
print(group, pull["number"], pull["sha"], pull["build_config"],
int(commit_time.timestamp()), sep="\t")
waiting_since, sep="\t")

if grouped["untested"]:
# If there are untested PRs waiting, build all of them first.
Expand Down

0 comments on commit b558a01

Please sign in to comment.