Skip to content

Commit

Permalink
keep status state only for main branch in allowed pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
thatportugueseguy committed Jan 31, 2025
1 parent 75ae179 commit cd26b3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/action.ml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) (Buildkite_api :
in
let%lwt recipients =
let rules = cfg.status_rules.rules in
match Context.is_pipeline_allowed ctx repo.url n with
match Context.is_pipeline_allowed ctx n with
| false -> Lwt.return []
| true ->
let%lwt dm_and_channels =
Expand Down Expand Up @@ -287,7 +287,9 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) (Buildkite_api :
let%lwt failed_builds_channel = get_failed_builds_channel_id () in
Lwt.return (dm_and_channels @ failed_builds_channel |> List.sort_uniq Status_notification.compare)
in
State.set_repo_pipeline_status ctx.state n;
(* We only care about maintaining status for allowed pipelines and the main branch *)
if Util.Build.is_main_branch cfg n && Context.is_pipeline_allowed ctx n then
State.set_repo_pipeline_status ctx.state n;
Lwt.return recipients

let partition_commit_comment (ctx : Context.t) n =
Expand Down
4 changes: 2 additions & 2 deletions lib/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ let hook_of_channel ctx channel_name =
(** [is_pipeline_allowed ctx repo_url notification] returns [true] if [status_rules]
doesn't define a whitelist of allowed pipelines in the config of [repo_url],
or if the list contains the pipeline name in [notification.context]; returns [false] otherwise. *)
let is_pipeline_allowed ctx repo_url (n : Github_t.status_notification) =
match find_repo_config ctx repo_url with
let is_pipeline_allowed ctx (n : Github_t.status_notification) =
match find_repo_config ctx n.repository.url with
| None -> true
| Some config -> Option.is_some (Util.Build.get_pipeline_config config n)

Expand Down

0 comments on commit cd26b3e

Please sign in to comment.