diff --git a/cmd/test-bot.rb b/cmd/test-bot.rb index 9596897b..5234a1ef 100755 --- a/cmd/test-bot.rb +++ b/cmd/test-bot.rb @@ -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", @@ -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." diff --git a/lib/tests/formulae_dependents.rb b/lib/tests/formulae_dependents.rb index 91da8e0b..cb0c083b 100644 --- a/lib/tests/formulae_dependents.rb +++ b/lib/tests/formulae_dependents.rb @@ -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) @@ -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) } + 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] @@ -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 @@ -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(",")}" + end end def install_dependent(dependent, testable_dependents, args:, build_from_source: false)