blinka-reporter 0.3.0 → 0.3.5
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 +34 -23
- data/lib/blinka_minitest.rb +18 -27
- data/lib/blinka_reporter/version.rb +3 -0
- data/lib/minitest/blinka_plugin.rb +19 -3
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18126165bf1e12fccca242964c2086abcab1ad37f1ca6b089b5e02edcb0a64b5
|
4
|
+
data.tar.gz: fc47b4d956f56d7c7572e8fd11b4cd9d119d4e14929ac6f73ba35ee20a66abfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d362519ba45683ad4cddc22c9fbe7e2f5f72e4281ff5369bda0056789b90ae77d3ddf529728a7c5b305d55a633e719a297e6389c79e4f923138311be1777ce75
|
7
|
+
data.tar.gz: 34416bc8b028746deb93b11a684cfed331c0f7fcb0b0210cc216721faec0c41d99caf3b335a9750db3bc11c131850f04964372b50481a680a6cf1368ee7a1649
|
data/lib/blinka_client.rb
CHANGED
@@ -2,23 +2,18 @@ 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
|
-
attr_reader(
|
7
|
-
|
8
|
-
:commit,
|
9
|
-
:host,
|
10
|
-
:repository,
|
11
|
-
:team_id,
|
12
|
-
:team_secret,
|
13
|
-
:jwt_token
|
14
|
-
)
|
10
|
+
attr_reader(:host, :repository, :team_id, :team_secret, :jwt_token)
|
11
|
+
|
15
12
|
def initialize
|
16
|
-
@host = ENV.fetch('BLINKA_HOST',
|
13
|
+
@host = ENV.fetch('BLINKA_HOST', DEFAULT_HOST)
|
17
14
|
@team_id = ENV.fetch('BLINKA_TEAM_ID', nil)
|
18
15
|
@team_secret = ENV.fetch('BLINKA_TEAM_SECRET', nil)
|
19
16
|
@repository = ENV.fetch('BLINKA_REPOSITORY', nil)
|
20
|
-
@tag = ENV.fetch('BLINKA_TAG', '')
|
21
|
-
@commit = ENV.fetch('BLINKA_COMMIT', `git rev-parse HEAD`.chomp)
|
22
17
|
|
23
18
|
if @team_id.nil? || @team_secret.nil? || @repository.nil?
|
24
19
|
raise(BlinkaError, <<~EOS)
|
@@ -32,7 +27,6 @@ class BlinkaClient
|
|
32
27
|
end
|
33
28
|
|
34
29
|
class BlinkaError < StandardError; end
|
35
|
-
include HTTParty
|
36
30
|
|
37
31
|
def initialize
|
38
32
|
@config = BlinkaConfig.new
|
@@ -40,12 +34,18 @@ class BlinkaClient
|
|
40
34
|
end
|
41
35
|
|
42
36
|
def report(filepath: './blinka_results.json')
|
43
|
-
unless File.
|
37
|
+
unless File.exist?(filepath)
|
44
38
|
raise(
|
45
39
|
BlinkaError,
|
46
40
|
'Could not find blinka_results.json, did tests run with environment variable BLINKA_JSON=true set?'
|
47
41
|
)
|
48
42
|
end
|
43
|
+
|
44
|
+
if ENV.fetch('BLINKA_ALLOW_WEBMOCK_DISABLE', 'true') == 'true' &&
|
45
|
+
defined?(WebMock) && WebMock.respond_to?(:disable!)
|
46
|
+
WebMock.disable!
|
47
|
+
end
|
48
|
+
|
49
49
|
self.authenticate
|
50
50
|
data = JSON.parse(File.open(filepath).read)
|
51
51
|
|
@@ -65,13 +65,13 @@ class BlinkaClient
|
|
65
65
|
body = {
|
66
66
|
report: {
|
67
67
|
repository: @config.repository,
|
68
|
-
tag:
|
69
|
-
commit:
|
68
|
+
tag: data['tag'],
|
69
|
+
commit: data['commit'],
|
70
70
|
metadata: {
|
71
|
-
total_time: data
|
72
|
-
nbr_tests: data
|
73
|
-
nbr_assertions: data
|
74
|
-
seed: data
|
71
|
+
total_time: data['total_time'],
|
72
|
+
nbr_tests: data['nbr_tests'],
|
73
|
+
nbr_assertions: data['nbr_assertions'],
|
74
|
+
seed: data['seed']
|
75
75
|
}.compact,
|
76
76
|
results: results
|
77
77
|
}
|
@@ -88,12 +88,23 @@ class BlinkaClient
|
|
88
88
|
)
|
89
89
|
case response.code
|
90
90
|
when 200
|
91
|
-
puts "Reported #{data
|
92
|
-
@config.commit
|
93
|
-
}!"
|
91
|
+
puts "Reported #{data['nbr_tests']} tests of commit #{data['commit']}!"
|
94
92
|
else
|
95
93
|
raise(BlinkaError, "Could not report, got response code #{response.code}")
|
96
94
|
end
|
95
|
+
rescue => error
|
96
|
+
raise(BlinkaError, <<-EOS)
|
97
|
+
BLINKA:
|
98
|
+
Failed to create report because of #{error.class} with message:
|
99
|
+
#{error.message}
|
100
|
+
EOS
|
101
|
+
ensure
|
102
|
+
WebMock.enable! if defined?(WebMock) && WebMock.respond_to?(:enable!)
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.report(filepath: './blinka_results.json')
|
106
|
+
client = BlinkaClient.new
|
107
|
+
client.report(filepath: filepath)
|
97
108
|
end
|
98
109
|
|
99
110
|
def self.upload_image(filepath:)
|
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,10 +26,13 @@ module Minitest
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def report
|
28
|
-
tap_report unless ENV['BLINKA_TAP'].nil?
|
29
|
-
json_report unless ENV['BLINKA_JSON'].nil?
|
30
|
-
|
31
29
|
super
|
30
|
+
|
31
|
+
tap_report if ENV['BLINKA_TAP']
|
32
|
+
json_report if ENV['BLINKA_JSON'] || ENV['BLINKA_REPORT']
|
33
|
+
BlinkaClient.new.report if ENV['BLINKA_REPORT']
|
34
|
+
rescue BlinkaClient::BlinkaError => error
|
35
|
+
puts(error)
|
32
36
|
end
|
33
37
|
|
34
38
|
private
|
@@ -38,6 +42,8 @@ module Minitest
|
|
38
42
|
total_time: total_time,
|
39
43
|
nbr_tests: count,
|
40
44
|
nbr_assertions: assertions,
|
45
|
+
commit: find_commit,
|
46
|
+
tag: ENV.fetch('BLINKA_TAG', ''),
|
41
47
|
seed: options[:seed],
|
42
48
|
results:
|
43
49
|
tests.map { |test_result| BlinkaMinitest.new(test_result).report }
|
@@ -79,6 +85,16 @@ module Minitest
|
|
79
85
|
def print_padded_comment(line)
|
80
86
|
puts "##{' ' * TAP_COMMENT_PAD + line}"
|
81
87
|
end
|
88
|
+
|
89
|
+
def find_commit
|
90
|
+
ENV.fetch(
|
91
|
+
'BLINKA_COMMIT',
|
92
|
+
ENV.fetch(
|
93
|
+
'HEROKU_TEST_RUN_COMMIT_VERSION',
|
94
|
+
`git rev-parse HEAD`.chomp
|
95
|
+
)
|
96
|
+
)
|
97
|
+
end
|
82
98
|
end
|
83
99
|
end
|
84
100
|
end
|
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.3.
|
4
|
+
version: 0.3.5
|
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-
|
11
|
+
date: 2021-03-11 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: []
|
@@ -102,11 +116,17 @@ extra_rdoc_files: []
|
|
102
116
|
files:
|
103
117
|
- lib/blinka_client.rb
|
104
118
|
- lib/blinka_minitest.rb
|
119
|
+
- lib/blinka_reporter/version.rb
|
105
120
|
- lib/minitest/blinka_plugin.rb
|
106
121
|
homepage: https://github.com/davidwessman/blinka_reporter
|
107
122
|
licenses:
|
108
123
|
- MIT
|
109
|
-
metadata:
|
124
|
+
metadata:
|
125
|
+
homepage_uri: https://github.com/davidwessman/blinka_reporter
|
126
|
+
bug_tracker_uri: https://github.com/davidwessman/blinka_reporter/issues
|
127
|
+
documentation_uri: https://github.com/davidwessman/blinka_reporter
|
128
|
+
changelog_uri: https://github.com/davidwessman/blinka_reporter/main/CHANGELOG.md
|
129
|
+
source_code_uri: https://github.com/davidwessman/blinka_reporter
|
110
130
|
post_install_message:
|
111
131
|
rdoc_options: []
|
112
132
|
require_paths:
|