blinka-reporter 0.7.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/main.yml +3 -3
- data/.husky/pre-commit +4 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/README.md +9 -8
- data/Rakefile +4 -4
- data/blinka_reporter.gemspec +26 -28
- data/lib/blinka_reporter/cli.rb +6 -35
- data/lib/blinka_reporter/client.rb +23 -26
- data/lib/blinka_reporter/error.rb +2 -1
- data/lib/blinka_reporter/minitest_adapter.rb +10 -7
- data/lib/blinka_reporter/tap.rb +11 -11
- data/lib/blinka_reporter/version.rb +1 -1
- data/lib/blinka_reporter.rb +4 -3
- data/lib/minitest/blinka_plugin.rb +26 -15
- data/package.json +9 -7
- data/yarn.lock +178 -428
- metadata +22 -33
- data/lib/blinka_reporter/blinka.rb +0 -172
- data/lib/blinka_reporter/config.rb +0 -37
metadata
CHANGED
|
@@ -1,29 +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: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Wessman
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: httparty
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0.18'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0.18'
|
|
27
12
|
- !ruby/object:Gem::Dependency
|
|
28
13
|
name: ox
|
|
29
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,28 +29,34 @@ dependencies:
|
|
|
44
29
|
requirements:
|
|
45
30
|
- - "~>"
|
|
46
31
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
32
|
+
version: 3.0.0
|
|
48
33
|
type: :development
|
|
49
34
|
prerelease: false
|
|
50
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
36
|
requirements:
|
|
52
37
|
- - "~>"
|
|
53
38
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
39
|
+
version: 3.0.0
|
|
55
40
|
- !ruby/object:Gem::Dependency
|
|
56
41
|
name: minitest
|
|
57
42
|
requirement: !ruby/object:Gem::Requirement
|
|
58
43
|
requirements:
|
|
59
|
-
- - "
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '5'
|
|
47
|
+
- - "<"
|
|
60
48
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
49
|
+
version: '7'
|
|
62
50
|
type: :development
|
|
63
51
|
prerelease: false
|
|
64
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
53
|
requirements:
|
|
66
|
-
- - "
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '5'
|
|
57
|
+
- - "<"
|
|
67
58
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
59
|
+
version: '7'
|
|
69
60
|
- !ruby/object:Gem::Dependency
|
|
70
61
|
name: mocha
|
|
71
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -95,19 +86,19 @@ dependencies:
|
|
|
95
86
|
- !ruby/object:Gem::Version
|
|
96
87
|
version: '13'
|
|
97
88
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
89
|
+
name: standard
|
|
99
90
|
requirement: !ruby/object:Gem::Requirement
|
|
100
91
|
requirements:
|
|
101
|
-
- - "
|
|
92
|
+
- - ">="
|
|
102
93
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
94
|
+
version: '0'
|
|
104
95
|
type: :development
|
|
105
96
|
prerelease: false
|
|
106
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
98
|
requirements:
|
|
108
|
-
- - "
|
|
99
|
+
- - ">="
|
|
109
100
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
101
|
+
version: '0'
|
|
111
102
|
description: Use to format test results from Minitest to use with Blinka.
|
|
112
103
|
email: david@wessman.co
|
|
113
104
|
executables:
|
|
@@ -119,7 +110,9 @@ files:
|
|
|
119
110
|
- ".github/release.yml"
|
|
120
111
|
- ".github/workflows/main.yml"
|
|
121
112
|
- ".gitignore"
|
|
113
|
+
- ".husky/pre-commit"
|
|
122
114
|
- ".ruby-version"
|
|
115
|
+
- ".tool-versions"
|
|
123
116
|
- CHANGELOG.md
|
|
124
117
|
- Gemfile
|
|
125
118
|
- LICENSE
|
|
@@ -129,10 +122,8 @@ files:
|
|
|
129
122
|
- bin/setup
|
|
130
123
|
- blinka_reporter.gemspec
|
|
131
124
|
- lib/blinka_reporter.rb
|
|
132
|
-
- lib/blinka_reporter/blinka.rb
|
|
133
125
|
- lib/blinka_reporter/cli.rb
|
|
134
126
|
- lib/blinka_reporter/client.rb
|
|
135
|
-
- lib/blinka_reporter/config.rb
|
|
136
127
|
- lib/blinka_reporter/error.rb
|
|
137
128
|
- lib/blinka_reporter/minitest_adapter.rb
|
|
138
129
|
- lib/blinka_reporter/tap.rb
|
|
@@ -150,7 +141,6 @@ metadata:
|
|
|
150
141
|
changelog_uri: https://github.com/davidwessman/blinka_reporter/main/CHANGELOG.md
|
|
151
142
|
source_code_uri: https://github.com/davidwessman/blinka_reporter
|
|
152
143
|
rubygems_mfa_required: 'true'
|
|
153
|
-
post_install_message:
|
|
154
144
|
rdoc_options: []
|
|
155
145
|
require_paths:
|
|
156
146
|
- lib
|
|
@@ -165,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
155
|
- !ruby/object:Gem::Version
|
|
166
156
|
version: '0'
|
|
167
157
|
requirements: []
|
|
168
|
-
rubygems_version: 3.
|
|
169
|
-
signing_key:
|
|
158
|
+
rubygems_version: 3.6.9
|
|
170
159
|
specification_version: 4
|
|
171
160
|
summary: Format tests for Blinka
|
|
172
161
|
test_files: []
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
require 'httparty'
|
|
2
|
-
require 'blinka_reporter/error'
|
|
3
|
-
|
|
4
|
-
module BlinkaReporter
|
|
5
|
-
class Blinka
|
|
6
|
-
SUPPORTED_MIME_TYPES = {
|
|
7
|
-
jpg: 'image/jpeg',
|
|
8
|
-
jpeg: 'image/jpeg',
|
|
9
|
-
png: 'image/png'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
include HTTParty
|
|
13
|
-
|
|
14
|
-
def self.report(data:, config:)
|
|
15
|
-
Blinka.new(data: data, config: config).report
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def initialize(data:, config:)
|
|
19
|
-
@data = data
|
|
20
|
-
@config = config
|
|
21
|
-
self.class.base_uri("#{@config.host}/api/v1")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def report
|
|
25
|
-
if ENV.fetch('BLINKA_ALLOW_WEBMOCK_DISABLE', 'true') == 'true' &&
|
|
26
|
-
defined?(WebMock) && WebMock.respond_to?(:disable!)
|
|
27
|
-
WebMock.disable!
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
@config.validate_blinka
|
|
31
|
-
self.authenticate
|
|
32
|
-
|
|
33
|
-
results =
|
|
34
|
-
@data
|
|
35
|
-
.fetch(:results, [])
|
|
36
|
-
.map do |result|
|
|
37
|
-
if !result[:image].nil?
|
|
38
|
-
result[:image] = Blinka.upload_image(filepath: result[:image])
|
|
39
|
-
result
|
|
40
|
-
else
|
|
41
|
-
result
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
body = {
|
|
46
|
-
report: {
|
|
47
|
-
repository: @config.repository,
|
|
48
|
-
tag: @config.tag,
|
|
49
|
-
commit: @config.commit,
|
|
50
|
-
metadata: {
|
|
51
|
-
total_time: @data[:total_time],
|
|
52
|
-
nbr_tests: @data[:nbr_tests],
|
|
53
|
-
nbr_assertions: @data[:nbr_assertions],
|
|
54
|
-
seed: @data[:seed]
|
|
55
|
-
}.compact,
|
|
56
|
-
results: results
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
response =
|
|
61
|
-
self.class.post(
|
|
62
|
-
'/report',
|
|
63
|
-
body: body.to_json,
|
|
64
|
-
headers: {
|
|
65
|
-
'Content-Type' => 'application/json',
|
|
66
|
-
'Authorization' => "Bearer #{@jwt_token}"
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
case response.code
|
|
70
|
-
when 200
|
|
71
|
-
puts "Reported #{@data[:nbr_tests]} tests of commit #{@config.commit}!"
|
|
72
|
-
else
|
|
73
|
-
raise(
|
|
74
|
-
BlinkaReporter::Error,
|
|
75
|
-
"Could not report, got response code #{response.code}"
|
|
76
|
-
)
|
|
77
|
-
end
|
|
78
|
-
rescue => error
|
|
79
|
-
raise(BlinkaReporter::Error, <<-EOS)
|
|
80
|
-
BLINKA:
|
|
81
|
-
Failed to create report because of #{error.class} with message:
|
|
82
|
-
#{error.message}
|
|
83
|
-
EOS
|
|
84
|
-
ensure
|
|
85
|
-
WebMock.enable! if defined?(WebMock) && WebMock.respond_to?(:enable!)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def authenticate
|
|
89
|
-
response =
|
|
90
|
-
self.class.post(
|
|
91
|
-
'/authentication',
|
|
92
|
-
body: {
|
|
93
|
-
token_id: @config.team_id,
|
|
94
|
-
token_secret: @config.team_secret
|
|
95
|
-
}.to_json,
|
|
96
|
-
headers: { 'Content-Type' => 'application/json' }
|
|
97
|
-
)
|
|
98
|
-
case response.code
|
|
99
|
-
when 200
|
|
100
|
-
@jwt_token = JSON.parse(response.body).dig('auth_token')
|
|
101
|
-
else
|
|
102
|
-
raise(
|
|
103
|
-
BlinkaReporter::Error,
|
|
104
|
-
"Could not authenticate to API #{response.code}"
|
|
105
|
-
)
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def self.upload_image(filepath:)
|
|
110
|
-
return unless File.exist?(filepath)
|
|
111
|
-
|
|
112
|
-
file = File.open(filepath)
|
|
113
|
-
filename = File.basename(filepath)
|
|
114
|
-
extension = File.extname(filepath).delete('.').to_sym
|
|
115
|
-
content_type = SUPPORTED_MIME_TYPES[extension]
|
|
116
|
-
return if content_type.nil?
|
|
117
|
-
|
|
118
|
-
presigned_post =
|
|
119
|
-
Blinka.presign_image(filename: filename, content_type: content_type)
|
|
120
|
-
Blinka.upload_to_storage(presigned_post: presigned_post, file: file)
|
|
121
|
-
|
|
122
|
-
puts "Uploaded: #{filename}"
|
|
123
|
-
Blinka.to_shrine_object(
|
|
124
|
-
presigned_post: presigned_post,
|
|
125
|
-
file: file,
|
|
126
|
-
filename: filename
|
|
127
|
-
)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def self.presign_image(filename:, content_type:)
|
|
131
|
-
response =
|
|
132
|
-
self.get(
|
|
133
|
-
'/presign',
|
|
134
|
-
body: { filename: filename, content_type: content_type }
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
case response.code
|
|
138
|
-
when 200
|
|
139
|
-
JSON.parse(response.body)
|
|
140
|
-
else
|
|
141
|
-
raise(BlinkaReporter::Error, 'Could not presign file')
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def self.upload_to_storage(presigned_post:, file:)
|
|
146
|
-
url = URI.parse(presigned_post.fetch('url'))
|
|
147
|
-
|
|
148
|
-
body = presigned_post['fields'].merge({ 'file' => file.read })
|
|
149
|
-
response = HTTParty.post(url, multipart: true, body: body)
|
|
150
|
-
|
|
151
|
-
case response.code
|
|
152
|
-
when 204
|
|
153
|
-
true
|
|
154
|
-
else
|
|
155
|
-
raise(BlinkaReporter::Error, 'Could not upload file to storage')
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def self.to_shrine_object(presigned_post:, file:, filename:)
|
|
160
|
-
storage, idx = presigned_post.dig('fields', 'key').split('/')
|
|
161
|
-
{
|
|
162
|
-
"id": idx,
|
|
163
|
-
"storage": storage,
|
|
164
|
-
"metadata": {
|
|
165
|
-
"size": file.size,
|
|
166
|
-
"filename": filename,
|
|
167
|
-
"mime_type": presigned_post.dig('fields', 'Content-Type')
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'blinka_reporter/error'
|
|
2
|
-
|
|
3
|
-
module BlinkaReporter
|
|
4
|
-
class Config
|
|
5
|
-
attr_reader(:commit, :host, :repository, :tag, :team_id, :team_secret)
|
|
6
|
-
DEFAULT_HOST = 'https://www.blinka.app'
|
|
7
|
-
|
|
8
|
-
def initialize(
|
|
9
|
-
tag:,
|
|
10
|
-
commit:,
|
|
11
|
-
repository:,
|
|
12
|
-
host: nil,
|
|
13
|
-
team_id:,
|
|
14
|
-
team_secret:
|
|
15
|
-
)
|
|
16
|
-
@commit = commit || find_commit
|
|
17
|
-
@host = host || DEFAULT_HOST
|
|
18
|
-
@repository = repository
|
|
19
|
-
@tag = tag
|
|
20
|
-
@team_id = team_id
|
|
21
|
-
@team_secret = team_secret
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def validate_blinka
|
|
25
|
-
required = [@team_id, @team_secret, @repository]
|
|
26
|
-
if required.include?(nil) || required.include?('')
|
|
27
|
-
raise(BlinkaReporter::Error, <<~EOS)
|
|
28
|
-
Missing configuration, make sure to set --team-id, --team-secret, --repository
|
|
29
|
-
EOS
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def find_commit
|
|
34
|
-
ENV.fetch('HEROKU_TEST_RUN_COMMIT_VERSION', `git rev-parse HEAD`.chomp)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|