Module: Homebrew::TestBot Private
- Extended by:
- Utils::Output::Mixin
- Includes:
- Kernel
- Defined in:
- test_bot.rb,
test_bot/step.rb,
test_bot/test.rb,
test_bot/junit.rb,
test_bot/setup.rb,
test_bot/formulae.rb,
test_bot/tap_syntax.rb,
test_bot/test_runner.rb,
test_bot/test_cleanup.rb,
test_bot/bottles_fetch.rb,
test_bot/cleanup_after.rb,
test_bot/test_formulae.rb,
test_bot/cleanup_before.rb,
test_bot/formulae_detect.rb,
test_bot/formulae_dependents.rb,
test_bot.rbi
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Defined Under Namespace
Modules: TestRunner Classes: BottlesFetch, CleanupAfter, CleanupBefore, Formulae, FormulaeDependents, FormulaeDetect, Junit, Setup, Step, TapSyntax, Test, TestCleanup, TestFormulae
Constant Summary collapse
- GIT =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
"/usr/bin/git"- HOMEBREW_TAP_REGEX =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
%r{^([\w-]+)/homebrew-([\w-]+)$}
Constants included from Kernel
Kernel::IGNORE_INTERRUPTS_MUTEX
Class Method Summary collapse
- .cleanup?(args) ⇒ Boolean private
- .configure_sandbox! ⇒ Boolean private
- .local?(args) ⇒ Boolean private
- .resolve_test_tap(tap = nil) ⇒ Tap? private
- .run!(args) ⇒ void private
- .runner_os_title ⇒ String private
- .runner_os_title_with_arch ⇒ String private
- .setup_github_actions_sandbox! ⇒ void private
Methods included from Utils::Output::Mixin
issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_deprecated, pretty_disabled, pretty_duration, pretty_install_status, pretty_installed, pretty_outdated, pretty_uninstalled, pretty_upgradable
Methods included from Kernel
#ensure_executable!, #exec_browser, #exec_editor, #ignore_interrupts, #interactive_shell, #quiet_system, #redirect_stdout, #safe_system, #which, #which_editor, #with_env, #with_homebrew_path
Class Method Details
.cleanup?(args) ⇒ Boolean
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.
33 34 35 |
# File 'test_bot.rb', line 33 def cleanup?(args) args.cleanup? || GitHub::Actions.env_set? end |
.configure_sandbox! ⇒ Boolean
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.
59 |
# File 'test_bot.rb', line 59 def configure_sandbox! = true |
.local?(args) ⇒ Boolean
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.
38 39 40 |
# File 'test_bot.rb', line 38 def local?(args) args.local? || GitHub::Actions.env_set? end |
.resolve_test_tap(tap = nil) ⇒ Tap?
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.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'test_bot.rb', line 62 def resolve_test_tap(tap = nil) return Tap.fetch(tap) if tap # Get tap from GitHub Actions GITHUB_REPOSITORY git_url = ENV.fetch("GITHUB_REPOSITORY", nil) return if git_url.blank? url_path = git_url.sub(%r{^https?://github\.com/}, "") .chomp("/") .sub(/\.git$/, "") return CoreTap.instance if url_path == CoreTap.instance.full_name begin Tap.fetch(url_path) if url_path.match?(HOMEBREW_TAP_REGEX) rescue # Don't care if tap fetch fails nil end end |
.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.
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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'test_bot.rb', line 84 def run!(args) $stdout.sync = true $stderr.sync = true if Pathname.pwd == HOMEBREW_PREFIX && cleanup?(args) raise UsageError, "cannot use --cleanup from HOMEBREW_PREFIX as it will delete all output." end ENV["HOMEBREW_DEVELOPER"] = "1" ENV["HOMEBREW_NO_AUTO_UPDATE"] = "1" ENV["HOMEBREW_NO_EMOJI"] = "1" ENV["HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK"] = "1" ENV["HOMEBREW_FAIL_LOG_LINES"] = "150" ENV["HOMEBREW_CURL"] = ENV["HOMEBREW_CURL_PATH"] = "/usr/bin/curl" ENV["HOMEBREW_GIT"] = ENV["HOMEBREW_GIT_PATH"] = GIT ENV["HOMEBREW_DISALLOW_LIBNSL1"] = "1" ENV["HOMEBREW_NO_ENV_HINTS"] = "1" ENV["HOMEBREW_SBOM"] = "1" ENV["HOMEBREW_PATH"] = ENV["PATH"] = "#{HOMEBREW_PREFIX}/bin:#{HOMEBREW_PREFIX}/sbin:#{ENV.fetch("PATH")}" if local?(args) home = "#{Dir.pwd}/home" logs = "#{Dir.pwd}/logs" gitconfig = "#{Dir.home}/.gitconfig" ENV["HOMEBREW_HOME"] = ENV["HOME"] = home ENV["HOMEBREW_LOGS"] = logs FileUtils.mkdir_p home FileUtils.mkdir_p logs FileUtils.cp gitconfig, home if File.exist?(gitconfig) end setup_github_actions_sandbox! tap = resolve_test_tap(args.tap) if tap&.core_tap? ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1" ENV["HOMEBREW_VERIFY_ATTESTATIONS"] = "1" if args.only_formulae? end # Tap repository if required, this is done before everything else # because Formula parsing and/or git commit hash lookup depends on it. # At the same time, make sure Tap is not a shallow clone. # bottle rebuild and bottle upload rely on full clone. if tap if !tap.path.exist? safe_system "brew", "tap", tap.name elsif (tap.path/".git/shallow").exist? raise unless quiet_system GIT, "-C", tap.path, "fetch", "--unshallow" end unless tap.official? action = Homebrew::Trust.trust!(:tap, tap.name) ? "Trusted" : "Already trusted" Homebrew::TestBot.ohai "#{action} tap: #{tap.name}" end end brew_version = Utils.safe_popen_read( GIT, "-C", HOMEBREW_REPOSITORY.to_s, "describe", "--tags", "--abbrev", "--dirty" ).strip brew_commit_subject = Utils.safe_popen_read( GIT, "-C", HOMEBREW_REPOSITORY.to_s, "log", "-1", "--format=%s" ).strip puts Formatter.headline("Using Homebrew/brew #{brew_version} (#{brew_commit_subject})", color: :cyan) if tap.to_s != CoreTap.instance.name && CoreTap.instance.installed? core_revision = Utils.safe_popen_read( GIT, "-C", CoreTap.instance.path.to_s, "log", "-1", "--format=%h (%s)" ).strip puts Formatter.headline("Using #{CoreTap.instance.full_name} #{core_revision}", color: :cyan) end if tap tap_github = " (#{ENV["GITHUB_REPOSITORY"]})" if tap.full_name != ENV["GITHUB_REPOSITORY"] tap_revision = Utils.safe_popen_read( GIT, "-C", tap.path.to_s, "log", "-1", "--format=%h (%s)" ).strip puts Formatter.headline("Testing #{tap.full_name}#{tap_github} #{tap_revision}:", color: :cyan) end ENV["HOMEBREW_GIT_NAME"] = args.git_name || "BrewTestBot" ENV["HOMEBREW_GIT_EMAIL"] = args.git_email || "1589480+BrewTestBot@users.noreply.github.com" Homebrew.failed = !TestRunner.run!(tap, git: GIT, args:) end |
.runner_os_title ⇒ String
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.
10 11 12 |
# File 'test_bot/step.rb', line 10 def self.runner_os_title raise NotImplementedError, "Homebrew::TestBot.runner_os_title must be implemented in extend/os." end |
.runner_os_title_with_arch ⇒ String
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.
15 16 17 |
# File 'test_bot/step.rb', line 15 def self.runner_os_title_with_arch runner_os_title end |
.setup_github_actions_sandbox! ⇒ 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.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'test_bot.rb', line 43 def setup_github_actions_sandbox! return unless GitHub::Actions.env_set? # TODO: odeprecated: force Linux sandbox support on when using `test-bot`. ENV["HOMEBREW_SANDBOX_LINUX"] = "1" if ENV["HOMEBREW_DEVELOPER"].present? && ENV["HOMEBREW_SANDBOX_LINUX"].blank? return unless Homebrew::EnvConfig.sandbox_linux? return if configure_sandbox! ENV["HOMEBREW_NO_SANDBOX_LINUX"] = "1" require "sandbox" Sandbox.reset_state! end |