Skip to content

Commit

Permalink
Merge pull request #1513 from argos-ci/fix-incoherent-status
Browse files Browse the repository at this point in the history
fix(build): fix inconsistent status
  • Loading branch information
gregberge authored Jan 5, 2025
2 parents 99c00f1 + 424f838 commit f5d6807
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions apps/backend/src/database/models/Build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,23 @@ export class Build extends Model {
Build.getStatuses(builds),
Build.getReviewStatuses(builds),
]);
const aggregateStatuses = builds.map((build, index) => {
const status =
reviewStatuses[index] || build.conclusion || statuses[index];
return BuildAggregatedStatusSchema.parse(status);
return builds.map((build, index) => {
if (reviewStatuses[index]) {
return reviewStatuses[index];
}
if (build.conclusion) {
return build.conclusion;
}
invariant(statuses[index], "status should be fetched");
// A progress status at this point means that the build has just been
// completed while the status was being fetched.
// So we consider it as progress.
if (statuses[index] === "complete") {
return "progress";
}

return statuses[index];
});
return aggregateStatuses;
}

/**
Expand Down

0 comments on commit f5d6807

Please sign in to comment.