class BuildkiteFormatter

Constants

KSDIFF_MATCHER
VERSION

Public Instance Methods

buildkite?() click to toggle source
# File lib/buildkite_formatter.rb, line 35
def buildkite?
  !!ENV['BUILDKITE']
end
inline_artifacts(*artifacts) click to toggle source
# File lib/buildkite_formatter.rb, line 20
def inline_artifacts(*artifacts)
  artifacts.each do |artifact|
    image_contents = Base64.encode64(File.read(artifact)).gsub("\n", '')
    image_name = Base64.encode64(File.basename(artifact)).gsub("\n", '')

    STDOUT.puts("\e]1337;File=name=#{image_name};inline=1:#{image_contents}\a")
  end
end
pretty_format(text) click to toggle source
# File lib/buildkite_formatter.rb, line 7
def pretty_format(text)
  if KSDIFF_MATCHER.match(text)
    if buildkite?
      upload_artifacts($1, $2)
      inline_artifacts($1, $2)
    else
      STDOUT.puts("\e[33mNot on Buildkite, would have uploaded: \n  #{$1}\n  #{$2}\e[0m")
    end
  end

  parser.parse(text)
end
upload_artifacts(*artifacts) click to toggle source
# File lib/buildkite_formatter.rb, line 29
def upload_artifacts(*artifacts)
  artifacts.each do |artifact|
    Kernel.system('buildkite-agent', 'artifact', 'upload', artifact)
  end
end