blinka-reporter 0.3.4 → 0.5.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 -29
- data/lib/blinka_minitest.rb +1 -1
- data/lib/blinka_reporter/version.rb +3 -0
- data/lib/minitest/blinka_plugin.rb +43 -6
- metadata +19 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d0803a1ef9055ba4f96126c073557f1c609fa7744cfeaecf05434bc43bc49a
|
4
|
+
data.tar.gz: b6474ced0df1e5021351f4e1cede83eb4102450750b832845d63d49d534b018d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e158fe5fc61ed571aaea0d0ebd45050731c41db9b148db1e3524ad54e3d345f430892109039228bc338d79d0a79d98ecbfc9bd7e5420c341eebabfa7abd3458b
|
7
|
+
data.tar.gz: e0210373323a0b51bf37d01ddbe7ddf7fdef61c966884296ef52d5ad79faf5f832900b5357276365291e76f72db844c0045e6984fc728089aeea769cf2b5c01f
|
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 = BlinkaClient.find_commit
|
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)
|
@@ -198,11 +192,4 @@ class BlinkaClient
|
|
198
192
|
}
|
199
193
|
}
|
200
194
|
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
|
208
195
|
end
|
data/lib/blinka_minitest.rb
CHANGED
@@ -11,6 +11,7 @@ module Minitest
|
|
11
11
|
def plugin_blinka_options(opts, options); end
|
12
12
|
|
13
13
|
module BlinkaPlugin
|
14
|
+
REPORT_PATH = 'blinka_results.json'.freeze
|
14
15
|
TAP_COMMENT_PAD = 8
|
15
16
|
class Reporter < Minitest::StatisticsReporter
|
16
17
|
attr_accessor :tests
|
@@ -26,32 +27,38 @@ module Minitest
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def report
|
30
|
+
super
|
31
|
+
|
29
32
|
tap_report if ENV['BLINKA_TAP']
|
30
|
-
|
33
|
+
if ENV['BLINKA_JSON'] || ENV['BLINKA_REPORT']
|
34
|
+
json_report(append: !ENV['BLINKA_APPEND'].nil?)
|
35
|
+
end
|
31
36
|
BlinkaClient.new.report if ENV['BLINKA_REPORT']
|
32
37
|
rescue BlinkaClient::BlinkaError => error
|
33
38
|
puts(error)
|
34
|
-
ensure
|
35
|
-
super
|
36
39
|
end
|
37
40
|
|
38
41
|
private
|
39
42
|
|
40
|
-
def json_report
|
43
|
+
def json_report(append:)
|
41
44
|
result = {
|
42
45
|
total_time: total_time,
|
43
46
|
nbr_tests: count,
|
44
47
|
nbr_assertions: assertions,
|
48
|
+
commit: find_commit,
|
49
|
+
tag: ENV.fetch('BLINKA_TAG', ''),
|
45
50
|
seed: options[:seed],
|
46
51
|
results:
|
47
52
|
tests.map { |test_result| BlinkaMinitest.new(test_result).report }
|
48
53
|
}
|
54
|
+
result = append_previous(result) if append
|
49
55
|
|
50
|
-
File.open(
|
56
|
+
File.open(REPORT_PATH, 'w+') do |file|
|
51
57
|
file.write(JSON.pretty_generate(result))
|
52
58
|
end
|
59
|
+
|
53
60
|
puts
|
54
|
-
puts(
|
61
|
+
puts("Test results written to `#{REPORT_PATH}`")
|
55
62
|
end
|
56
63
|
|
57
64
|
# Based on https://github.com/kern/minitest-reporters/blob/master/lib/minitest/reporters/progress_reporter.rb
|
@@ -83,6 +90,36 @@ module Minitest
|
|
83
90
|
def print_padded_comment(line)
|
84
91
|
puts "##{' ' * TAP_COMMENT_PAD + line}"
|
85
92
|
end
|
93
|
+
|
94
|
+
def find_commit
|
95
|
+
ENV.fetch(
|
96
|
+
'BLINKA_COMMIT',
|
97
|
+
ENV.fetch(
|
98
|
+
'HEROKU_TEST_RUN_COMMIT_VERSION',
|
99
|
+
`git rev-parse HEAD`.chomp
|
100
|
+
)
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def parse_report
|
107
|
+
return unless File.exist?(REPORT_PATH)
|
108
|
+
JSON.parse(File.read(REPORT_PATH))
|
109
|
+
end
|
110
|
+
|
111
|
+
def append_previous(result)
|
112
|
+
previous = parse_report
|
113
|
+
return if previous.nil?
|
114
|
+
return if result[:commit] != previous['commit']
|
115
|
+
return if result[:tag] != previous['tag']
|
116
|
+
|
117
|
+
result[:total_time] += previous['total_time'] || 0
|
118
|
+
result[:nbr_tests] += previous['nbr_tests'] || 0
|
119
|
+
result[:nbr_assertions] += previous['nbr_assertions'] || 0
|
120
|
+
result[:results] += previous['results'] || []
|
121
|
+
result
|
122
|
+
end
|
86
123
|
end
|
87
124
|
end
|
88
125
|
end
|
metadata
CHANGED
@@ -1,43 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blinka-reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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:
|
11
|
+
date: 2022-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.18.1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.21.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.18.1
|
27
|
-
-
|
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
|
-
- - "~>"
|
30
|
+
- - "<"
|
39
31
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
32
|
+
version: 0.21.0
|
41
33
|
- !ruby/object:Gem::Dependency
|
42
34
|
name: dotenv
|
43
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,12 +108,18 @@ extra_rdoc_files: []
|
|
116
108
|
files:
|
117
109
|
- lib/blinka_client.rb
|
118
110
|
- lib/blinka_minitest.rb
|
111
|
+
- lib/blinka_reporter/version.rb
|
119
112
|
- lib/minitest/blinka_plugin.rb
|
120
113
|
homepage: https://github.com/davidwessman/blinka_reporter
|
121
114
|
licenses:
|
122
115
|
- MIT
|
123
|
-
metadata:
|
124
|
-
|
116
|
+
metadata:
|
117
|
+
homepage_uri: https://github.com/davidwessman/blinka_reporter
|
118
|
+
bug_tracker_uri: https://github.com/davidwessman/blinka_reporter/issues
|
119
|
+
documentation_uri: https://github.com/davidwessman/blinka_reporter
|
120
|
+
changelog_uri: https://github.com/davidwessman/blinka_reporter/main/CHANGELOG.md
|
121
|
+
source_code_uri: https://github.com/davidwessman/blinka_reporter
|
122
|
+
post_install_message:
|
125
123
|
rdoc_options: []
|
126
124
|
require_paths:
|
127
125
|
- lib
|
@@ -137,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
135
|
version: '0'
|
138
136
|
requirements: []
|
139
137
|
rubygems_version: 3.2.7
|
140
|
-
signing_key:
|
138
|
+
signing_key:
|
141
139
|
specification_version: 4
|
142
140
|
summary: Format tests for Blinka
|
143
141
|
test_files: []
|