buildkite-test_collector 2.4.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/Gemfile.lock +2 -2
- data/buildkite-test_collector.gemspec +1 -2
- data/lib/buildkite/test_collector/ci.rb +1 -0
- data/lib/buildkite/test_collector/library_hooks/rspec.rb +3 -1
- data/lib/buildkite/test_collector/minitest_plugin/trace.rb +1 -1
- data/lib/buildkite/test_collector/minitest_plugin.rb +5 -1
- data/lib/buildkite/test_collector/rspec_plugin/reporter.rb +6 -2
- data/lib/buildkite/test_collector/rspec_plugin/trace.rb +2 -2
- data/lib/buildkite/test_collector/test_links_plugin/formatter.rb +1 -1
- data/lib/buildkite/test_collector/tracer.rb +18 -4
- data/lib/buildkite/test_collector/version.rb +1 -1
- data/lib/buildkite/test_collector.rb +12 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e8ff4ceff4d825291a8878bf19a912362d45c36d6750c5e14628f446cec0bbd
|
4
|
+
data.tar.gz: 215441296a3c91547b0c43b062893239fbe5bae5ca2e1a80cca7b2ec65277e77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d31e59e76f2dc92ef5951f9d97663f14cb84d9ba1256c8586931146151222c7ce3769a8913517910312d0a75a7cafb3488f0b9690257c4fc6686fbf37cbed9ee
|
7
|
+
data.tar.gz: 995fc9e592b74a41385058c4eac868e9639f6ef9bfb2ba9068cd156fd6ab5d90bf40aca86a9ab9c8560cf7c9ba80c4f172747a948e4e219976c680d035eae0af
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v2.6.0
|
4
|
+
|
5
|
+
- Trace spans can be filtered by minimum duration #215 - @pda
|
6
|
+
|
7
|
+
## v2.5.0
|
8
|
+
|
9
|
+
- Remove ActiveSupport as a primary dependancy #212 - @pat
|
10
|
+
|
3
11
|
## v2.4.0
|
4
12
|
|
5
|
-
- Feature release: Output links to Test Analytic tests within the rspec log @meghan-kradolfer
|
13
|
+
- Feature release: Output links to Test Analytic tests within the rspec log #209 - @meghan-kradolfer
|
6
14
|
|
7
15
|
## v2.3.2
|
8
16
|
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
buildkite-test_collector (2.
|
5
|
-
activesupport (>= 4.2)
|
4
|
+
buildkite-test_collector (2.6.0)
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: https://rubygems.org/
|
@@ -38,6 +37,7 @@ PLATFORMS
|
|
38
37
|
ruby
|
39
38
|
|
40
39
|
DEPENDENCIES
|
40
|
+
activesupport (>= 4.2)
|
41
41
|
buildkite-test_collector!
|
42
42
|
rake (~> 13.0)
|
43
43
|
rspec (~> 3.0)
|
@@ -24,8 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
26
26
|
|
27
|
-
spec.
|
28
|
-
|
27
|
+
spec.add_development_dependency "activesupport", ">= 4.2"
|
29
28
|
spec.add_development_dependency "rspec-core", '~> 3.10'
|
30
29
|
spec.add_development_dependency "rspec-expectations", '~> 3.10'
|
31
30
|
end
|
@@ -40,6 +40,7 @@ class Buildkite::TestCollector::CI
|
|
40
40
|
"language_version" => RUBY_VERSION,
|
41
41
|
"version" => Buildkite::TestCollector::VERSION,
|
42
42
|
"collector" => "ruby-#{Buildkite::TestCollector::NAME}",
|
43
|
+
"trace_min_duration" => Buildkite::TestCollector.trace_min_duration&.to_s,
|
43
44
|
}.select { |_, value| !value.nil? }
|
44
45
|
end
|
45
46
|
|
@@ -16,7 +16,9 @@ RSpec.configure do |config|
|
|
16
16
|
end
|
17
17
|
|
18
18
|
config.around(:each) do |example|
|
19
|
-
tracer = Buildkite::TestCollector::Tracer.new
|
19
|
+
tracer = Buildkite::TestCollector::Tracer.new(
|
20
|
+
min_duration: Buildkite::TestCollector.trace_min_duration,
|
21
|
+
)
|
20
22
|
|
21
23
|
# The _buildkite prefix here is added as a safeguard against name collisions
|
22
24
|
# as we are in the main thread
|
@@ -38,7 +38,7 @@ module Buildkite::TestCollector::MinitestPlugin
|
|
38
38
|
failure_reason: failure_reason,
|
39
39
|
failure_expanded: failure_expanded,
|
40
40
|
history: history,
|
41
|
-
).
|
41
|
+
).select { |_, value| !value.nil? }
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
@@ -9,7 +9,11 @@ require_relative "minitest_plugin/trace"
|
|
9
9
|
module Buildkite::TestCollector::MinitestPlugin
|
10
10
|
def before_setup
|
11
11
|
super
|
12
|
-
|
12
|
+
|
13
|
+
tracer = Buildkite::TestCollector::Tracer.new(
|
14
|
+
min_duration: Buildkite::TestCollector.trace_min_duration,
|
15
|
+
)
|
16
|
+
|
13
17
|
# The _buildkite prefix here is added as a safeguard against name collisions
|
14
18
|
# as we are in the main thread
|
15
19
|
Thread.current[:_buildkite_tracer] = tracer
|
@@ -40,6 +40,10 @@ module Buildkite::TestCollector::RSpecPlugin
|
|
40
40
|
RSpec::Core::MultipleExceptionError
|
41
41
|
]
|
42
42
|
|
43
|
+
def blank?(string)
|
44
|
+
string.nil? || string.strip.empty?
|
45
|
+
end
|
46
|
+
|
43
47
|
def failure_info(notification)
|
44
48
|
failure_expanded = []
|
45
49
|
|
@@ -73,9 +77,9 @@ module Buildkite::TestCollector::RSpecPlugin
|
|
73
77
|
def format_message_lines(message_lines)
|
74
78
|
message_lines.map! { |l| strip_diff_colors(l) }
|
75
79
|
# the first line is sometimes blank, depending on the error reported
|
76
|
-
message_lines.shift if message_lines.first
|
80
|
+
message_lines.shift if blank?(message_lines.first)
|
77
81
|
# the last line is sometimes blank, depending on the error reported
|
78
|
-
message_lines.pop if message_lines.last
|
82
|
+
message_lines.pop if blank?(message_lines.last)
|
79
83
|
message_lines
|
80
84
|
end
|
81
85
|
|
@@ -32,7 +32,7 @@ module Buildkite::TestCollector::RSpecPlugin
|
|
32
32
|
failure_reason: failure_reason,
|
33
33
|
failure_expanded: failure_expanded,
|
34
34
|
history: history,
|
35
|
-
).
|
35
|
+
).select { |_, value| !value.nil? }
|
36
36
|
end
|
37
37
|
|
38
38
|
private
|
@@ -60,7 +60,7 @@ module Buildkite::TestCollector::RSpecPlugin
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def shared_example?
|
63
|
-
example.metadata[:shared_group_inclusion_backtrace].
|
63
|
+
!example.metadata[:shared_group_inclusion_backtrace].empty?
|
64
64
|
end
|
65
65
|
|
66
66
|
def shared_example_call_location
|
@@ -10,7 +10,7 @@ module Buildkite::TestCollector::TestLinksPlugin
|
|
10
10
|
|
11
11
|
def dump_failures(notification)
|
12
12
|
# Do not display summary if no failed examples
|
13
|
-
return
|
13
|
+
return if notification.failed_examples.empty?
|
14
14
|
|
15
15
|
# Check if a Test Analytics token is set
|
16
16
|
return unless Buildkite::TestCollector.api_token
|
@@ -35,21 +35,30 @@ module Buildkite::TestCollector
|
|
35
35
|
@children = []
|
36
36
|
end
|
37
37
|
|
38
|
+
def duration
|
39
|
+
raise IncompleteSpan if end_at.nil?
|
40
|
+
|
41
|
+
end_at - start_at
|
42
|
+
end
|
43
|
+
|
38
44
|
def as_hash
|
39
45
|
{
|
40
46
|
section: section,
|
41
47
|
start_at: start_at,
|
42
48
|
end_at: end_at,
|
43
|
-
duration:
|
49
|
+
duration: duration,
|
44
50
|
detail: detail,
|
45
51
|
children: children.map(&:as_hash),
|
46
|
-
}
|
52
|
+
}
|
47
53
|
end
|
54
|
+
|
55
|
+
class IncompleteSpan < StandardError; end
|
48
56
|
end
|
49
57
|
|
50
|
-
def initialize
|
58
|
+
def initialize(min_duration: nil)
|
51
59
|
@top = Span.new(:top, MonotonicTime.call, nil, {})
|
52
60
|
@stack = [@top]
|
61
|
+
@min_duration = min_duration
|
53
62
|
end
|
54
63
|
|
55
64
|
def enter(section, **detail)
|
@@ -60,11 +69,16 @@ module Buildkite::TestCollector
|
|
60
69
|
|
61
70
|
def leave
|
62
71
|
current_span.end_at = MonotonicTime.call
|
72
|
+
duration = current_span.duration
|
63
73
|
@stack.pop
|
74
|
+
current_span.children.pop if @min_duration && duration < @min_duration
|
75
|
+
nil # avoid ambiguous return type/value
|
64
76
|
end
|
65
77
|
|
66
78
|
def backfill(section, duration, **detail)
|
67
|
-
|
79
|
+
return if @min_duration && duration < @min_duration
|
80
|
+
now = MonotonicTime.call
|
81
|
+
new_entry = Span.new(section, now - duration, now, detail)
|
68
82
|
current_span.children << new_entry
|
69
83
|
end
|
70
84
|
|
@@ -8,14 +8,11 @@ end
|
|
8
8
|
require "json"
|
9
9
|
require "logger"
|
10
10
|
require "net/http"
|
11
|
+
require "openssl"
|
11
12
|
require "time"
|
12
13
|
require "timeout"
|
13
14
|
require "tmpdir"
|
14
15
|
|
15
|
-
require "active_support/core_ext/object/blank"
|
16
|
-
require "active_support/core_ext/hash/indifferent_access"
|
17
|
-
require "active_support/notifications"
|
18
|
-
|
19
16
|
require_relative "test_collector/version"
|
20
17
|
require_relative "test_collector/error"
|
21
18
|
require_relative "test_collector/ci"
|
@@ -41,6 +38,7 @@ module Buildkite
|
|
41
38
|
attr_accessor :artifact_path
|
42
39
|
attr_accessor :env
|
43
40
|
attr_accessor :batch_size
|
41
|
+
attr_accessor :trace_min_duration
|
44
42
|
end
|
45
43
|
|
46
44
|
def self.configure(hook:, token: nil, url: nil, tracing_enabled: true, artifact_path: nil, env: {})
|
@@ -50,6 +48,12 @@ module Buildkite
|
|
50
48
|
self.artifact_path = artifact_path
|
51
49
|
self.env = env
|
52
50
|
self.batch_size = ENV.fetch("BUILDKITE_ANALYTICS_UPLOAD_BATCH_SIZE") { DEFAULT_UPLOAD_BATCH_SIZE }.to_i
|
51
|
+
|
52
|
+
trace_min_ms_string = ENV["BUILDKITE_ANALYTICS_TRACE_MIN_MS"]
|
53
|
+
self.trace_min_duration = if trace_min_ms_string && !trace_min_ms_string.empty?
|
54
|
+
Float(trace_min_ms_string) / 1000
|
55
|
+
end
|
56
|
+
|
53
57
|
self.hook_into(hook)
|
54
58
|
end
|
55
59
|
|
@@ -72,6 +76,10 @@ module Buildkite
|
|
72
76
|
Buildkite::TestCollector::Network.configure
|
73
77
|
Buildkite::TestCollector::Object.configure
|
74
78
|
|
79
|
+
return unless defined?(ActiveSupport)
|
80
|
+
|
81
|
+
require "active_support/notifications"
|
82
|
+
|
75
83
|
ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, payload|
|
76
84
|
Buildkite::TestCollector::Uploader.tracer&.backfill(:sql, finish - start, **{ query: payload[:sql] })
|
77
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildkite-test_collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Buildkite
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.2'
|
20
|
-
type: :
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubygems_version: 3.
|
118
|
+
rubygems_version: 3.4.10
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Track test executions and report to Buildkite Test Analytics
|