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: nil, 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.
Constructor Details
#initialize(type, message, file: nil, 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.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'utils/github/actions.rb', line 84 def initialize(type, , file: nil, title: nil, line: nil, end_line: nil, column: nil, end_column: nil) raise ArgumentError, "Unsupported type: #{type.inspect}" if ANNOTATION_TYPES.exclude?(type) raise ArgumentError, "`title` must not contain `::`" if title.present? && title.include?("::") require "utils/tty" @type = type @message = T.let(Tty.strip_ansi(), String) @file = T.let(self.class.path_relative_to_workspace(file), T.nilable(Pathname)) if file.present? @title = T.let(Tty.strip_ansi(title), String) if title @line = T.let(Integer(line), Integer) if line @end_line = T.let(Integer(end_line), Integer) if end_line @column = T.let(Integer(column), Integer) if column @end_column = T.let(Integer(end_column), Integer) 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.
64 65 66 67 68 69 70 |
# File 'utils/github/actions.rb', line 64 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.
128 129 130 131 132 |
# File 'utils/github/actions.rb', line 128 def relevant? return true if @file.blank? @file.descend.next.to_s != ".." end |