blinka-reporter 0.2.1 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blinka_client.rb +39 -3
- data/lib/blinka_minitest.rb +18 -27
- data/lib/minitest/blinka_plugin.rb +8 -4
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d84bd0f016744a88e06403d6f01f730004bf3cfb31b36394174f1335c12cd103
|
4
|
+
data.tar.gz: 3ab3b1744b8be12c29227e080ed0a39e6039ff63e0e883063d21b5c80a212290
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd1ee46a25fb0c799ae89054c6b835f11aea3883420320d5809160b2315ad1eb93640aea7588b1509fb744c79dc7fb6a5a35b3b47ba493cdc81b2bcb65ee671a
|
7
|
+
data.tar.gz: 97c433c7f79f60e8441376f47fcc9d937e2d1c02db93d67793655aed288d0367eea13d02fa1a7833ff6a299611e3c971f121d8b5169cc7d0f2dcf4b93e0cde73
|
data/lib/blinka_client.rb
CHANGED
@@ -2,6 +2,10 @@ require 'mimemagic'
|
|
2
2
|
require 'httparty'
|
3
3
|
|
4
4
|
class BlinkaClient
|
5
|
+
DEFAULT_HOST = 'https://www.blinka.app'.freeze
|
6
|
+
|
7
|
+
include HTTParty
|
8
|
+
|
5
9
|
class BlinkaConfig
|
6
10
|
attr_reader(
|
7
11
|
:tag,
|
@@ -12,13 +16,14 @@ class BlinkaClient
|
|
12
16
|
:team_secret,
|
13
17
|
:jwt_token
|
14
18
|
)
|
19
|
+
|
15
20
|
def initialize
|
16
|
-
@host = ENV.fetch('BLINKA_HOST',
|
21
|
+
@host = ENV.fetch('BLINKA_HOST', DEFAULT_HOST)
|
17
22
|
@team_id = ENV.fetch('BLINKA_TEAM_ID', nil)
|
18
23
|
@team_secret = ENV.fetch('BLINKA_TEAM_SECRET', nil)
|
19
24
|
@repository = ENV.fetch('BLINKA_REPOSITORY', nil)
|
20
25
|
@tag = ENV.fetch('BLINKA_TAG', '')
|
21
|
-
@commit =
|
26
|
+
@commit = BlinkaClient.find_commit
|
22
27
|
|
23
28
|
if @team_id.nil? || @team_secret.nil? || @repository.nil?
|
24
29
|
raise(BlinkaError, <<~EOS)
|
@@ -32,7 +37,6 @@ class BlinkaClient
|
|
32
37
|
end
|
33
38
|
|
34
39
|
class BlinkaError < StandardError; end
|
35
|
-
include HTTParty
|
36
40
|
|
37
41
|
def initialize
|
38
42
|
@config = BlinkaConfig.new
|
@@ -40,6 +44,18 @@ class BlinkaClient
|
|
40
44
|
end
|
41
45
|
|
42
46
|
def report(filepath: './blinka_results.json')
|
47
|
+
unless File.exist?(filepath)
|
48
|
+
raise(
|
49
|
+
BlinkaError,
|
50
|
+
'Could not find blinka_results.json, did tests run with environment variable BLINKA_JSON=true set?'
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
if ENV.fetch('BLINKA_ALLOW_WEBMOCK_DISABLE', 'true') == 'true' &&
|
55
|
+
defined?(WebMock) && WebMock.respond_to?(:disable!)
|
56
|
+
WebMock.disable!
|
57
|
+
end
|
58
|
+
|
43
59
|
self.authenticate
|
44
60
|
data = JSON.parse(File.open(filepath).read)
|
45
61
|
|
@@ -88,6 +104,19 @@ class BlinkaClient
|
|
88
104
|
else
|
89
105
|
raise(BlinkaError, "Could not report, got response code #{response.code}")
|
90
106
|
end
|
107
|
+
rescue => error
|
108
|
+
raise(BlinkaError, <<-EOS)
|
109
|
+
BLINKA:
|
110
|
+
Failed to create report because of #{error.class} with message:
|
111
|
+
#{error.message}
|
112
|
+
EOS
|
113
|
+
ensure
|
114
|
+
WebMock.enable! if defined?(WebMock) && WebMock.respond_to?(:enable!)
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.report(filepath: './blinka_results.json')
|
118
|
+
client = BlinkaClient.new
|
119
|
+
client.report(filepath: filepath)
|
91
120
|
end
|
92
121
|
|
93
122
|
def self.upload_image(filepath:)
|
@@ -169,4 +198,11 @@ class BlinkaClient
|
|
169
198
|
}
|
170
199
|
}
|
171
200
|
end
|
201
|
+
|
202
|
+
def self.find_commit
|
203
|
+
ENV.fetch(
|
204
|
+
'BLINKA_COMMIT',
|
205
|
+
ENV.fetch('HEROKU_TEST_RUN_COMMIT_VERSION', `git rev-parse HEAD`.chomp)
|
206
|
+
)
|
207
|
+
end
|
172
208
|
end
|
data/lib/blinka_minitest.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
class BlinkaMinitest
|
2
|
-
attr_reader(:test_result)
|
3
2
|
def initialize(test_result)
|
4
3
|
@test_result = test_result
|
5
4
|
end
|
@@ -8,14 +7,19 @@ class BlinkaMinitest
|
|
8
7
|
@path ||= source_location.first.gsub(Dir.getwd, '').delete_prefix('/')
|
9
8
|
end
|
10
9
|
|
10
|
+
def line
|
11
|
+
@line ||= source_location.last
|
12
|
+
end
|
13
|
+
|
11
14
|
# Handle broken API in Minitest between 5.10 and 5.11
|
12
15
|
# https://github.com/minitest-reporters/minitest-reporters/blob/e9092460b5a5cf5ca9eb375428217cbb2a7f6dbb/lib/minitest/reporters/default_reporter.rb#L159
|
13
16
|
def source_location
|
14
|
-
|
15
|
-
test_result.
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
@source_location ||=
|
18
|
+
if @test_result.respond_to?(:klass)
|
19
|
+
@test_result.source_location
|
20
|
+
else
|
21
|
+
@test_result.method(@test_result.name).source_location
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
def kind
|
@@ -24,47 +28,34 @@ class BlinkaMinitest
|
|
24
28
|
end
|
25
29
|
|
26
30
|
def message
|
27
|
-
failure = test_result.failure
|
31
|
+
failure = @test_result.failure
|
28
32
|
return unless failure
|
29
33
|
"#{failure.error.class}: #{failure.error.message}"
|
30
34
|
end
|
31
35
|
|
32
36
|
def backtrace
|
33
|
-
return unless test_result.failure
|
34
|
-
Minitest.filter_backtrace(test_result.failure.backtrace)
|
37
|
+
return unless @test_result.failure
|
38
|
+
Minitest.filter_backtrace(@test_result.failure.backtrace)
|
35
39
|
end
|
36
40
|
|
37
41
|
def result
|
38
|
-
if test_result.error?
|
42
|
+
if @test_result.error?
|
39
43
|
:error
|
40
|
-
elsif test_result.skipped?
|
44
|
+
elsif @test_result.skipped?
|
41
45
|
:skip
|
42
|
-
elsif test_result.failure
|
46
|
+
elsif @test_result.failure
|
43
47
|
:failed
|
44
48
|
else
|
45
49
|
:pass
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
49
|
-
def line
|
50
|
-
current_backtrace = backtrace
|
51
|
-
return if current_backtrace.nil?
|
52
|
-
|
53
|
-
row =
|
54
|
-
current_backtrace
|
55
|
-
.map { |row| row.split(':')[0..1] }
|
56
|
-
.detect { |row| row[0] == path }
|
57
|
-
|
58
|
-
return if row.nil?
|
59
|
-
row[1].to_i
|
60
|
-
end
|
61
|
-
|
62
53
|
def time
|
63
|
-
test_result.time
|
54
|
+
@test_result.time
|
64
55
|
end
|
65
56
|
|
66
57
|
def name
|
67
|
-
test_result.name
|
58
|
+
@test_result.name
|
68
59
|
end
|
69
60
|
|
70
61
|
def image
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'minitest'
|
2
2
|
require 'json'
|
3
3
|
require 'blinka_minitest'
|
4
|
+
require 'blinka_client'
|
4
5
|
|
5
6
|
module Minitest
|
6
7
|
def self.plugin_blinka_init(options)
|
@@ -25,15 +26,18 @@ module Minitest
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def report
|
28
|
-
tap_report
|
29
|
-
|
30
|
-
|
29
|
+
tap_report if ENV['BLINKA_TAP']
|
30
|
+
json_report if ENV['BLINKA_JSON'] || ENV['BLINKA_REPORT']
|
31
|
+
BlinkaClient.new.report if ENV['BLINKA_REPORT']
|
32
|
+
rescue BlinkaClient::BlinkaError => error
|
33
|
+
puts(error)
|
34
|
+
ensure
|
31
35
|
super
|
32
36
|
end
|
33
37
|
|
34
38
|
private
|
35
39
|
|
36
|
-
def
|
40
|
+
def json_report
|
37
41
|
result = {
|
38
42
|
total_time: total_time,
|
39
43
|
nbr_tests: count,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blinka-reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Wessman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '13'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.11'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.11'
|
97
111
|
description: Use to format test results from Minitest to use with Blinka.
|
98
112
|
email: david@wessman.co
|
99
113
|
executables: []
|