fc-queue-runner: map exit codes to extended BuildStatus variants
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ibaa4de9e2c789931df8c67a53528829a6a6a6964
This commit is contained in:
parent
f4772036ce
commit
5f09a46d29
3 changed files with 14 additions and 9 deletions
|
|
@ -111,6 +111,7 @@ pub async fn run_nix_build_remote(
|
||||||
|
|
||||||
Ok::<_, CiError>(BuildResult {
|
Ok::<_, CiError>(BuildResult {
|
||||||
success: status.success(),
|
success: status.success(),
|
||||||
|
exit_code: status.code(),
|
||||||
stdout: stdout_buf,
|
stdout: stdout_buf,
|
||||||
stderr: stderr_buf,
|
stderr: stderr_buf,
|
||||||
output_paths,
|
output_paths,
|
||||||
|
|
@ -131,6 +132,7 @@ pub async fn run_nix_build_remote(
|
||||||
|
|
||||||
pub struct BuildResult {
|
pub struct BuildResult {
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
|
pub exit_code: Option<i32>,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String,
|
pub stderr: String,
|
||||||
pub output_paths: Vec<String>,
|
pub output_paths: Vec<String>,
|
||||||
|
|
@ -288,6 +290,7 @@ pub async fn run_nix_build(
|
||||||
|
|
||||||
Ok::<_, CiError>(BuildResult {
|
Ok::<_, CiError>(BuildResult {
|
||||||
success: status.success(),
|
success: status.success(),
|
||||||
|
exit_code: status.code(),
|
||||||
stdout: stdout_buf,
|
stdout: stdout_buf,
|
||||||
stderr: stderr_buf,
|
stderr: stderr_buf,
|
||||||
output_paths,
|
output_paths,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ pub async fn run(
|
||||||
if let Err(e) = repo::builds::complete(
|
if let Err(e) = repo::builds::complete(
|
||||||
&pool,
|
&pool,
|
||||||
build.id,
|
build.id,
|
||||||
BuildStatus::Completed,
|
BuildStatus::Succeeded,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
|
@ -95,7 +95,7 @@ pub async fn run(
|
||||||
if let Err(e) = repo::builds::complete(
|
if let Err(e) = repo::builds::complete(
|
||||||
&pool,
|
&pool,
|
||||||
build.id,
|
build.id,
|
||||||
BuildStatus::Completed,
|
BuildStatus::Succeeded,
|
||||||
existing.log_path.as_deref(),
|
existing.log_path.as_deref(),
|
||||||
existing.build_output_path.as_deref(),
|
existing.build_output_path.as_deref(),
|
||||||
None,
|
None,
|
||||||
|
|
|
||||||
|
|
@ -688,7 +688,7 @@ async fn run_build(
|
||||||
repo::builds::complete(
|
repo::builds::complete(
|
||||||
pool,
|
pool,
|
||||||
build.id,
|
build.id,
|
||||||
BuildStatus::Completed,
|
BuildStatus::Succeeded,
|
||||||
log_path.as_deref(),
|
log_path.as_deref(),
|
||||||
primary_output,
|
primary_output,
|
||||||
None,
|
None,
|
||||||
|
|
@ -730,17 +730,21 @@ async fn run_build(
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let failure_status = build_result
|
||||||
|
.exit_code
|
||||||
|
.map(BuildStatus::from_exit_code)
|
||||||
|
.unwrap_or(BuildStatus::Failed);
|
||||||
repo::builds::complete(
|
repo::builds::complete(
|
||||||
pool,
|
pool,
|
||||||
build.id,
|
build.id,
|
||||||
BuildStatus::Failed,
|
failure_status,
|
||||||
log_path.as_deref(),
|
log_path.as_deref(),
|
||||||
None,
|
None,
|
||||||
Some(&build_result.stderr),
|
Some(&build_result.stderr),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
tracing::warn!(build_id = %build.id, "Build failed");
|
tracing::warn!(build_id = %build.id, "Build failed: {:?}", failure_status);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
@ -771,9 +775,7 @@ async fn run_build(
|
||||||
|
|
||||||
// Dispatch notifications after build completion
|
// Dispatch notifications after build completion
|
||||||
let updated_build = repo::builds::get(pool, build.id).await?;
|
let updated_build = repo::builds::get(pool, build.id).await?;
|
||||||
if updated_build.status == BuildStatus::Completed
|
if updated_build.status.is_finished() {
|
||||||
|| updated_build.status == BuildStatus::Failed
|
|
||||||
{
|
|
||||||
if let Some((project, commit_hash)) =
|
if let Some((project, commit_hash)) =
|
||||||
get_project_for_build(pool, build).await
|
get_project_for_build(pool, build).await
|
||||||
{
|
{
|
||||||
|
|
@ -787,7 +789,7 @@ async fn run_build(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-promote channels if all builds in the evaluation are done
|
// Auto-promote channels if all builds in the evaluation are done
|
||||||
if updated_build.status == BuildStatus::Completed
|
if updated_build.status.is_success()
|
||||||
&& let Ok(eval) = repo::evaluations::get(pool, build.evaluation_id).await
|
&& let Ok(eval) = repo::evaluations::get(pool, build.evaluation_id).await
|
||||||
{
|
{
|
||||||
if let Err(e) =
|
if let Err(e) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue