Class: RSpec::Buildkite::AnnotationFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/buildkite/annotation_formatter.rb

Overview

Create a Buildkite annotation for RSpec failures

Help folks fix their builds as soon as possible when failures crop up by calling out failures in an annotation, even while the build is still running.

Uses a background Thread so we don’t block the build.

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ AnnotationFormatter



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rspec/buildkite/annotation_formatter.rb', line 17

def initialize(output)
  # We don't actually use this, but keep a reference anyway
  @output = output

  # Only setup if we're actually running on Buildkite
  if ENV["BUILDKITE"]
    @queue = Queue.new
    @thread = Thread.new(&method(:thread))
    at_exit { @queue.push(:close); @thread.join }
  end
end

Instance Method Details

#example_failed(notification) ⇒ Object



29
30
31
# File 'lib/rspec/buildkite/annotation_formatter.rb', line 29

def example_failed(notification)
  @queue.push(notification) if @queue
end