blinka-reporter 0.0.3 → 0.3.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/lib/blinka_client.rb +22 -7
- data/lib/minitest/blinka_plugin.rb +38 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fa8216d86cce40da5c4c423b473dcb6956302b017807ab383d93b94c32484fe
|
4
|
+
data.tar.gz: 1eabf2319cedab3b2378e087c66b36974fdc4dc0753ebd7cdb95f50300ac5df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 259de1e1edf5332fa682d95444a081d85cd2f55416ce183a92e4109822735ff594f70885cf3307d3045f8c7f9df73bc874a1ca7abb20523cd7e00980cbf3a6c5
|
7
|
+
data.tar.gz: b18f0a91507350ad8023894b7d237aab25a92683db6963c651d9267d316315a8f5233dcbc361355bd21e21530c181df4a318e7a1a3a353b5290d45bacaf817a4
|
data/lib/blinka_client.rb
CHANGED
@@ -4,7 +4,7 @@ require 'httparty'
|
|
4
4
|
class BlinkaClient
|
5
5
|
class BlinkaConfig
|
6
6
|
attr_reader(
|
7
|
-
:
|
7
|
+
:tag,
|
8
8
|
:commit,
|
9
9
|
:host,
|
10
10
|
:repository,
|
@@ -13,12 +13,21 @@ class BlinkaClient
|
|
13
13
|
:jwt_token
|
14
14
|
)
|
15
15
|
def initialize
|
16
|
-
@host = ENV.fetch('BLINKA_HOST', 'https://
|
17
|
-
@team_id = ENV.fetch('BLINKA_TEAM_ID')
|
18
|
-
@team_secret = ENV.fetch('BLINKA_TEAM_SECRET')
|
19
|
-
@repository = ENV.fetch('BLINKA_REPOSITORY')
|
20
|
-
@
|
16
|
+
@host = ENV.fetch('BLINKA_HOST', 'https://www.blinka.app')
|
17
|
+
@team_id = ENV.fetch('BLINKA_TEAM_ID', nil)
|
18
|
+
@team_secret = ENV.fetch('BLINKA_TEAM_SECRET', nil)
|
19
|
+
@repository = ENV.fetch('BLINKA_REPOSITORY', nil)
|
20
|
+
@tag = ENV.fetch('BLINKA_TAG', '')
|
21
21
|
@commit = ENV.fetch('BLINKA_COMMIT', `git rev-parse HEAD`.chomp)
|
22
|
+
|
23
|
+
if @team_id.nil? || @team_secret.nil? || @repository.nil?
|
24
|
+
raise(BlinkaError, <<~EOS)
|
25
|
+
Missing configuration, make sure to set required environment variables:
|
26
|
+
- BLINKA_TEAM_ID
|
27
|
+
- BLINKA_TEAM_SECRET
|
28
|
+
- BLINKA_REPOSITORY
|
29
|
+
EOS
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
@@ -31,6 +40,12 @@ class BlinkaClient
|
|
31
40
|
end
|
32
41
|
|
33
42
|
def report(filepath: './blinka_results.json')
|
43
|
+
unless File.exists?(filepath)
|
44
|
+
raise(
|
45
|
+
BlinkaError,
|
46
|
+
'Could not find blinka_results.json, did tests run with environment variable BLINKA_JSON=true set?'
|
47
|
+
)
|
48
|
+
end
|
34
49
|
self.authenticate
|
35
50
|
data = JSON.parse(File.open(filepath).read)
|
36
51
|
|
@@ -50,7 +65,7 @@ class BlinkaClient
|
|
50
65
|
body = {
|
51
66
|
report: {
|
52
67
|
repository: @config.repository,
|
53
|
-
|
68
|
+
tag: @config.tag,
|
54
69
|
commit: @config.commit,
|
55
70
|
metadata: {
|
56
71
|
total_time: data.dig('total_time'),
|
@@ -10,6 +10,7 @@ module Minitest
|
|
10
10
|
def plugin_blinka_options(opts, options); end
|
11
11
|
|
12
12
|
module BlinkaPlugin
|
13
|
+
TAP_COMMENT_PAD = 8
|
13
14
|
class Reporter < Minitest::StatisticsReporter
|
14
15
|
attr_accessor :tests
|
15
16
|
|
@@ -24,8 +25,15 @@ module Minitest
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def report
|
28
|
+
tap_report unless ENV['BLINKA_TAP'].nil?
|
29
|
+
json_report unless ENV['BLINKA_JSON'].nil?
|
30
|
+
|
27
31
|
super
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
28
35
|
|
36
|
+
def json_report
|
29
37
|
result = {
|
30
38
|
total_time: total_time,
|
31
39
|
nbr_tests: count,
|
@@ -41,6 +49,36 @@ module Minitest
|
|
41
49
|
puts
|
42
50
|
puts('Test results written to `./blinka_results.json`')
|
43
51
|
end
|
52
|
+
|
53
|
+
# Based on https://github.com/kern/minitest-reporters/blob/master/lib/minitest/reporters/progress_reporter.rb
|
54
|
+
# Tries to adhere to https://testanything.org/tap-specification.html
|
55
|
+
def tap_report
|
56
|
+
puts
|
57
|
+
puts('TAP version 13')
|
58
|
+
puts("1..#{tests.length}")
|
59
|
+
tests.each_with_index do |test, index|
|
60
|
+
blinka = BlinkaMinitest.new(test)
|
61
|
+
test_str = "#{blinka.path} - #{test.name.tr('#', '_')}"
|
62
|
+
if test.passed?
|
63
|
+
puts "ok #{index + 1} - #{test_str}"
|
64
|
+
elsif test.skipped?
|
65
|
+
puts "ok #{index + 1} # skip: #{test_str}"
|
66
|
+
elsif test.failure
|
67
|
+
puts "not ok #{index + 1} - failed: #{test_str}"
|
68
|
+
blinka.message.each_line { |line| print_padded_comment(line) }
|
69
|
+
|
70
|
+
# test.failure.message.each_line { |line| print_padded_comment(line) }
|
71
|
+
unless test.failure.is_a?(MiniTest::UnexpectedError)
|
72
|
+
blinka.backtrace.each { |line| print_padded_comment(line) }
|
73
|
+
end
|
74
|
+
puts
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def print_padded_comment(line)
|
80
|
+
puts "##{' ' * TAP_COMMENT_PAD + line}"
|
81
|
+
end
|
44
82
|
end
|
45
83
|
end
|
46
84
|
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.0
|
4
|
+
version: 0.3.0
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -103,7 +103,7 @@ files:
|
|
103
103
|
- lib/blinka_client.rb
|
104
104
|
- lib/blinka_minitest.rb
|
105
105
|
- lib/minitest/blinka_plugin.rb
|
106
|
-
homepage: https://
|
106
|
+
homepage: https://github.com/davidwessman/blinka_reporter
|
107
107
|
licenses:
|
108
108
|
- MIT
|
109
109
|
metadata: {}
|