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
fileis relative to theGITHUB_WORKSPACEdirectory or if nofileis 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.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'utils/github/actions.rb', line 69 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.
49 50 51 52 53 54 55 |
# File 'utils/github/actions.rb', line 49 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.
113 114 115 116 117 |
# File 'utils/github/actions.rb', line 113 def relevant? return true unless @file @file.descend.next.to_s != ".." end |