Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split detection of dependents [WIP] #1069

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/test-bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def test_bot_args
description: "Only run the formulae steps."
switch "--only-formulae-detect",
description: "Only run the formulae detection steps."
switch "--only-dependents-detect",
description: "Only run the dependents detection steps."
switch "--only-formulae-dependents",
description: "Only run the formulae dependents steps."
switch "--only-bottles-fetch",
Expand All @@ -98,6 +100,12 @@ def test_bot_args
description: "Use these added formulae rather than running the formulae detection steps."
comma_array "--deleted-formulae=",
description: "Use these deleted formulae rather than running the formulae detection steps."
comma_array "--source-dependents=",
description: "Use these source dependents rather than running the dependent detection steps."
comma_array "--bottled-dependents=",
description: "Use these bottled dependents rather than running the dependent detection steps."
comma_array "--testable-dependents=",
description: "Use these testable depenents rather than running the dependent detection steps."
comma_array "--skipped-or-failed-formulae=",
description: "Use these skipped or failed formulae from formulae steps for a " \
"formulae dependents step."
Expand Down
21 changes: 20 additions & 1 deletion lib/tests/formulae_dependents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def dependent_formulae!(formula_name, args:)
source_dependents, bottled_dependents, testable_dependents =
dependents_for_formula(formula, formula_name, args:)

print_dependents(source_dependents, bottled_dependents, testable_dependents)
return if args.only_dependents_detect?

source_dependents.each do |dependent|
install_dependent(dependent, testable_dependents, build_from_source: true, args:)
install_dependent(dependent, testable_dependents, args:) if bottled?(dependent)
Expand All @@ -85,6 +88,12 @@ def dependent_formulae!(formula_name, args:)
end

def dependents_for_formula(formula, formula_name, args:)
source_dependents = Array(args.source_dependents).map { |dep| Formulary.factory(dep) }
bottled_dependents = Array(args.bottled_dependents).map { |dep| Formulary.factory(dep) }
testable_dependents = Array(args.testable_dependents).map { |dep| Formulary.factory(dep) }
Comment on lines +91 to +93
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A method for this might be nice as it's doing the same thing 3 times.

dep_array = [source_dependents, bottled_dependents, testable_dependents]
return dep_array if dep_array.any?(&:present?)

info_header "Determining dependents..."

uses_args = %w[--formula --eval-all]
Expand Down Expand Up @@ -161,6 +170,10 @@ def dependents_for_formula(formula, formula_name, args:)
bottled_dependents = dependents.select { |dep| bottled?(dep) }
testable_dependents += bottled_dependents.select(&:test_defined?)

[source_dependents, bottled_dependents, testable_dependents]
end

def print_dependents(source_dependents, bottled_dependents, testable_dependents)
info_header "Source dependents:"
puts source_dependents

Expand All @@ -170,7 +183,13 @@ def dependents_for_formula(formula, formula_name, args:)
info_header "Testable dependents:"
puts testable_dependents

[source_dependents, bottled_dependents, testable_dependents]
return unless ENV["GITHUB_ACTIONS"].present?

File.open(ENV.fetch("GITHUB_OUTPUT"), "a") do |f|
f.puts "source_dependents=#{source_dependents.map(&:full_name).join(",")}"
f.puts "bottled_dependents=#{bottled_dependents.map(&:full_name).join(",")}"
f.puts "testable_dependents=#{testable_dependents.map(&:full_name).join(",")}"
Comment on lines +189 to +191
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

end
end

def install_dependent(dependent, testable_dependents, args:, build_from_source: false)
Expand Down
Loading