Skip to content

Commit

Permalink
Pass 'continuously_deployed_apps' to govuk-developers overflow
Browse files Browse the repository at this point in the history
govuk-developers is an edge case whereby if we have too many PRs
for a team(s) to handle, it 'overflows' into #govuk-developers.
This meant that `:continuously_deployed_apps` wasn't being defined
for the #govuk-developers entry.

This commit ensures that any continuously-deployed-apps
information is passed through with the overflow, so that the
govuk-developers channel gets the same CD improvement as the team
specific ones.
  • Loading branch information
ChrisBAshton committed Feb 8, 2021
1 parent a2eda3d commit c0b318d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/use_cases/distribute/overflow_to_developers_channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ def execute(application_prs_by_team:, overflow_at: 15)
@overflow_at = overflow_at

redistribution = []
continuously_deployed_apps = []

application_prs_by_team.each do |application_prs_for_team|
redistribution.concat(redistribute(application_prs_for_team[:applications]))
if application_prs_for_team[:continuously_deployed_apps]
continuously_deployed_apps.concat(application_prs_for_team[:continuously_deployed_apps])
end
end

if redistribution.any?
ensure_govuk_developers_exists
govuk_developers_application_prs[:applications].concat(redistribution)
redistribution.each do |app|
if continuously_deployed_apps.include?(app[:application_name])
govuk_developers_application_prs[:continuously_deployed_apps] << app[:application_name]
end
end
# govuk_developers_application_prs[:continuously_deployed_apps].concat("foo")
end

application_prs_by_team
Expand All @@ -25,7 +35,7 @@ def execute(application_prs_by_team:, overflow_at: 15)

def ensure_govuk_developers_exists
unless govuk_developers_application_prs
application_prs_by_team << { team_name: "govuk-developers", applications: [] }
application_prs_by_team << { team_name: "govuk-developers", applications: [], continuously_deployed_apps: [] }
end
end

Expand Down
37 changes: 37 additions & 0 deletions spec/use_cases/distribute/overflow_to_developers_channel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,41 @@ def distribute(prs, overflow_at)
expect(overflow_with_dev_team).to have_application_count_for_team(6, "govuk-developers")
end
end

context "with continuously_deployed_apps" do
let(:prs_by_team) do
[
{
team_name: "govuk-platform-health",
continuously_deployed_apps: %w[whitehall signon support content-publisher],
applications:
[
{ application_name: "whitehall", pull_request_count: 5 },
{ application_name: "signon", pull_request_count: 4 },
{ application_name: "ckanext-datagovuk", pull_request_count: 3 },
{ application_name: "collections-publisher", pull_request_count: 2 },
{ application_name: "content-data-admin", pull_request_count: 1 },
{ application_name: "content-publisher", pull_request_count: 1 },
{ application_name: "support", pull_request_count: 1 },
],
},
{
team_name: "govuk-top-team",
applications:
[
{ application_name: "not-another-whitehall", pull_request_count: 1 },
],
},
]
end

let(:overflow_with_dev_team) do
distribute(prs_by_team, 5)
end

it "should retain the continuously_deployed_apps information" do
govuk_developers = overflow_with_dev_team.find { |h| h[:team_name] == "govuk-developers" }
expect(govuk_developers[:continuously_deployed_apps]).to eq(%w[content-publisher support])
end
end
end

0 comments on commit c0b318d

Please sign in to comment.