rspec-buildkite 0.1.0 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa56a03a46bef42009cd2ecd773ce3d7093767832586421a43fef470bd79ffb1
4
- data.tar.gz: d14a660da966c5bdd0142398c94620a7a1ac65db893c3ab851c9807914841304
3
+ metadata.gz: 4323487115d2dc58511e6c4acabf0007e27cfe6df9c71c9167a3c24fce9ea862
4
+ data.tar.gz: f6c45d22e5c68cb34145867aa175fcd7f0cf555aab9aa2dfc91e3ad065717d81
5
5
  SHA512:
6
- metadata.gz: bc072e5216cd80d3b67681261e663f7b2f1ebbb33d6eab5d830db678a268fccf3e904773d9893b4553bcfec7135cbf11aa0dbecee82035c05d1608487cc6f6a4
7
- data.tar.gz: 16d8112cb59fd30917579c00f2896e76294127a57fdbf9ae375f5ef7fd6e1ca591e338a35861bce3605364183426ebe03370f8ec8f3cd1704c7c0da43a5fb780
6
+ metadata.gz: fabcc3676a007e391243bff2e841300e362560c52c1e17c88fc3782c35316a82a4dbb1cf2ef36e21040b7002a88a33d02984eb32b50c8f474fa8fa61c28e2bba
7
+ data.tar.gz: f088b0c96a630a361cb7e657f2acc83f8a78e13bfe6658d46b03bad9d28cab1b30910bd5a82d895b0f3ee8ea7e62209b71fe994965e41100891e6db1151dd733
checksums.yaml.gz.sig CHANGED
@@ -1 +1,3 @@
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�
1
+ oPUt3jԥ���)��?L}e��� �&� zM����Z'
2
+ ��[G�$Im���,�sy{��?�d����T�eȲ����բX�3r�(gP�Hf�F|B����
3
+ x]�����3},�Օ��rO�0
data.tar.gz.sig CHANGED
Binary file
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Samuel Cochran
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -38,6 +38,22 @@ Add it to your `.rspec` alongside your favorite formatter:
38
38
 
39
39
  Now run your specs on Buildkite!
40
40
 
41
+ ### Docker & Docker Compose
42
+
43
+ If you run your RSpec builds inside Docker or Docker Compose then you'll need to make sure that buildkite-agent is available inside your container, and that some environment variables are propagated into the running containers. The buildkite-agent binary can be baked into your image, or mounted in as a volume. If you're using [the docker-compose-buildkite-plugin][dcbp] you can pass the environment using [plugin configuration][dcbp-env]. Or you can add them to the [environment section][dc-env] in your `docker-compose.yml`, or supply [env arguments][d-env] to your docker command.
44
+
45
+ The following environment variables are required:
46
+
47
+ - `BUILDKITE`
48
+ - `BUILDKITE_BUILD_URL`
49
+ - `BUILDKITE_JOB_ID`
50
+ - `BUILDKITE_AGENT_ACCESS_TOKEN`
51
+
52
+ [dcbp]: https://github.com/buildkite-plugins/docker-compose-buildkite-plugin
53
+ [dcbp-env]: https://github.com/buildkite-plugins/docker-compose-buildkite-plugin#environment
54
+ [dc-env]: https://docs.docker.com/compose/environment-variables/
55
+ [d-env]: https://docs.docker.com/engine/reference/run/#env-environment-variables
56
+
41
57
  ## Development
42
58
 
43
59
  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.
@@ -46,7 +62,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
46
62
 
47
63
  ## Contributing
48
64
 
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/sj26/rspec-buildkite.
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/buildkite/rspec-buildkite.
50
66
 
51
67
  ## License
52
68
 
@@ -1,109 +1,76 @@
1
1
  require "thread"
2
2
 
3
3
  require "rspec/core"
4
+ require "rspec/buildkite/recolorizer"
4
5
 
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
6
+ module RSpec::Buildkite
7
+ # Create a Buildkite annotation for RSpec failures
8
+ #
9
+ # Help folks fix their builds as soon as possible when failures crop up by
10
+ # calling out failures in an annotation, even while the build is still running.
11
+ #
12
+ # Uses a background Thread so we don't block the build.
13
+ #
14
+ class AnnotationFormatter
15
+ RSpec::Core::Formatters.register self, :example_failed
14
16
 
15
- def initialize(output)
16
- # We don't actually use this, but keep a reference anyway
17
- @output = output
17
+ def initialize(output)
18
+ # We don't actually use this, but keep a reference anyway
19
+ @output = output
18
20
 
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 }
21
+ # Only setup if we're actually running on Buildkite
22
+ if ENV["BUILDKITE"]
23
+ @queue = Queue.new
24
+ @thread = Thread.new(&method(:thread))
25
+ at_exit { @queue.push(:close); @thread.join }
26
+ end
24
27
  end
25
- end
26
28
 
27
- def example_failed(notification)
28
- @queue.push(notification) if @queue
29
- end
29
+ def example_failed(notification)
30
+ @queue.push(notification) if @queue
31
+ end
30
32
 
31
- private
33
+ private
32
34
 
33
- def thread
34
- while notification = @queue.pop
35
- break if notification == :close
35
+ def thread
36
+ while notification = @queue.pop
37
+ break if notification == :close
36
38
 
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
39
+ if notification
40
+ system("buildkite-agent", "annotate",
41
+ "--context", "rspec",
42
+ "--style", "error",
43
+ "--append",
44
+ format_failure(notification),
45
+ out: :close # only display errors
46
+ ) or raise "buildkite-agent failed to run: #{$?}#{" (command not found)" if $?.exitstatus == 127}"
47
+ end
44
48
  end
49
+ rescue
50
+ $stderr.puts "Warning: Couldn't create Buildkite annotations:\n" <<
51
+ " #{$!.to_s}\n" <<
52
+ " #{$!.backtrace.join("\n ")}"
45
53
  end
46
- rescue
47
- puts "Warning: Couldn't create Buildkite annotations:"
48
- puts " " << $!.to_s, " " << $!.backtrace.join("\n ")
49
- end
50
54
 
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
55
+ def format_failure(notification)
56
+ build_url = ENV["BUILDKITE_BUILD_URL"].to_s
57
+ job_id = ENV["BUILDKITE_JOB_ID"].to_s
58
+ job_url = "#{build_url}##{job_id}"
63
59
 
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
60
+ %{<details>\n} <<
61
+ %{<summary>#{notification.description.encode(:xml => :text)}</summary>\n} <<
62
+ %{<pre class="term">#{Recolorizer.recolorize(notification.colorized_message_lines.join("\n").encode(:xml => :text))}</pre>\n} <<
63
+ format_rerun(notification) <<
64
+ %{<p>in <a href=#{job_url.encode(:xml => :attr)}>Job ##{job_id.encode(:xml => :text)}</a></p>\n} <<
65
+ %{</details>} <<
66
+ %{\n\n\n}
67
+ end
101
68
 
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)
69
+ def format_rerun(notification)
70
+ %{<pre class="term">} <<
71
+ %{<span class="term-fg31">rspec #{notification.example.location_rerun_argument.encode(:xml => :text)}</span>} <<
72
+ %{ <span class="term-fg36"># #{notification.example.full_description.encode(:xml => :text)}</span>} <<
73
+ %{</pre>\n}
74
+ end
108
75
  end
109
76
  end
@@ -0,0 +1,53 @@
1
+ module RSpec::Buildkite
2
+ module Recolorizer
3
+ module_function
4
+
5
+ # Re-color an ANSI-colorized string using terminal CSS classes:
6
+ # https://github.com/buildkite/terminal/blob/05a77905c468b9150cac41298fdb8a0735024d42/style.go#L34
7
+ def recolorize(string)
8
+ level = 0
9
+ string.gsub(/\e\[(\d+(?:;\d+)*)m/) do
10
+ "".tap do |buffer|
11
+ codes = $1.split(";").map(&:to_i)
12
+
13
+ classes = []
14
+ while code = codes.shift
15
+ case code
16
+ when 0
17
+ classes.clear
18
+ buffer << ("</span>" * level)
19
+ level = 0
20
+ when 1..5, 9, 30..37
21
+ classes << "term-fg#{code}"
22
+ when 38
23
+ if codes[0] == 5
24
+ codes.shift
25
+ if codes[0]
26
+ classes << "term-fgx#{codes.shift}"
27
+ end
28
+ end
29
+ when 40..47
30
+ classes << "term-bg#{code}"
31
+ when 48
32
+ if codes[0] == 5
33
+ codes.shift
34
+ if codes[0]
35
+ classes << "term-bgx#{codes.shift}"
36
+ end
37
+ end
38
+ when 90..97
39
+ classes << "term-fgi#{code}"
40
+ when 100..107
41
+ classes << "term-bgi#{code}"
42
+ end
43
+ end
44
+
45
+ if classes.any?
46
+ level += 1
47
+ buffer << %{<span class=#{classes.map { |klass| klass }.join(" ").encode(:xml => :attr)}>}
48
+ end
49
+ end
50
+ end << ("</span>" * level)
51
+ end
52
+ end
53
+ end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Buildkite
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.5"
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Cochran
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDKDCCAhCgAwIBAgIBBTANBgkqhkiG9w0BAQUFADA6MQ0wCwYDVQQDDARzajI2
14
- MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0x
15
- NzA3MzEwNTQ3MDVaFw0xODA3MzEwNTQ3MDVaMDoxDTALBgNVBAMMBHNqMjYxFDAS
13
+ MIIDKDCCAhCgAwIBAgIBCDANBgkqhkiG9w0BAQsFADA6MQ0wCwYDVQQDDARzajI2
14
+ MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0y
15
+ MTA0MjcwMzIxMjZaFw0yMjA0MjcwMzIxMjZaMDoxDTALBgNVBAMMBHNqMjYxFDAS
16
16
  BgoJkiaJk/IsZAEZFgRzajI2MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkq
17
17
  hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr60Eo/ttCk8GMTMFiPr3GoYMIMFvLak
18
18
  xSmTk9YGCB6UiEePB4THSSA5w6IPyeaCF/nWkDp3/BAam0eZMWG1IzYQB23TqIM0
@@ -21,14 +21,14 @@ cert_chain:
21
21
  4O/FL2ChjL2CPCpLZW55ShYyrzphWJwLOJe+FJ/ZBl6YXwrzQM9HKnt4titSNvyU
22
22
  KzE3L63A3PZvExzLrN9u09kuWLLJfXB2sGOlw3n9t72rJiuBr3/OQQIDAQABozkw
23
23
  NzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU99dfRjEKFyczTeIz
24
- m3ZsDWrNC80wDQYJKoZIhvcNAQEFBQADggEBADGiXpvK754s0zTFx3y31ZRDdvAI
25
- lA209JIjUlDyr9ptCRadihyfF2l9/hb+hLemiPEYppzG6vEK1TIyzbAR36yOJ8CX
26
- 4vPkCXLuwHhs6UIRbwN+IEy41nsIlBxmjLYei8h3t/G2Vm2oOaLdbjDXS+Srl9U8
27
- shsE8ft81PxSQfzEL7Mr9cC9XvWbHW+SyTpfGm8rAtaqZkNeke4U8a0di4oz2EfA
28
- P4lSfmXxsd1C71ckIp0cyXkPhyTtpyS/5hq9HhuUNzEHkSDe36/Rd1xYKV5JxMC2
29
- YAttWFUs06lor2q1wwncPaMtUtbWwW35+1IV6xhs2rFY6DD/I6ZkK3GnHdY=
24
+ m3ZsDWrNC80wDQYJKoZIhvcNAQELBQADggEBAInkmTwBeGEJ7Xu9jjZIuFaE197m
25
+ YfvrzVoE6Q1DlWXpgyhhxbPIKg2acvM/Z18A7kQrF7paYl64Ti84dC64seOFIBNx
26
+ Qj/lxzPHMBoAYqeXYJhnYIXnvGCZ4Fkic5Bhs+VdcDP/uwYp3adqy+4bT/XDFZQg
27
+ tSjrAOTg3wck5aI+Tz90ONQJ83bnCRr1UPQ0T3PbWMjnNsEa9CAxUB845Sg+9yUz
28
+ Tvf+pbX8JT9rawFDogxPhL7eRAbjg4MH9amp5l8HTVCAsW8vqv7wM4rtMNAaXmik
29
+ LJghfDEf70fTtbs4Zv57pPhn1b7wBNf8fh+TZOlYAA6dFtQXoCwfE6bWgQU=
30
30
  -----END CERTIFICATE-----
31
- date: 2018-05-26 00:00:00.000000000 Z
31
+ date: 2021-06-01 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec-core
@@ -120,11 +120,13 @@ executables: []
120
120
  extensions: []
121
121
  extra_rdoc_files: []
122
122
  files:
123
+ - LICENSE.txt
123
124
  - README.md
124
125
  - lib/rspec/buildkite.rb
125
126
  - lib/rspec/buildkite/annotation_formatter.rb
127
+ - lib/rspec/buildkite/recolorizer.rb
126
128
  - lib/rspec/buildkite/version.rb
127
- homepage: https://github.com/sj26/rspec-buildkite
129
+ homepage: https://github.com/buildkite/rspec-buildkite
128
130
  licenses:
129
131
  - MIT
130
132
  metadata: {}
@@ -134,7 +136,7 @@ require_paths:
134
136
  - lib
135
137
  required_ruby_version: !ruby/object:Gem::Requirement
136
138
  requirements:
137
- - - "~>"
139
+ - - ">="
138
140
  - !ruby/object:Gem::Version
139
141
  version: '2.2'
140
142
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -143,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
145
  - !ruby/object:Gem::Version
144
146
  version: '0'
145
147
  requirements: []
146
- rubyforge_project:
147
- rubygems_version: 2.7.7
148
+ rubygems_version: 3.1.4
148
149
  signing_key:
149
150
  specification_version: 4
150
151
  summary: RSpec formatter creating Buildkite annotations for failures
metadata.gz.sig CHANGED
Binary file