rspec-buildkite 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa56a03a46bef42009cd2ecd773ce3d7093767832586421a43fef470bd79ffb1
4
- data.tar.gz: d14a660da966c5bdd0142398c94620a7a1ac65db893c3ab851c9807914841304
3
+ metadata.gz: c1ae58f6a8295488ba436c3fbcf75fd6394b4a131f907fc6d98ba40af42cdc5b
4
+ data.tar.gz: 5426da063d471f51897dea21f8a58d6561da3e9bcea549e30b5f72abfe7886b6
5
5
  SHA512:
6
- metadata.gz: bc072e5216cd80d3b67681261e663f7b2f1ebbb33d6eab5d830db678a268fccf3e904773d9893b4553bcfec7135cbf11aa0dbecee82035c05d1608487cc6f6a4
7
- data.tar.gz: 16d8112cb59fd30917579c00f2896e76294127a57fdbf9ae375f5ef7fd6e1ca591e338a35861bce3605364183426ebe03370f8ec8f3cd1704c7c0da43a5fb780
6
+ metadata.gz: d5dde4aba7b9eab1521dfc2e1b0c481457f559f86a8452dfc049f8d2ec811f14273ec67c26ce62cb1422d21ab667be26bedc80a7b77b647ca89553ea65a3fe23
7
+ data.tar.gz: 4d5d5c9fdde9a0129c4a40e83a2e69db0c4d76e33f2bd6a118b1667ab337342329945185a9820aa7693ccba2eea6fbb9be229db565f9bf8961ed105b4a61c72f
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,108 +2,110 @@ require "thread"
2
2
 
3
3
  require "rspec/core"
4
4
 
5
- # Create a Buildkite annotation for RSpec failures
6
- #
7
- # Help folks fix their builds as soon as possible when failures crop up by
8
- # calling out failures in an annotation, even while the build is still running.
9
- #
10
- # Uses a background Thread so we don't block the build.
11
- #
12
- class RSpec::Buildkite::AnnotationFormatter
13
- RSpec::Core::Formatters.register self, :example_failed
5
+ module RSpec::Buildkite
6
+ # Create a Buildkite annotation for RSpec failures
7
+ #
8
+ # Help folks fix their builds as soon as possible when failures crop up by
9
+ # calling out failures in an annotation, even while the build is still running.
10
+ #
11
+ # Uses a background Thread so we don't block the build.
12
+ #
13
+ class AnnotationFormatter
14
+ RSpec::Core::Formatters.register self, :example_failed
14
15
 
15
- def initialize(output)
16
- # We don't actually use this, but keep a reference anyway
17
- @output = output
16
+ def initialize(output)
17
+ # We don't actually use this, but keep a reference anyway
18
+ @output = output
18
19
 
19
- # Only setup if we're actually running on Buildkite
20
- if ENV["BUILDKITE"]
21
- @queue = Queue.new
22
- @thread = Thread.new(&method(:thread))
23
- at_exit { @queue.push(:close); @thread.join }
20
+ # Only setup if we're actually running on Buildkite
21
+ if ENV["BUILDKITE"]
22
+ @queue = Queue.new
23
+ @thread = Thread.new(&method(:thread))
24
+ at_exit { @queue.push(:close); @thread.join }
25
+ end
24
26
  end
25
- end
26
27
 
27
- def example_failed(notification)
28
- @queue.push(notification) if @queue
29
- end
28
+ def example_failed(notification)
29
+ @queue.push(notification) if @queue
30
+ end
30
31
 
31
- private
32
+ private
32
33
 
33
- def thread
34
- while notification = @queue.pop
35
- break if notification == :close
34
+ def thread
35
+ while notification = @queue.pop
36
+ break if notification == :close
36
37
 
37
- if notification
38
- system "buildkite-agent", "annotate",
39
- "--context", "rspec",
40
- "--style", "error",
41
- "--append",
42
- format_failure(notification),
43
- out: :close # only display errors
38
+ if notification
39
+ system "buildkite-agent", "annotate",
40
+ "--context", "rspec",
41
+ "--style", "error",
42
+ "--append",
43
+ format_failure(notification),
44
+ out: :close # only display errors
45
+ end
44
46
  end
47
+ rescue
48
+ puts "Warning: Couldn't create Buildkite annotations:"
49
+ puts " " << $!.to_s, " " << $!.backtrace.join("\n ")
45
50
  end
46
- rescue
47
- puts "Warning: Couldn't create Buildkite annotations:"
48
- puts " " << $!.to_s, " " << $!.backtrace.join("\n ")
49
- end
50
51
 
51
- def format_failure(notification)
52
- build_url = ENV["BUILDKITE_BUILD_URL"].to_s
53
- job_id = ENV["BUILDKITE_JOB_ID"].to_s
54
- job_url = "#{build_url}##{job_id}"
52
+ def format_failure(notification)
53
+ build_url = ENV["BUILDKITE_BUILD_URL"].to_s
54
+ job_id = ENV["BUILDKITE_JOB_ID"].to_s
55
+ job_url = "#{build_url}##{job_id}"
55
56
 
56
- "<details>\n" <<
57
- "<summary>#{notification.description.encode(:xml => :text)}</summary>\n\n" <<
58
- "<code><pre>#{recolorize(notification.colorized_message_lines.join("\n").encode(:xml => :text))}</pre></code>\n\n" <<
59
- %{in <a href=#{job_url.encode(:xml => :attr)}>Job ##{job_id.encode(:xml => :text)}</a>\n} <<
60
- "</details>" <<
61
- "\n\n\n"
62
- end
57
+ "<details>\n" <<
58
+ "<summary>#{notification.description.encode(:xml => :text)}</summary>\n\n" <<
59
+ "<code><pre>#{recolorize(notification.colorized_message_lines.join("\n").encode(:xml => :text))}</pre></code>\n\n" <<
60
+ %{in <a href=#{job_url.encode(:xml => :attr)}>Job ##{job_id.encode(:xml => :text)}</a>\n} <<
61
+ "</details>" <<
62
+ "\n\n\n"
63
+ end
63
64
 
64
- private
65
+ private
65
66
 
66
- # Re-color an ANSI-colorized string using terminal CSS classes:
67
- # https://github.com/buildkite/terminal/blob/05a77905c468b9150cac41298fdb8a0735024d42/style.go#L34
68
- def recolorize(string)
69
- level = 0
70
- string.gsub(/\e\[(\d+(?:;\d+)*)m/) do
71
- "".tap do |buffer|
72
- codes = $1.split(";").map(&:to_i)
67
+ # Re-color an ANSI-colorized string using terminal CSS classes:
68
+ # https://github.com/buildkite/terminal/blob/05a77905c468b9150cac41298fdb8a0735024d42/style.go#L34
69
+ def recolorize(string)
70
+ level = 0
71
+ string.gsub(/\e\[(\d+(?:;\d+)*)m/) do
72
+ "".tap do |buffer|
73
+ codes = $1.split(";").map(&:to_i)
73
74
 
74
- classes = []
75
- while code = codes.shift
76
- case code
77
- when 0
78
- classes.clear
79
- buffer << ("</span>" * level)
80
- level = 0
81
- when 1..5, 9, 30..37, 90..97
82
- classes << "term-fg#{code}"
83
- when 40..47, 100..107
84
- classes << "term-bg#{code}"
85
- when 38
86
- if codes[0] == 5
87
- codes.shift
88
- if codes[0]
89
- classes << "term-fgx#{codes.shift}"
75
+ classes = []
76
+ while code = codes.shift
77
+ case code
78
+ when 0
79
+ classes.clear
80
+ buffer << ("</span>" * level)
81
+ level = 0
82
+ when 1..5, 9, 30..37, 90..97
83
+ classes << "term-fg#{code}"
84
+ when 40..47, 100..107
85
+ classes << "term-bg#{code}"
86
+ when 38
87
+ if codes[0] == 5
88
+ codes.shift
89
+ if codes[0]
90
+ classes << "term-fgx#{codes.shift}"
91
+ end
90
92
  end
91
- end
92
- when 48
93
- if codes[0] == 5
94
- codes.shift
95
- if codes[0]
96
- classes << "term-bgx#{codes.shift}"
93
+ when 48
94
+ if codes[0] == 5
95
+ codes.shift
96
+ if codes[0]
97
+ classes << "term-bgx#{codes.shift}"
98
+ end
97
99
  end
98
100
  end
99
101
  end
100
- end
101
102
 
102
- if classes.any?
103
- level += 1
104
- buffer << %{<span class=#{classes.map { |klass| klass }.join(" ").encode(:xml => :attr)}>}
103
+ if classes.any?
104
+ level += 1
105
+ buffer << %{<span class=#{classes.map { |klass| klass }.join(" ").encode(:xml => :attr)}>}
106
+ end
105
107
  end
106
- end
107
- end << ("</span>" * level)
108
+ end << ("</span>" * level)
109
+ end
108
110
  end
109
111
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Buildkite
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-buildkite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Cochran
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- cE~�p?J���5��v�J�{w�Ёr(��S|ə>�mѴ���)�m��Z�:�uQ�����z�ٴ�S���y��Y�GF�hHG����� {@6��x�?h1::�^7B�b0��*/�%���-�0��v;�!��SȵV� ul�gkP��0pA��.�D���wK&�����S�^�
2
- j��zv�� ��O�����. ����z�@u*�ś�4�cu2i��•�Ё�^ �P�ϊp�!���S�"��� ��*)��
1
+ ��v���
2
+ ����㉆=+}y��+>'����E�l�v��Άu5-�!*,��wC��1(&������P�=�7Q�a�d�N�Đ�6t��_��<>�e�'���"5� ���