Skip to content
Merged
Show file tree
Hide file tree
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions migrations/20260113181302_add_duration_to_build.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Add down migration script here
ALTER TABLE build DROP COLUMN duration;
2 changes: 2 additions & 0 deletions migrations/20260113181302_add_duration_to_build.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Add up migration script here
ALTER TABLE build ADD COLUMN duration INTERVAL;
2 changes: 1 addition & 1 deletion src/bors/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub async fn cancel_build(
CancelBuildConclusion::Timeout => BuildStatus::Timeouted,
CancelBuildConclusion::Cancel => BuildStatus::Cancelled,
};
db.update_build_status(build, status)
db.update_build_column(build, status, None)
.await
.map_err(CancelBuildError::FailedToMarkBuildAsCancelled)?;

Expand Down
18 changes: 14 additions & 4 deletions src/bors/build_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,16 @@ pub async fn handle_build_queue_event(
// First try to complete builds, and only then timeout then
// Because if the bot was offline for some time, we want to first attempt to
// actually finish the build, otherwise it might get instantly timeouted.
if !maybe_complete_build(&repo, db, &build, &pr, &merge_queue_tx, None)
.await?
if !maybe_complete_build(
&repo,
db,
&build,
&pr,
&merge_queue_tx,
None,
None,
)
.await?
{
maybe_timeout_build(&repo, db, &build, &pr, timeout).await?;
}
Expand All @@ -113,7 +121,7 @@ pub async fn handle_build_queue_event(
tracing::warn!(
"Detected orphaned pending without a PR, marking it as timeouted: {build:?}"
);
db.update_build_status(&build, BuildStatus::Timeouted)
db.update_build_column(&build, BuildStatus::Timeouted, None)
.await?;
}
anyhow::Ok(())
Expand Down Expand Up @@ -148,6 +156,7 @@ pub async fn handle_build_queue_event(
&pr,
&merge_queue_tx,
Some(CompletionTrigger { error_context }),
event.running_time,
)
.await?;
}
Expand Down Expand Up @@ -219,6 +228,7 @@ async fn maybe_complete_build(
pr: &PullRequestModel,
merge_queue_tx: &MergeQueueSender,
completion_trigger: Option<CompletionTrigger>,
running_time: Option<chrono::Duration>,
) -> anyhow::Result<bool> {
assert_eq!(
build.status,
Expand Down Expand Up @@ -299,7 +309,7 @@ async fn maybe_complete_build(
}),
};

db.update_build_status(build, status).await?;
db.update_build_column(build, status, running_time).await?;
if let Some(trigger) = trigger {
let pr = repo.client.get_pull_request(pr_num).await?;
handle_label_trigger(repo, &pr, trigger).await?;
Expand Down
2 changes: 1 addition & 1 deletion src/bors/merge_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ async fn handle_successful_build(

if let Some(error_comment) = error_comment {
ctx.db
.update_build_status(auto_build, BuildStatus::Failure)
.update_build_column(auto_build, BuildStatus::Failure, None)
.await?;
repo.client
.post_comment(pr_num, error_comment, &ctx.db)
Expand Down
8 changes: 5 additions & 3 deletions src/database/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::operations::{
get_workflows_for_build, insert_repo_if_not_exists, record_tagged_bot_comment,
set_pr_assignees, set_pr_mergeability_state, set_pr_priority, set_pr_rollup, set_pr_status,
set_stale_mergeability_status_by_base_branch, unapprove_pull_request, undelegate_pull_request,
update_build_check_run_id, update_build_status, update_pr_try_build_id, update_workflow_status,
update_build_check_run_id, update_build_column, update_pr_try_build_id, update_workflow_status,
upsert_pull_request, upsert_repository,
};
use super::{ApprovalInfo, DelegatedPermission, MergeableState, RunId, UpsertPullRequestParams};
Expand All @@ -20,6 +20,7 @@ use crate::database::{
use crate::github::PullRequestNumber;
use crate::github::{CommitSha, GithubRepoName};
use anyhow::Context;
use chrono::Duration;
use itertools::Either;
use sqlx::PgPool;
use sqlx::postgres::PgAdvisoryLock;
Expand Down Expand Up @@ -256,12 +257,13 @@ impl PgDbClient {
get_pending_builds(&self.pool, repo).await
}

pub async fn update_build_status(
pub async fn update_build_column(
&self,
build: &BuildModel,
status: BuildStatus,
duration: Option<Duration>,
) -> anyhow::Result<()> {
update_build_status(&self.pool, build.id, status).await
update_build_column(&self.pool, build.id, status, duration).await
}

pub async fn update_build_check_run_id(
Expand Down
Loading