Class: Homebrew::TestBot::Formulae Private

Inherits:
TestFormulae show all
Defined in:
test_bot/formulae.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Instance Attribute Summary collapse

Attributes inherited from TestFormulae

#artifact_cache, #skipped_or_failed_formulae

Attributes inherited from Test

#steps

Instance Method Summary collapse

Methods inherited from Test

#failed_steps, #ignored_steps

Methods included from Utils::Output::Mixin

#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled

Constructor Details

#initialize(tap:, git:, dry_run:, fail_fast:, verbose:, output_paths:) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'test_bot/formulae.rb', line 26

def initialize(tap:, git:, dry_run:, fail_fast:, verbose:, output_paths:)
  super(tap:, git:, dry_run:, fail_fast:, verbose:)

  @built_formulae = T.let([], T::Array[String])
  @bottle_checksums = T.let({}, T::Hash[Pathname, String])
  @bottle_output_path = T.let(output_paths.fetch(:bottle), Pathname)
  @linkage_output_path = T.let(output_paths.fetch(:linkage), Pathname)
  @skipped_or_failed_formulae_output_path = T.let(output_paths.fetch(:skipped_or_failed_formulae), Pathname)
  @testing_formulae = T.let([], T::Array[String])
  @added_formulae = T.let([], T::Array[String])
  @deleted_formulae = T.let([], T::Array[String])
  @testing_formulae_count = T.let(0, Integer)
  @tested_formulae_count = T.let(0, Integer)
  @unchanged_dependencies = T.let([], T::Array[String])
  @unchanged_build_dependencies = T.let([], T::Array[String])
  @bottle_filename = T.let(nil, T.nilable(Pathname))
  @bottle_json_filename = T.let(nil, T.nilable(Pathname))
end

Instance Attribute Details

#added_formulae=(value) ⇒ void (writeonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



11
12
13
# File 'test_bot/formulae.rb', line 11

def added_formulae=(value)
  @added_formulae = value
end

#deleted_formulae=(value) ⇒ void (writeonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



14
15
16
# File 'test_bot/formulae.rb', line 14

def deleted_formulae=(value)
  @deleted_formulae = value
end

#testing_formulae=(value) ⇒ void (writeonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



8
9
10
# File 'test_bot/formulae.rb', line 8

def testing_formulae=(value)
  @testing_formulae = value
end

Instance Method Details

#run!(args:) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'test_bot/formulae.rb', line 46

def run!(args:)
  test_header(:Formulae)

  verify_local_bottles

  with_env(HOMEBREW_DISABLE_LOAD_FORMULA: "1") do
    # Portable Ruby bottles are handled differently.
    next if testing_portable_ruby?

    # TODO: move to extend/os
    # rubocop:todo Homebrew/MoveToExtendOS
    bottle_specifier = if OS.linux?
      "{linux,ubuntu}"
    else
      "{macos-#{MacOS.version},#{MacOS.version}-#{Hardware::CPU.arch}}"
    end
    # rubocop:enable Homebrew/MoveToExtendOS
    download_artifacts_from_previous_run!("bottles{,_#{bottle_specifier}*}", dry_run: args.dry_run?)
  end
  @bottle_checksums.merge!(
    bottle_glob("*", artifact_cache, ".{json,tar.gz}", bottle_tag: "*").to_h do |bottle_file|
      [bottle_file.realpath, bottle_file.sha256]
    end,
  )

  # #run! modifies `@testing_formulae`, so we need to track this separately.
  @testing_formulae_count = @testing_formulae.count
  perform_bash_cleanup = @testing_formulae.include?("bash")
  @tested_formulae_count = 0

  sorted_formulae.each do |f|
    verify_local_bottles
    if testing_portable_ruby?
      portable_formula!(f)
    else
      formula!(f, args:)
    end
    puts
    next if @testing_formulae_count < 3

    progress_text = +"Test progress: "
    progress_text += "#{@tested_formulae_count} formula(e) tested, "
    progress_text += "#{@testing_formulae_count - @tested_formulae_count} remaining"
    info_header progress_text
  end

  @deleted_formulae.each do |f|
    deleted_formula!(f)
    verify_local_bottles
    puts
  end

  return unless GitHub::Actions.env_set?

  # Remove `bash` after it is tested, since leaving a broken `bash`
  # installation in the environment can cause issues with subsequent
  # GitHub Actions steps.
  test "brew", "uninstall", "--formula", "--force", "bash" if perform_bash_cleanup

  File.open(ENV.fetch("GITHUB_OUTPUT"), "a") do |f|
    f.puts "skipped_or_failed_formulae=#{@skipped_or_failed_formulae.join(",")}"
  end

  @skipped_or_failed_formulae_output_path.write(@skipped_or_failed_formulae.join(","))
ensure
  verify_local_bottles
  FileUtils.rm_rf artifact_cache
end