build_metrics_logger 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/build_metrics_logger.rb +93 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 20b35be726c1122b4fe7178411d79ebd1a20e734
|
4
|
+
data.tar.gz: 8fc72b7c723c14f2868718fcdce22bf490808181
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 456cc252ba2a5011da17f7851ebc11f85859fba2503c6de588a13fe584c1cdc89d0c0726fc431447f40c7c69e5dbccf754767ea6f9ecbf65f8810500a1c31485
|
7
|
+
data.tar.gz: c8b5ad623b65d2e971c673ab398908cc64a677668c780189822a590c665e3927ce0b16cd27a144fa1d104887dfabe242fef168ef44afd6984a4b9d4318b79f93
|
@@ -0,0 +1,93 @@
|
|
1
|
+
class BuildMetricsLogger
|
2
|
+
include HTTParty
|
3
|
+
|
4
|
+
def initialize(token = nil)
|
5
|
+
puts "Listener Initialized"
|
6
|
+
@token = token
|
7
|
+
@build_id = ENV.fetch('BUILD_METRICS_LOGGER_ID')
|
8
|
+
end
|
9
|
+
|
10
|
+
def start(notification)
|
11
|
+
# "**Running before the entire suite**"
|
12
|
+
end
|
13
|
+
|
14
|
+
def stop(notification)
|
15
|
+
# "**Running after the entire suite finishes**"
|
16
|
+
suite_finished(notification)
|
17
|
+
end
|
18
|
+
|
19
|
+
def example_passed(notification)
|
20
|
+
# "**This example passed. Neat!**"
|
21
|
+
|
22
|
+
example_finished(notification)
|
23
|
+
end
|
24
|
+
|
25
|
+
def example_failed(notification)
|
26
|
+
# "**This example failed :(**"
|
27
|
+
|
28
|
+
example_finished(notification)
|
29
|
+
end
|
30
|
+
|
31
|
+
def example_finished(notification)
|
32
|
+
if notification.example.metadata[:e2e] == true && ENV.fetch('IS_LOCAL', 'true') == 'false'
|
33
|
+
id = notification.example.id.to_s
|
34
|
+
description = notification.example.full_description.to_s
|
35
|
+
location = notification.example.location.to_s
|
36
|
+
passed = notification.example.execution_result.status.to_s == 'passed' ? true : false
|
37
|
+
# prev_result = notification.example.metadata[:last_run_status].to_s
|
38
|
+
time = notification.example.execution_result.run_time.to_s
|
39
|
+
exception = notification.example.execution_result.exception.to_s.empty? ? "nil" : notification.example.execution_result.exception.to_s
|
40
|
+
test_data = [id, description, location, passed, prev_result, time, exception]
|
41
|
+
if @token
|
42
|
+
log_example_result(test_data)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def suite_finished(notification)
|
48
|
+
if notification.examples[0].metadata[:e2e] == true && ENV.fetch('IS_LOCAL', 'true') == 'false'
|
49
|
+
time = notification.duration
|
50
|
+
passed = notification.failure_count == 0 ? true : false
|
51
|
+
build_data = [time, passed]
|
52
|
+
if @token
|
53
|
+
log_build_result(build_data)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def example_result_url
|
59
|
+
"https://build-metrics-web.herokuapp.com/builds/#{@build_id}/tests/result"
|
60
|
+
end
|
61
|
+
|
62
|
+
def build_result_url
|
63
|
+
"https://build-metrics-web.herokuapp.com/builds/#{@build_id}/result"
|
64
|
+
end
|
65
|
+
|
66
|
+
def log_example_result(data)
|
67
|
+
response = HTTParty.post(example_result_url,
|
68
|
+
headers: {
|
69
|
+
"Authorization" => "Bearer #{@token}"
|
70
|
+
},
|
71
|
+
body: {
|
72
|
+
passed: data.passed,
|
73
|
+
rspecID: data.id,
|
74
|
+
description: data.description,
|
75
|
+
path: data.location,
|
76
|
+
runtime: data.time
|
77
|
+
}
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
def log_build_result(data)
|
82
|
+
response = HTTPart.post(build_result_url,
|
83
|
+
headers: {
|
84
|
+
"Authorization" => "Bearer #{@token}"
|
85
|
+
},
|
86
|
+
body: {
|
87
|
+
passed: data.passed,
|
88
|
+
time: data.time,
|
89
|
+
build: @build_id
|
90
|
+
}
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: build_metrics_logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Nelson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/build_metrics_logger.rb
|
20
|
+
homepage: http://rubygems.org/gems/build_metrics_logger
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.14
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: A gem to log spec results back to the Build Metrics web application
|
44
|
+
test_files: []
|