blinka-reporter 0.3.2 → 0.4.0
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 +16 -22
- data/lib/blinka_minitest.rb +19 -28
- data/lib/blinka_reporter/version.rb +3 -0
- data/lib/minitest/blinka_plugin.rb +14 -2
- metadata +12 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad98fd45f2147f5fd55ca1d55c6f672feacbe41ac3b76b192ac6080992901107
|
4
|
+
data.tar.gz: 36abc057b50457b372f1edea9d1e6fadb3088ccf6e9f21db2da2be10d804bfb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65e2258b6777627483a15f3b1b1d3a8abf3ad5b8f0d88b71f1b32c9745d22cbc6da165864074e00338bb0479c352305ca8841cc242936c4b1bd7a6cc42e43af8
|
7
|
+
data.tar.gz: a5bd248c55c5a164970326fe24a8277ea6b869ad9fab6f9fecab786166c9dc5e982521f2fea5ba9c18408a7023ff3cc39a41af83c67f56996205713e6fc567bf
|
data/lib/blinka_client.rb
CHANGED
@@ -1,29 +1,23 @@
|
|
1
|
-
require 'mimemagic'
|
2
1
|
require 'httparty'
|
3
2
|
|
4
3
|
class BlinkaClient
|
5
4
|
DEFAULT_HOST = 'https://www.blinka.app'.freeze
|
5
|
+
SUPPORTED_MIME_TYPES = {
|
6
|
+
jpg: 'image/jpeg',
|
7
|
+
jpeg: 'image/jpeg',
|
8
|
+
png: 'image/png'
|
9
|
+
}
|
6
10
|
|
7
11
|
include HTTParty
|
8
12
|
|
9
13
|
class BlinkaConfig
|
10
|
-
attr_reader(
|
11
|
-
:tag,
|
12
|
-
:commit,
|
13
|
-
:host,
|
14
|
-
:repository,
|
15
|
-
:team_id,
|
16
|
-
:team_secret,
|
17
|
-
:jwt_token
|
18
|
-
)
|
14
|
+
attr_reader(:host, :repository, :team_id, :team_secret, :jwt_token)
|
19
15
|
|
20
16
|
def initialize
|
21
17
|
@host = ENV.fetch('BLINKA_HOST', DEFAULT_HOST)
|
22
18
|
@team_id = ENV.fetch('BLINKA_TEAM_ID', nil)
|
23
19
|
@team_secret = ENV.fetch('BLINKA_TEAM_SECRET', nil)
|
24
20
|
@repository = ENV.fetch('BLINKA_REPOSITORY', nil)
|
25
|
-
@tag = ENV.fetch('BLINKA_TAG', '')
|
26
|
-
@commit = ENV.fetch('BLINKA_COMMIT', `git rev-parse HEAD`.chomp)
|
27
21
|
|
28
22
|
if @team_id.nil? || @team_secret.nil? || @repository.nil?
|
29
23
|
raise(BlinkaError, <<~EOS)
|
@@ -75,13 +69,13 @@ class BlinkaClient
|
|
75
69
|
body = {
|
76
70
|
report: {
|
77
71
|
repository: @config.repository,
|
78
|
-
tag:
|
79
|
-
commit:
|
72
|
+
tag: data['tag'],
|
73
|
+
commit: data['commit'],
|
80
74
|
metadata: {
|
81
|
-
total_time: data
|
82
|
-
nbr_tests: data
|
83
|
-
nbr_assertions: data
|
84
|
-
seed: data
|
75
|
+
total_time: data['total_time'],
|
76
|
+
nbr_tests: data['nbr_tests'],
|
77
|
+
nbr_assertions: data['nbr_assertions'],
|
78
|
+
seed: data['seed']
|
85
79
|
}.compact,
|
86
80
|
results: results
|
87
81
|
}
|
@@ -98,9 +92,7 @@ class BlinkaClient
|
|
98
92
|
)
|
99
93
|
case response.code
|
100
94
|
when 200
|
101
|
-
puts "Reported #{data
|
102
|
-
@config.commit
|
103
|
-
}!"
|
95
|
+
puts "Reported #{data['nbr_tests']} tests of commit #{data['commit']}!"
|
104
96
|
else
|
105
97
|
raise(BlinkaError, "Could not report, got response code #{response.code}")
|
106
98
|
end
|
@@ -124,7 +116,9 @@ class BlinkaClient
|
|
124
116
|
|
125
117
|
file = File.open(filepath)
|
126
118
|
filename = File.basename(filepath)
|
127
|
-
|
119
|
+
extension = File.extname(filepath).delete('.').to_sym
|
120
|
+
content_type = SUPPORTED_MIME_TYPES[extension]
|
121
|
+
return if content_type.nil?
|
128
122
|
|
129
123
|
presigned_post =
|
130
124
|
BlinkaClient.presign_image(filename: filename, content_type: content_type)
|
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
|
43
|
-
:
|
46
|
+
elsif @test_result.failure
|
47
|
+
:fail
|
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
|
@@ -26,13 +26,13 @@ module Minitest
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def report
|
29
|
+
super
|
30
|
+
|
29
31
|
tap_report if ENV['BLINKA_TAP']
|
30
32
|
json_report if ENV['BLINKA_JSON'] || ENV['BLINKA_REPORT']
|
31
33
|
BlinkaClient.new.report if ENV['BLINKA_REPORT']
|
32
34
|
rescue BlinkaClient::BlinkaError => error
|
33
35
|
puts(error)
|
34
|
-
ensure
|
35
|
-
super
|
36
36
|
end
|
37
37
|
|
38
38
|
private
|
@@ -42,6 +42,8 @@ module Minitest
|
|
42
42
|
total_time: total_time,
|
43
43
|
nbr_tests: count,
|
44
44
|
nbr_assertions: assertions,
|
45
|
+
commit: find_commit,
|
46
|
+
tag: ENV.fetch('BLINKA_TAG', ''),
|
45
47
|
seed: options[:seed],
|
46
48
|
results:
|
47
49
|
tests.map { |test_result| BlinkaMinitest.new(test_result).report }
|
@@ -83,6 +85,16 @@ module Minitest
|
|
83
85
|
def print_padded_comment(line)
|
84
86
|
puts "##{' ' * TAP_COMMENT_PAD + line}"
|
85
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
|
86
98
|
end
|
87
99
|
end
|
88
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Wessman
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.18.1
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: mimemagic
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.3.5
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.3.5
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: dotenv
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,12 +102,18 @@ extra_rdoc_files: []
|
|
116
102
|
files:
|
117
103
|
- lib/blinka_client.rb
|
118
104
|
- lib/blinka_minitest.rb
|
105
|
+
- lib/blinka_reporter/version.rb
|
119
106
|
- lib/minitest/blinka_plugin.rb
|
120
107
|
homepage: https://github.com/davidwessman/blinka_reporter
|
121
108
|
licenses:
|
122
109
|
- MIT
|
123
|
-
metadata:
|
124
|
-
|
110
|
+
metadata:
|
111
|
+
homepage_uri: https://github.com/davidwessman/blinka_reporter
|
112
|
+
bug_tracker_uri: https://github.com/davidwessman/blinka_reporter/issues
|
113
|
+
documentation_uri: https://github.com/davidwessman/blinka_reporter
|
114
|
+
changelog_uri: https://github.com/davidwessman/blinka_reporter/main/CHANGELOG.md
|
115
|
+
source_code_uri: https://github.com/davidwessman/blinka_reporter
|
116
|
+
post_install_message:
|
125
117
|
rdoc_options: []
|
126
118
|
require_paths:
|
127
119
|
- lib
|
@@ -137,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
129
|
version: '0'
|
138
130
|
requirements: []
|
139
131
|
rubygems_version: 3.2.7
|
140
|
-
signing_key:
|
132
|
+
signing_key:
|
141
133
|
specification_version: 4
|
142
134
|
summary: Format tests for Blinka
|
143
135
|
test_files: []
|