Class: GitHub::Actions::Annotation Private
Overview
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.
Helper class for formatting annotations on GitHub Actions.
Constant Summary collapse
- ANNOTATION_TYPES =
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.
[:notice, :warning, :error].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, message, file:, title: nil, line: nil, end_line: nil, column: nil, end_column: nil) ⇒ void
constructor
private
-
#relevant? ⇒ Boolean
private
An annotation is only relevant if the corresponding
file
is relative to theGITHUB_WORKSPACE
directory or if nofile
is specified. -
#to_s ⇒ String
private
Constructor Details
#initialize(type, message, file:, title: nil, line: nil, end_line: nil, column: nil, end_column: nil) ⇒ 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.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'utils/github/actions.rb', line 63 def initialize(type, , file:, title: nil, line: nil, end_line: nil, column: nil, end_column: nil) raise ArgumentError, "Unsupported type: #{type.inspect}" if ANNOTATION_TYPES.exclude?(type) @type = type @message = Tty.strip_ansi() @file = self.class.path_relative_to_workspace(file) @title = Tty.strip_ansi(title) if title @line = Integer(line) if line @end_line = Integer(end_line) if end_line @column = Integer(column) if column @end_column = Integer(end_column) if end_column end |
Class Method Details
.path_relative_to_workspace(path) ⇒ Pathname?
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.
43 44 45 46 47 48 49 |
# File 'utils/github/actions.rb', line 43 def self.path_relative_to_workspace(path) workspace = Pathname(ENV.fetch("GITHUB_WORKSPACE", Dir.pwd)).realpath path = Pathname(path) return path unless path.exist? path.realpath.relative_path_from(workspace) end |
Instance Method Details
#relevant? ⇒ 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.
An annotation is only relevant if the corresponding file
is relative to
the GITHUB_WORKSPACE
directory or if no file
is specified.
99 100 101 |
# File 'utils/github/actions.rb', line 99 def relevant? @file.descend.next.to_s != ".." end |
#to_s ⇒ 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.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'utils/github/actions.rb', line 77 def to_s = @type.to_s << " file=#{Actions.escape(@file.to_s)}" if @line << ",line=#{@line}" << ",endLine=#{@end_line}" if @end_line if @column << ",col=#{@column}" << ",endColumn=#{@end_column}" if @end_column end end << ",title=#{Actions.escape(@title)}" if @title "::#{}::#{Actions.escape(@message)}" end |