Merge pull request #18561 from Homebrew/duplicate-messages-github-actions
extend/kernel: fix duplicate messages in GitHub Actions
This commit is contained in:
commit
fd270c78d1
@ -64,9 +64,10 @@ module Kernel
|
|||||||
# @api public
|
# @api public
|
||||||
sig { params(message: T.any(String, Exception)).void }
|
sig { params(message: T.any(String, Exception)).void }
|
||||||
def opoo(message)
|
def opoo(message)
|
||||||
|
return if GitHub::Actions.puts_annotation_if_env_set(:warning, message.to_s)
|
||||||
|
|
||||||
Tty.with($stderr) do |stderr|
|
Tty.with($stderr) do |stderr|
|
||||||
stderr.puts Formatter.warning(message, label: "Warning")
|
stderr.puts Formatter.warning(message, label: "Warning")
|
||||||
GitHub::Actions.puts_annotation_if_env_set(:warning, message.to_s)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -75,12 +76,13 @@ module Kernel
|
|||||||
# @api public
|
# @api public
|
||||||
sig { params(message: T.any(String, Exception)).void }
|
sig { params(message: T.any(String, Exception)).void }
|
||||||
def onoe(message)
|
def onoe(message)
|
||||||
require "utils/formatter"
|
|
||||||
require "utils/github/actions"
|
require "utils/github/actions"
|
||||||
|
return if GitHub::Actions.puts_annotation_if_env_set(:error, message.to_s)
|
||||||
|
|
||||||
|
require "utils/formatter"
|
||||||
|
|
||||||
Tty.with($stderr) do |stderr|
|
Tty.with($stderr) do |stderr|
|
||||||
stderr.puts Formatter.error(message, label: "Error")
|
stderr.puts Formatter.error(message, label: "Error")
|
||||||
GitHub::Actions.puts_annotation_if_env_set(:error, message.to_s)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -178,8 +180,6 @@ module Kernel
|
|||||||
exception.set_backtrace(backtrace)
|
exception.set_backtrace(backtrace)
|
||||||
raise exception
|
raise exception
|
||||||
elsif !Homebrew.auditing?
|
elsif !Homebrew.auditing?
|
||||||
require "utils/github/actions"
|
|
||||||
GitHub::Actions.puts_annotation_if_env_set(:warning, message, file:, line:)
|
|
||||||
opoo message
|
opoo message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -43,15 +43,17 @@ module GitHub
|
|||||||
type: Symbol, message: String,
|
type: Symbol, message: String,
|
||||||
file: T.nilable(T.any(String, Pathname)),
|
file: T.nilable(T.any(String, Pathname)),
|
||||||
line: T.nilable(Integer)
|
line: T.nilable(Integer)
|
||||||
).void
|
).returns(T::Boolean)
|
||||||
}
|
}
|
||||||
def self.puts_annotation_if_env_set(type, message, file: nil, line: nil)
|
def self.puts_annotation_if_env_set(type, message, file: nil, line: nil)
|
||||||
# Don't print annotations during tests, too messy to handle these.
|
# Don't print annotations during tests, too messy to handle these.
|
||||||
return if ENV.fetch("HOMEBREW_TESTS", false)
|
return false if ENV.fetch("HOMEBREW_TESTS", false)
|
||||||
return unless env_set?
|
return false unless env_set?
|
||||||
|
|
||||||
std = (type == :notice) ? $stdout : $stderr
|
std = (type == :notice) ? $stdout : $stderr
|
||||||
std.puts Annotation.new(type, message)
|
std.puts Annotation.new(type, message)
|
||||||
|
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Helper class for formatting annotations on GitHub Actions.
|
# Helper class for formatting annotations on GitHub Actions.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user