diff --git a/lib/step.rb b/lib/step.rb index 4d93370a..3a7323ca 100644 --- a/lib/step.rb +++ b/lib/step.rb @@ -88,7 +88,7 @@ def puts_github_actions_annotation(message, title, file, line) :error end - annotation = GitHub::Actions::Annotation.new(type, message, title: title, file: file, line: line) + annotation = GitHub::Actions::Annotation.new(type, message, title:, file:, line:) puts annotation end @@ -151,7 +151,7 @@ def run(dry_run: false, fail_fast: false) executable, *args = command - result = system_command executable, args: args, + result = system_command executable, args:, print_stdout: @verbose, print_stderr: @verbose, env: @env diff --git a/lib/test.rb b/lib/test.rb index afc697e7..60dfdf1f 100644 --- a/lib/test.rb +++ b/lib/test.rb @@ -44,10 +44,10 @@ def info_header(text) def test(*arguments, named_args: nil, env: {}, verbose: @verbose, ignore_failures: false) step = Step.new( arguments, - named_args: named_args, - env: env, - verbose: verbose, - ignore_failures: ignore_failures, + named_args:, + env:, + verbose:, + ignore_failures:, repository: @repository, ) step.run(dry_run: @dry_run, fail_fast: @fail_fast) diff --git a/lib/test_bot.rb b/lib/test_bot.rb index a5f91ca5..b1ea131a 100644 --- a/lib/test_bot.rb +++ b/lib/test_bot.rb @@ -134,7 +134,7 @@ def run!(args) ENV["HOMEBREW_GIT_EMAIL"] = args.git_email || "1589480+BrewTestBot@users.noreply.github.com" - Homebrew.failed = !TestRunner.run!(tap, git: GIT, args: args) + Homebrew.failed = !TestRunner.run!(tap, git: GIT, args:) end end end diff --git a/lib/test_formulae.rb b/lib/test_formulae.rb index b2a9371b..b0f9b8fa 100644 --- a/lib/test_formulae.rb +++ b/lib/test_formulae.rb @@ -123,12 +123,12 @@ def download_artifact_from_previous_run!(artifact_name, dry_run:) return if pr_labels.include?("CI-no-bottle-cache") || pr_labels.include?("workflows") variables = { - owner: owner, - repo: repo, + owner:, + repo:, commit: sha, } - response = GitHub::API.open_graphql(GRAPHQL_QUERY, variables: variables) + response = GitHub::API.open_graphql(GRAPHQL_QUERY, variables:) check_suite_nodes = response.dig("repository", "object", "checkSuites", "nodes") return if check_suite_nodes.blank? @@ -163,7 +163,7 @@ def download_artifact_from_previous_run!(artifact_name, dry_run:) # If we made it here, then we downloaded an `event_payload` artifact. # We can now use this `event_payload` artifact to attempt to download the artifact we wanted. - download_artifact_from_previous_run!(artifact_name, dry_run: dry_run) + download_artifact_from_previous_run!(artifact_name, dry_run:) rescue GitHub::API::AuthenticationFailedError => e opoo e end @@ -224,7 +224,7 @@ def install_formula_from_bottle(formula_name, testing_formulae_dependents:, dry_ install_step = steps.last if !dry_run && !testing_formulae_dependents && install_step.passed? - bottle_hash = local_bottle_hash(formula_name, bottle_dir: bottle_dir) + bottle_hash = local_bottle_hash(formula_name, bottle_dir:) bottle_revision = bottle_hash.dig(formula_name, "formula", "tap_git_revision") bottle_header = "Installed previously built bottle for #{formula_name} from:" bottle_message = if @fetched_refs&.include?(bottle_revision) @@ -258,14 +258,14 @@ def bottled?(formula, no_older_versions: false) # up the dep tree when we encounter an `:all` bottle because # a formula is not bottled unless its dependencies are. if formula.bottle_specification.tag?(Utils::Bottles.tag(:all)) - formula.deps.all? { |dep| bottled?(dep.to_formula, no_older_versions: no_older_versions) } + formula.deps.all? { |dep| bottled?(dep.to_formula, no_older_versions:) } else - formula.bottle_specification.tag?(Utils::Bottles.tag, no_older_versions: no_older_versions) + formula.bottle_specification.tag?(Utils::Bottles.tag, no_older_versions:) end end def bottled_or_built?(formula, built_formulae, no_older_versions: false) - bottled?(formula, no_older_versions: no_older_versions) || built_formulae.include?(formula.full_name) + bottled?(formula, no_older_versions:) || built_formulae.include?(formula.full_name) end def downloads_using_homebrew_curl?(formula) diff --git a/lib/test_runner.rb b/lib/test_runner.rb index aaabe7f0..706d10c1 100644 --- a/lib/test_runner.rb +++ b/lib/test_runner.rb @@ -53,17 +53,17 @@ def run!(tap, git:, args:) test_bot_args.each do |argument| skip_cleanup_after = argument != test_bot_args.last - current_tests = build_tests(argument, tap: tap, - git: git, - output_paths: output_paths, - skip_setup: skip_setup, - skip_cleanup_before: skip_cleanup_before, - skip_cleanup_after: skip_cleanup_after, - args: args) + current_tests = build_tests(argument, tap:, + git:, + output_paths:, + skip_setup:, + skip_cleanup_before:, + skip_cleanup_after:, + args:) skip_setup = true skip_cleanup_before = true tests += current_tests.values - run_tests(current_tests, args: args) + run_tests(current_tests, args:) end failed_steps = tests.map(&:failed_steps) @@ -140,25 +140,25 @@ def build_tests(argument, tap:, git:, output_paths:, skip_setup:, args.added_formulae.nil? && args.deleted_formulae.nil? if no_formulae_flags && (no_only_args || args.only_formulae? || args.only_formulae_detect?) - tests[:formulae_detect] = Tests::FormulaeDetect.new(argument, tap: tap, - git: git, + tests[:formulae_detect] = Tests::FormulaeDetect.new(argument, tap:, + git:, dry_run: args.dry_run?, fail_fast: args.fail_fast?, verbose: args.verbose?) end if no_only_args || args.only_formulae? - tests[:formulae] = Tests::Formulae.new(tap: tap, - git: git, + tests[:formulae] = Tests::Formulae.new(tap:, + git:, dry_run: args.dry_run?, fail_fast: args.fail_fast?, verbose: args.verbose?, - output_paths: output_paths) + output_paths:) end if !args.skip_dependents? && (no_only_args || args.only_formulae? || args.only_formulae_dependents?) - tests[:formulae_dependents] = Tests::FormulaeDependents.new(tap: tap, - git: git, + tests[:formulae_dependents] = Tests::FormulaeDependents.new(tap:, + git:, dry_run: args.dry_run?, fail_fast: args.fail_fast?, verbose: args.verbose?) @@ -166,16 +166,16 @@ def build_tests(argument, tap:, git:, output_paths:, skip_setup:, if args.cleanup? if !skip_cleanup_before && (no_only_args || args.only_cleanup_before?) - tests[:cleanup_before] = Tests::CleanupBefore.new(tap: tap, - git: git, + tests[:cleanup_before] = Tests::CleanupBefore.new(tap:, + git:, dry_run: args.dry_run?, fail_fast: args.fail_fast?, verbose: args.verbose?) end if !skip_cleanup_after && (no_only_args || args.only_cleanup_after?) - tests[:cleanup_after] = Tests::CleanupAfter.new(tap: tap, - git: git, + tests[:cleanup_after] = Tests::CleanupAfter.new(tap:, + git:, dry_run: args.dry_run?, fail_fast: args.fail_fast?, verbose: args.verbose?) @@ -183,8 +183,8 @@ def build_tests(argument, tap:, git:, output_paths:, skip_setup:, end if args.only_bottles_fetch? - tests[:bottles_fetch] = Tests::BottlesFetch.new(tap: tap, - git: git, + tests[:bottles_fetch] = Tests::BottlesFetch.new(tap:, + git:, dry_run: args.dry_run?, fail_fast: args.fail_fast?, verbose: args.verbose?) @@ -194,13 +194,13 @@ def build_tests(argument, tap:, git:, output_paths:, skip_setup:, end def run_tests(tests, args:) - tests[:cleanup_before]&.run!(args: args) + tests[:cleanup_before]&.run!(args:) begin - tests[:setup]&.run!(args: args) - tests[:tap_syntax]&.run!(args: args) + tests[:setup]&.run!(args:) + tests[:tap_syntax]&.run!(args:) testing_formulae, added_formulae, deleted_formulae = if (detect_test = tests[:formulae_detect]) - detect_test.run!(args: args) + detect_test.run!(args:) [ detect_test.testing_formulae, @@ -220,7 +220,7 @@ def run_tests(tests, args:) formulae_test.added_formulae = added_formulae formulae_test.deleted_formulae = deleted_formulae - formulae_test.run!(args: args) + formulae_test.run!(args:) formulae_test.skipped_or_failed_formulae elsif args.skipped_or_failed_formulae.present? @@ -235,16 +235,16 @@ def run_tests(tests, args:) dependents_test.testing_formulae = testing_formulae dependents_test.skipped_or_failed_formulae = skipped_or_failed_formulae - dependents_test.run!(args: args) + dependents_test.run!(args:) end if (fetch_test = tests[:bottles_fetch]) fetch_test.testing_formulae = testing_formulae - fetch_test.run!(args: args) + fetch_test.run!(args:) end ensure - tests[:cleanup_after]&.run!(args: args) + tests[:cleanup_after]&.run!(args:) end end end diff --git a/lib/tests/bottles_fetch.rb b/lib/tests/bottles_fetch.rb index 1c00c597..d711ff21 100644 --- a/lib/tests/bottles_fetch.rb +++ b/lib/tests/bottles_fetch.rb @@ -11,7 +11,7 @@ def run!(args:) puts testing_formulae.each do |formula_name| - fetch_bottles!(formula_name, args: args) + fetch_bottles!(formula_name, args:) puts end end @@ -25,7 +25,7 @@ def fetch_bottles!(formula_name, args:) tags = formula.bottle_specification.collector.tags tags.each do |tag| - cleanup_during!(args: args) + cleanup_during!(args:) test "brew", "fetch", "--retry", "--formulae", "--bottle-tag=#{tag}", formula_name end end diff --git a/lib/tests/formulae.rb b/lib/tests/formulae.rb index b1f1c66f..2a5c9826 100644 --- a/lib/tests/formulae.rb +++ b/lib/tests/formulae.rb @@ -6,7 +6,7 @@ class Formulae < TestFormulae attr_writer :testing_formulae, :added_formulae, :deleted_formulae def initialize(tap:, git:, dry_run:, fail_fast:, verbose:, output_paths:) - super(tap: tap, git: git, dry_run: dry_run, fail_fast: fail_fast, verbose: verbose) + super(tap:, git:, dry_run:, fail_fast:, verbose:) @built_formulae = [] @bottle_checksums = {} @@ -33,7 +33,7 @@ def run!(args:) @testing_formulae_count = @testing_formulae.count sorted_formulae.each do |f| - formula!(f, args: args) + formula!(f, args:) verify_local_bottles puts end @@ -156,12 +156,12 @@ def setup_formulae_deps_instances(formula, formula_name, args:) # checksum problems. We have to install all `changed_dependencies` # in one `brew install` command to make sure they are installed in # the right order. - test "brew", "install", "--build-from-source", + test("brew", "install", "--build-from-source", named_args: changed_dependencies, - ignore_failures: ignore_failures + ignore_failures:) # Run postinstall on them because the tested formula might depend on # this step - test "brew", "postinstall", named_args: changed_dependencies, ignore_failures: ignore_failures + test "brew", "postinstall", named_args: changed_dependencies, ignore_failures: end runtime_or_test_dependencies = @@ -228,7 +228,7 @@ def verify_local_bottles end def bottle_reinstall_formula(formula, new_formula, args:) - unless build_bottle?(formula, args: args) + unless build_bottle?(formula, args:) @bottle_filename = nil return end @@ -366,7 +366,7 @@ def livecheck(formula) end def formula!(formula_name, args:) - cleanup_during!(@testing_formulae, args: args) + cleanup_during!(@testing_formulae, args:) test_header(:Formulae, method: "formula!(#{formula_name})") @@ -399,7 +399,7 @@ def formula!(formula_name, args:) deps = [] reqs = [] - build_flag = if build_bottle?(formula, args: args) + build_flag = if build_bottle?(formula, args:) "--build-bottle" else if ENV["GITHUB_ACTIONS"].present? @@ -465,7 +465,7 @@ def formula!(formula_name, args:) install_curl_if_needed(formula) install_mercurial_if_needed(deps, reqs) install_subversion_if_needed(deps, reqs) - setup_formulae_deps_instances(formula, formula_name, args: args) + setup_formulae_deps_instances(formula, formula_name, args:) test "brew", "uninstall", "--force", formula_name if formula.latest_version_installed? @@ -499,10 +499,10 @@ def formula!(formula_name, args:) dry_run: args.dry_run?) install_step_passed ||= begin - test "brew", "install", *install_args, + test("brew", "install", *install_args, named_args: formula_name, env: env.merge({ "HOMEBREW_DEVELOPER" => nil }), - ignore_failures: ignore_failures + ignore_failures:) steps.last.passed? end @@ -530,10 +530,10 @@ def formula!(formula_name, args:) @bottle_checksums.delete(old_location) end else - bottle_reinstall_formula(formula, new_formula, args: args) + bottle_reinstall_formula(formula, new_formula, args:) end @built_formulae << formula.full_name - test "brew", "linkage", "--test", named_args: formula_name, ignore_failures: ignore_failures + test("brew", "linkage", "--test", named_args: formula_name, ignore_failures:) failed_linkage_or_test_messages ||= [] failed_linkage_or_test_messages << "linkage failed" unless steps.last.passed? @@ -560,7 +560,7 @@ def formula!(formula_name, args:) # Intentionally not passing --retry here to avoid papering over # flaky tests when a formula isn't being pulled in as a dependent. - test "brew", "test", "--verbose", named_args: formula_name, env: env, ignore_failures: ignore_failures + test("brew", "test", "--verbose", named_args: formula_name, env:, ignore_failures:) failed_linkage_or_test_messages << "test failed" unless steps.last.passed? end diff --git a/lib/tests/formulae_dependents.rb b/lib/tests/formulae_dependents.rb index 43160462..92a8cafd 100644 --- a/lib/tests/formulae_dependents.rb +++ b/lib/tests/formulae_dependents.rb @@ -14,7 +14,7 @@ def run!(args:) @dependent_testing_formulae = sorted_formulae - skipped_or_failed_formulae - install_formulae_if_needed_from_bottles!(args: args) + install_formulae_if_needed_from_bottles!(args:) download_artifact_from_previous_run!("dependents", dry_run: args.dry_run?) @skip_candidates = if (tested_dependents_cache = artifact_cache/@tested_dependents_list).exist? @@ -24,7 +24,7 @@ def run!(args:) end @dependent_testing_formulae.each do |formula_name| - dependent_formulae!(formula_name, args: args) + dependent_formulae!(formula_name, args:) puts end end @@ -41,7 +41,7 @@ def install_formulae_if_needed_from_bottles!(args:) end def dependent_formulae!(formula_name, args:) - cleanup_during!(@dependent_testing_formulae, args: args) + cleanup_during!(@dependent_testing_formulae, args:) test_header(:FormulaeDependents, method: "dependent_formulae!(#{formula_name})") @tested_formulae << formula_name @@ -67,15 +67,15 @@ def dependent_formulae!(formula_name, args:) return if steps.last.failed? source_dependents, bottled_dependents, testable_dependents = - dependents_for_formula(formula, formula_name, args: args) + dependents_for_formula(formula, formula_name, args:) source_dependents.each do |dependent| - install_dependent(dependent, testable_dependents, build_from_source: true, args: args) - install_dependent(dependent, testable_dependents, args: args) if bottled?(dependent) + install_dependent(dependent, testable_dependents, build_from_source: true, args:) + install_dependent(dependent, testable_dependents, args:) if bottled?(dependent) end bottled_dependents.each do |dependent| - install_dependent(dependent, testable_dependents, args: args) + install_dependent(dependent, testable_dependents, args:) end end @@ -188,7 +188,7 @@ def install_dependent(dependent, testable_dependents, args:, build_from_source: return end - cleanup_during!(@dependent_testing_formulae, args: args) + cleanup_during!(@dependent_testing_formulae, args:) required_dependent_deps = dependent.deps.reject(&:optional?) bottled_on_current_version = bottled?(dependent, no_older_versions: true) @@ -278,7 +278,7 @@ def install_dependent(dependent, testable_dependents, args:, build_from_source: end test "brew", "test", "--retry", "--verbose", named_args: dependent.full_name, - env: env, + env:, ignore_failures: !args.test_default_formula? && !bottled_on_current_version test_step = steps.last end diff --git a/lib/tests/formulae_detect.rb b/lib/tests/formulae_detect.rb index fa42bc63..40c993dc 100644 --- a/lib/tests/formulae_detect.rb +++ b/lib/tests/formulae_detect.rb @@ -6,7 +6,7 @@ class FormulaeDetect < Test attr_reader :testing_formulae, :added_formulae, :deleted_formulae def initialize(argument, tap:, git:, dry_run:, fail_fast:, verbose:) - super(tap: tap, git: git, dry_run: dry_run, fail_fast: fail_fast, verbose: verbose) + super(tap:, git:, dry_run:, fail_fast:, verbose:) @argument = argument @added_formulae = [] @@ -15,7 +15,7 @@ def initialize(argument, tap:, git:, dry_run:, fail_fast:, verbose:) end def run!(args:) - detect_formulae!(args: args) + detect_formulae!(args:) return unless ENV["GITHUB_ACTIONS"] @@ -45,7 +45,7 @@ def detect_formulae!(args:) %r{refs/pull/(?\d+)/merge} =~ github_ref url = "https://github.com/#{github_repository}/pull/#{pr}/checks" end - elsif (canonical_formula_name = safe_formula_canonical_name(@argument, args: args)) + elsif (canonical_formula_name = safe_formula_canonical_name(@argument, args:)) unless canonical_formula_name.include?("/") ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1" CoreTap.ensure_installed! diff --git a/spec/homebrew/step_spec.rb b/spec/homebrew/step_spec.rb index 3c2597fd..28b4a340 100644 --- a/spec/homebrew/step_spec.rb +++ b/spec/homebrew/step_spec.rb @@ -6,12 +6,12 @@ let(:command) { ["brew", "config"] } let(:env) { {} } let(:verbose) { false } - let(:step) { described_class.new(command, env: env, verbose: verbose) } + let(:step) { described_class.new(command, env:, verbose:) } describe "#run" do it "runs the command" do expect(step).to receive(:system_command) - .with("brew", args: ["config"], env: env, print_stderr: verbose, print_stdout: verbose) + .with("brew", args: ["config"], env:, print_stderr: verbose, print_stdout: verbose) .and_return(OpenStruct.new(success?: true, merged_output: "")) step.run end