rspec-buildkite 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aa56a03a46bef42009cd2ecd773ce3d7093767832586421a43fef470bd79ffb1
4
+ data.tar.gz: d14a660da966c5bdd0142398c94620a7a1ac65db893c3ab851c9807914841304
5
+ SHA512:
6
+ metadata.gz: bc072e5216cd80d3b67681261e663f7b2f1ebbb33d6eab5d830db678a268fccf3e904773d9893b4553bcfec7135cbf11aa0dbecee82035c05d1608487cc6f6a4
7
+ data.tar.gz: 16d8112cb59fd30917579c00f2896e76294127a57fdbf9ae375f5ef7fd6e1ca591e338a35861bce3605364183426ebe03370f8ec8f3cd1704c7c0da43a5fb780
@@ -0,0 +1 @@
1
+ �Wm�fy�q��yҢ�L]42�lD�Q{�Pv���G;E%A�NP��}Vu��!��]���^@�Gkѳȶ׋䓗�!�n:�FsP�0?���p�r |N�r��<���xt|#�LNgS WX�ش�� -6�b�?�w� �Xk���5�G���G��2=d�P��$~�o�x{ :�se�D�-F�0�*��ʍD]a����c����^` I(l ��`&}o'L]+%��o��-��n�aO�S6������"!JQ�
Binary file
@@ -0,0 +1,53 @@
1
+ # RSpec Buildkite
2
+
3
+ Output [RSpec][rspec] failure messages as [Buildkite annotations][buildkite-annotations] as soon as they happen so you can fix them while your build finishes.
4
+
5
+ ![A Buildkite build still in progress with an annotation showing an RSpec failure][screenshot]
6
+
7
+ [rspec]: http://rspec.info
8
+ [buildkite-annotations]: https://buildkite.com/docs/agent/v3/cli-annotate
9
+ [screenshot]: https://user-images.githubusercontent.com/14028/40577709-5b839e8a-614d-11e8-898b-575bb0cc02ba.png
10
+
11
+ ## Installation
12
+
13
+ Add the gem to your Gemfile, after rspec:
14
+
15
+ ```ruby
16
+ gem "rspec"
17
+ gem "rspec-buildkite"
18
+ ```
19
+
20
+ And then bundle:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install rspec-buildkite
27
+
28
+ ## Usage
29
+
30
+ Add it to your `.rspec` alongside your favorite formatter:
31
+
32
+ ```
33
+ --color
34
+ --require spec_helper
35
+ --format documentation
36
+ --format RSpec::Buildkite::AnnotationFormatter
37
+ ```
38
+
39
+ Now run your specs on Buildkite!
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sj26/rspec-buildkite.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "rspec/buildkite/version"
2
+ require "rspec/buildkite/annotation_formatter"
@@ -0,0 +1,109 @@
1
+ require "thread"
2
+
3
+ require "rspec/core"
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
14
+
15
+ def initialize(output)
16
+ # We don't actually use this, but keep a reference anyway
17
+ @output = output
18
+
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 }
24
+ end
25
+ end
26
+
27
+ def example_failed(notification)
28
+ @queue.push(notification) if @queue
29
+ end
30
+
31
+ private
32
+
33
+ def thread
34
+ while notification = @queue.pop
35
+ break if notification == :close
36
+
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
44
+ end
45
+ end
46
+ rescue
47
+ puts "Warning: Couldn't create Buildkite annotations:"
48
+ puts " " << $!.to_s, " " << $!.backtrace.join("\n ")
49
+ end
50
+
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}"
55
+
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
63
+
64
+ private
65
+
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)
73
+
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}"
90
+ end
91
+ end
92
+ when 48
93
+ if codes[0] == 5
94
+ codes.shift
95
+ if codes[0]
96
+ classes << "term-bgx#{codes.shift}"
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ if classes.any?
103
+ level += 1
104
+ buffer << %{<span class=#{classes.map { |klass| klass }.join(" ").encode(:xml => :attr)}>}
105
+ end
106
+ end
107
+ end << ("</span>" * level)
108
+ end
109
+ end
@@ -0,0 +1,5 @@
1
+ module RSpec
2
+ module Buildkite
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-buildkite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Cochran
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDKDCCAhCgAwIBAgIBBTANBgkqhkiG9w0BAQUFADA6MQ0wCwYDVQQDDARzajI2
14
+ MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0x
15
+ NzA3MzEwNTQ3MDVaFw0xODA3MzEwNTQ3MDVaMDoxDTALBgNVBAMMBHNqMjYxFDAS
16
+ BgoJkiaJk/IsZAEZFgRzajI2MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkq
17
+ hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr60Eo/ttCk8GMTMFiPr3GoYMIMFvLak
18
+ xSmTk9YGCB6UiEePB4THSSA5w6IPyeaCF/nWkDp3/BAam0eZMWG1IzYQB23TqIM0
19
+ 1xzcNRvFsn0aQoQ00k+sj+G83j3T5OOV5OZIlu8xAChMkQmiPd1NXc6uFv+Iacz7
20
+ kj+CMsI9YUFdNoU09QY0b+u+Rb6wDYdpyvN60YC30h0h1MeYbvYZJx/iZK4XY5zu
21
+ 4O/FL2ChjL2CPCpLZW55ShYyrzphWJwLOJe+FJ/ZBl6YXwrzQM9HKnt4titSNvyU
22
+ KzE3L63A3PZvExzLrN9u09kuWLLJfXB2sGOlw3n9t72rJiuBr3/OQQIDAQABozkw
23
+ NzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU99dfRjEKFyczTeIz
24
+ m3ZsDWrNC80wDQYJKoZIhvcNAQEFBQADggEBADGiXpvK754s0zTFx3y31ZRDdvAI
25
+ lA209JIjUlDyr9ptCRadihyfF2l9/hb+hLemiPEYppzG6vEK1TIyzbAR36yOJ8CX
26
+ 4vPkCXLuwHhs6UIRbwN+IEy41nsIlBxmjLYei8h3t/G2Vm2oOaLdbjDXS+Srl9U8
27
+ shsE8ft81PxSQfzEL7Mr9cC9XvWbHW+SyTpfGm8rAtaqZkNeke4U8a0di4oz2EfA
28
+ P4lSfmXxsd1C71ckIp0cyXkPhyTtpyS/5hq9HhuUNzEHkSDe36/Rd1xYKV5JxMC2
29
+ YAttWFUs06lor2q1wwncPaMtUtbWwW35+1IV6xhs2rFY6DD/I6ZkK3GnHdY=
30
+ -----END CERTIFICATE-----
31
+ date: 2018-05-26 00:00:00.000000000 Z
32
+ dependencies:
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec-core
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.16'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.16'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: coderay
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: appraisal
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ description:
118
+ email: sj26@sj26.com
119
+ executables: []
120
+ extensions: []
121
+ extra_rdoc_files: []
122
+ files:
123
+ - README.md
124
+ - lib/rspec/buildkite.rb
125
+ - lib/rspec/buildkite/annotation_formatter.rb
126
+ - lib/rspec/buildkite/version.rb
127
+ homepage: https://github.com/sj26/rspec-buildkite
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '2.2'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.7.7
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: RSpec formatter creating Buildkite annotations for failures
151
+ test_files: []
@@ -0,0 +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�"��� ��*)��