Skip to content

Commit

Permalink
Fix bugs in check jobs
Browse files Browse the repository at this point in the history
- When a check job marked itself as failed using the API,
update_build_status_after_check would notice that the build is no longer
in the Validating state and think something was wrong. Fixed by making
it do nothing if the build is already marked as failed.
- Change the JSON job results from null to {}
  • Loading branch information
jameswestman authored and barthalion committed Jun 21, 2023
1 parent a1f4d2f commit 52454dc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/jobs/check_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl JobInstance for CheckJobInstance {
Ok(())
})?;

Ok(json! {()})
Ok(json!({}))
}
}

Expand Down Expand Up @@ -175,13 +175,18 @@ pub fn update_build_status_after_check(
.for_update()
.get_result::<Build>(conn)?;

let repo_state = RepoState::from_db(build.repo_state, &build.repo_state_reason);

if matches!(repo_state, RepoState::Failed(_)) {
/* If the build has already failed, don't change its status */
return Ok(());
}

// Sanity check--make sure the build is still in Validating state
if !RepoState::from_db(build.repo_state, &build.repo_state_reason)
.same_state_as(&RepoState::Validating)
{
if !matches!(repo_state, RepoState::Validating) {
return Err(JobError::new(&format!(
"Expected repo to be in {:?} state upon check completion, but it was in {:?}",
RepoState::Committing,
RepoState::Validating,
RepoState::from_db(build.repo_state, &build.repo_state_reason)
)));
}
Expand Down

0 comments on commit 52454dc

Please sign in to comment.