buildkite-test_collector 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +19 -0
- data/CODE_OF_CONDUCT.md +133 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +50 -0
- data/LICENSE.txt +21 -0
- data/README.md +103 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/buildkite-test_collector.gemspec +32 -0
- data/buildkite.yaml +8 -0
- data/lib/buildkite/test_collector/ci.rb +86 -0
- data/lib/buildkite/test_collector/http_client.rb +35 -0
- data/lib/buildkite/test_collector/library_hooks/minitest.rb +16 -0
- data/lib/buildkite/test_collector/library_hooks/rspec.rb +35 -0
- data/lib/buildkite/test_collector/logger.rb +19 -0
- data/lib/buildkite/test_collector/minitest_plugin/reporter.rb +34 -0
- data/lib/buildkite/test_collector/minitest_plugin/trace.rb +102 -0
- data/lib/buildkite/test_collector/minitest_plugin.rb +27 -0
- data/lib/buildkite/test_collector/network.rb +77 -0
- data/lib/buildkite/test_collector/object.rb +20 -0
- data/lib/buildkite/test_collector/rspec_plugin/reporter.rb +95 -0
- data/lib/buildkite/test_collector/rspec_plugin/trace.rb +87 -0
- data/lib/buildkite/test_collector/session.rb +331 -0
- data/lib/buildkite/test_collector/socket_connection.rb +157 -0
- data/lib/buildkite/test_collector/tracer.rb +65 -0
- data/lib/buildkite/test_collector/uploader.rb +73 -0
- data/lib/buildkite/test_collector/version.rb +8 -0
- data/lib/buildkite/test_collector.rb +84 -0
- data/lib/minitest/buildkite_collector_plugin.rb +7 -0
- metadata +139 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "timeout"
|
4
|
+
require "tmpdir"
|
5
|
+
|
6
|
+
require_relative "test_collector/version"
|
7
|
+
require_relative "test_collector/logger"
|
8
|
+
|
9
|
+
module Buildkite
|
10
|
+
module TestCollector
|
11
|
+
class Error < StandardError; end
|
12
|
+
class TimeoutError < ::Timeout::Error; end
|
13
|
+
|
14
|
+
DEFAULT_URL = "https://analytics-api.buildkite.com/v1/uploads"
|
15
|
+
|
16
|
+
class << self
|
17
|
+
attr_accessor :api_token
|
18
|
+
attr_accessor :url
|
19
|
+
attr_accessor :uploader
|
20
|
+
attr_accessor :session
|
21
|
+
attr_accessor :debug_enabled
|
22
|
+
attr_accessor :debug_filepath
|
23
|
+
attr_accessor :tracing_enabled
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.configure(hook:, token: nil, url: nil, debug_enabled: false, debug_filepath: nil, tracing_enabled: true)
|
27
|
+
self.api_token = token || ENV["BUILDKITE_ANALYTICS_TOKEN"]
|
28
|
+
self.url = url || DEFAULT_URL
|
29
|
+
self.debug_enabled = debug_enabled || !!(ENV["BUILDKITE_ANALYTICS_DEBUG_ENABLED"])
|
30
|
+
self.debug_filepath = debug_filepath || ENV["BUILDKITE_ANALYTICS_DEBUG_FILEPATH"] || Dir.tmpdir
|
31
|
+
self.tracing_enabled = tracing_enabled
|
32
|
+
|
33
|
+
self.hook_into(hook)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.hook_into(hook)
|
37
|
+
file = "test_collector/library_hooks/#{hook}"
|
38
|
+
require_relative file
|
39
|
+
rescue LoadError
|
40
|
+
raise ArgumentError.new("#{hook.inspect} is not a supported Buildkite Analytics Test library hook.")
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.annotate(content)
|
44
|
+
tracer = Buildkite::TestCollector::Uploader.tracer
|
45
|
+
tracer&.enter("annotation", **{ content: content })
|
46
|
+
tracer&.leave
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.log_formatter
|
50
|
+
@log_formatter ||= Buildkite::TestCollector::Logger::Formatter.new
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.log_formatter=(log_formatter)
|
54
|
+
@log_formatter = log_formatter
|
55
|
+
logger.formatter = log_formatter
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.logger=(logger)
|
59
|
+
@logger = logger
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.logger
|
63
|
+
return @logger if defined?(@logger)
|
64
|
+
|
65
|
+
debug_mode = ENV.fetch("BUILDKITE_ANALYTICS_DEBUG_ENABLED") do
|
66
|
+
$DEBUG
|
67
|
+
end
|
68
|
+
|
69
|
+
level = !!debug_mode ? ::Logger::DEBUG : ::Logger::WARN
|
70
|
+
@logger ||= Buildkite::TestCollector::Logger.new($stderr, level: level)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.enable_tracing!
|
74
|
+
return unless self.tracing_enabled
|
75
|
+
|
76
|
+
Buildkite::TestCollector::Network.configure
|
77
|
+
Buildkite::TestCollector::Object.configure
|
78
|
+
|
79
|
+
ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, payload|
|
80
|
+
Buildkite::TestCollector::Uploader.tracer&.backfill(:sql, finish - start, **{ query: payload[:sql] })
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: buildkite-test_collector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Buildkite
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '8'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '8'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: websocket
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.2'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.2'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec-core
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.10'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.10'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec-expectations
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.10'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.10'
|
75
|
+
description:
|
76
|
+
email:
|
77
|
+
- support+analytics@buildkite.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- ".gitignore"
|
83
|
+
- ".rspec"
|
84
|
+
- CHANGELOG.md
|
85
|
+
- CODE_OF_CONDUCT.md
|
86
|
+
- Gemfile
|
87
|
+
- Gemfile.lock
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- bin/console
|
92
|
+
- bin/setup
|
93
|
+
- buildkite-test_collector.gemspec
|
94
|
+
- buildkite.yaml
|
95
|
+
- lib/buildkite/test_collector.rb
|
96
|
+
- lib/buildkite/test_collector/ci.rb
|
97
|
+
- lib/buildkite/test_collector/http_client.rb
|
98
|
+
- lib/buildkite/test_collector/library_hooks/minitest.rb
|
99
|
+
- lib/buildkite/test_collector/library_hooks/rspec.rb
|
100
|
+
- lib/buildkite/test_collector/logger.rb
|
101
|
+
- lib/buildkite/test_collector/minitest_plugin.rb
|
102
|
+
- lib/buildkite/test_collector/minitest_plugin/reporter.rb
|
103
|
+
- lib/buildkite/test_collector/minitest_plugin/trace.rb
|
104
|
+
- lib/buildkite/test_collector/network.rb
|
105
|
+
- lib/buildkite/test_collector/object.rb
|
106
|
+
- lib/buildkite/test_collector/rspec_plugin/reporter.rb
|
107
|
+
- lib/buildkite/test_collector/rspec_plugin/trace.rb
|
108
|
+
- lib/buildkite/test_collector/session.rb
|
109
|
+
- lib/buildkite/test_collector/socket_connection.rb
|
110
|
+
- lib/buildkite/test_collector/tracer.rb
|
111
|
+
- lib/buildkite/test_collector/uploader.rb
|
112
|
+
- lib/buildkite/test_collector/version.rb
|
113
|
+
- lib/minitest/buildkite_collector_plugin.rb
|
114
|
+
homepage: https://github.com/buildkite/test-collector-ruby
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
metadata:
|
118
|
+
homepage_uri: https://github.com/buildkite/test-collector-ruby
|
119
|
+
source_code_uri: https://github.com/buildkite/test-collector-ruby
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 2.3.0
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubygems_version: 3.1.4
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Track test executions and report to Buildkite Test Analytics
|
139
|
+
test_files: []
|