Skip to content

Commit b34d404

Browse files
update state cleanup logic
1 parent f3b80fb commit b34d404

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/state.ml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,17 @@ let set_repo_pipeline_status { state } (n : Github_t.status_notification) =
126126
in
127127
IntMap.remove build_number builds_map
128128
|> IntMap.filter (fun build_number' build_status ->
129-
match build_status.State_t.failed_steps with
130-
(* Remove old builds without failed steps because they were fixed and cleaned from state *)
131-
| [] when build_number' < build_number && build_status.is_finished -> false
132-
(* Remove builds that ran for more than the threshold or for which we didn't get an end notification *)
133-
| _ when is_past_threshold build_status threshold -> false
134-
| _ -> true))
129+
match build_status.State_t.is_finished, build_number' < build_number with
130+
| true, true ->
131+
(* remove all finished older builds *)
132+
false
133+
| false, true when is_past_threshold build_status threshold ->
134+
(* remove older builds that ran for longer than the threshold,
135+
or for which we might not have received a final notification *)
136+
false
137+
| _ ->
138+
(* keep all other builds *)
139+
true))
135140
in
136141
let rm_successful_step =
137142
update_builds_in_branches ~branches:n.branches ~f:(fun builds_map ->

0 commit comments

Comments
 (0)