Class: Ask::Eval::Reporters::GitHub
- Inherits:
-
Object
- Object
- Ask::Eval::Reporters::GitHub
- Defined in:
- lib/ask/eval/reporters/github.rb
Overview
GitHub Actions reporter — produces annotations that appear as PR comments and annotations in GitHub Actions.
Output format:
::warning file={path},line={line},title={title}::{message}
::error file={path},line={line},title={title}::{message}
Instance Method Summary collapse
-
#annotations ⇒ Array<Hash>
Generate GitHub Actions annotations.
-
#initialize(results, options = {}) ⇒ GitHub
constructor
A new instance of GitHub.
-
#report ⇒ void
Print annotations to stdout in GitHub Actions format.
Constructor Details
#initialize(results, options = {}) ⇒ GitHub
Returns a new instance of GitHub.
17 18 19 20 21 |
# File 'lib/ask/eval/reporters/github.rb', line 17 def initialize(results, = {}) @results = results @file = [:file] @line = [:line] || 1 end |
Instance Method Details
#annotations ⇒ Array<Hash>
Generate GitHub Actions annotations.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ask/eval/reporters/github.rb', line 25 def annotations @results.filter_map do |r| next if result_passed?(r) result = r[:result] reason = result.is_a?(Hash) ? result[:reason] : result.reason score = result.is_a?(Hash) ? result[:score] : result.score test_name = "#{r[:test] || 'eval'} #{r[:name]}" { path: @file || ".github/workflows/ci.yml", line: @line, message: "#{test_name}: #{reason} (score: #{score})", severity: score.to_f < 0.3 ? "error" : "warning" } end end |
#report ⇒ void
This method returns an undefined value.
Print annotations to stdout in GitHub Actions format.
45 46 47 48 49 50 |
# File 'lib/ask/eval/reporters/github.rb', line 45 def report annotations.each do |a| severity = a[:severity] == "error" ? "error" : "warning" puts "::#{severity} file=#{a[:path]},line=#{a[:line]},title=ask-eval::#{a[:message]}" end end |