diff --git a/ci/build-helpers.sh b/ci/build-helpers.sh index 4eadd269..ad5a76c1 100755 --- a/ci/build-helpers.sh +++ b/ci/build-helpers.sh @@ -39,13 +39,6 @@ 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" \ @@ -53,7 +46,7 @@ function report_state () { "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 diff --git a/ci/continuous-builder.sh b/ci/continuous-builder.sh index 72ce388f..84ada931 100755 --- a/ci/continuous-builder.sh +++ b/ci/continuous-builder.sh @@ -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 diff --git a/list-branch-pr b/list-branch-pr index 2d38ac1f..e6285204 100755 --- a/list-branch-pr +++ b/list-branch-pr @@ -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.