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 +4 -4
- checksums.yaml.gz.sig +3 -1
- data.tar.gz.sig +0 -0
- data/LICENSE.txt +21 -0
- data/README.md +17 -1
- data/lib/rspec/buildkite/annotation_formatter.rb +58 -91
- data/lib/rspec/buildkite/recolorizer.rb +53 -0
- data/lib/rspec/buildkite/version.rb +1 -1
- metadata +16 -15
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4323487115d2dc58511e6c4acabf0007e27cfe6df9c71c9167a3c24fce9ea862
|
4
|
+
data.tar.gz: f6c45d22e5c68cb34145867aa175fcd7f0cf555aab9aa2dfc91e3ad065717d81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fabcc3676a007e391243bff2e841300e362560c52c1e17c88fc3782c35316a82a4dbb1cf2ef36e21040b7002a88a33d02984eb32b50c8f474fa8fa61c28e2bba
|
7
|
+
data.tar.gz: f088b0c96a630a361cb7e657f2acc83f8a78e13bfe6658d46b03bad9d28cab1b30910bd5a82d895b0f3ee8ea7e62209b71fe994965e41100891e6db1151dd733
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
�
|
1
|
+
oPU�t3jԥ���)��?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/
|
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
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
17
|
+
def initialize(output)
|
18
|
+
# We don't actually use this, but keep a reference anyway
|
19
|
+
@output = output
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
29
|
+
def example_failed(notification)
|
30
|
+
@queue.push(notification) if @queue
|
31
|
+
end
|
30
32
|
|
31
|
-
|
33
|
+
private
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
def thread
|
36
|
+
while notification = @queue.pop
|
37
|
+
break if notification == :close
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
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
|
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.
|
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
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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:
|
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/
|
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
|
-
|
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
|