blinka-reporter 0.0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31edba38b92782d767fbd8171ef389d038650ec112cefbc1126191326252bedc
4
- data.tar.gz: c3a8d636de16e3d20b279f1611a41951001a491fce1824e43265da4b1f61d77f
3
+ metadata.gz: bda58bde54cfddafa7711c984e477a7781299f90874a137e4e396dd048885afe
4
+ data.tar.gz: 41ce526368565e1f97884fb13977f8833081681a2f63e29343e78508c4f4535a
5
5
  SHA512:
6
- metadata.gz: 0fde649f8f710d3a321241e86a9a9f195fb031184b1a4b73fd3d9fa35290cc65ea757cb41d5afd852ac0f63ec60bb06af51a7a27e940aa07cbe29572bc116b99
7
- data.tar.gz: 272d9195b859bf2a440daeefa415ae02e0a1a9ee1a2eebd0c7d0850c42251be5900bdf1e16d23f9d4f93655fda4c9c2a07ca4e65c8617b85fafdc29c022741b7
6
+ metadata.gz: f98b19c0df3fe63a02c322d53c22bdca62a473d106a3984a6803fc856e1203028e4de3f4b1f9d902b399fad285294218ee47c736f6f2f3b984c5ba63048d40fd
7
+ data.tar.gz: 0d701507d2ae55c3d022694c212a668d91804acbe18040e0476d8bf585f098edc1fc0dbe4a51a7d340c56fcc3309c4aeec6cc199b1990e4f1430e98314d190c7
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
- :branch,
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://blinkblink.herokuapp.com')
17
- @team_id = ENV.fetch('BLINKA_TEAM_ID')
18
- @team_secret = ENV.fetch('BLINKA_TEAM_SECRET')
19
- @repository = ENV.fetch('BLINKA_REPOSITORY')
20
- @branch = ENV.fetch('BLINKA_BRANCH')
21
- @commit = `git rev-parse HEAD`.chomp
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
+ @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
 
@@ -50,7 +59,7 @@ class BlinkaClient
50
59
  body = {
51
60
  report: {
52
61
  repository: @config.repository,
53
- branch: @config.branch,
62
+ tag: @config.tag,
54
63
  commit: @config.commit,
55
64
  metadata: {
56
65
  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
+ blinka_report
30
+
27
31
  super
32
+ end
33
+
34
+ private
28
35
 
36
+ def blinka_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.2
4
+ version: 0.2.1
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-01 00:00:00.000000000 Z
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://rubygemspec.org/gems/blinka-reporter
106
+ homepage: https://github.com/davidwessman/blinka_reporter
107
107
  licenses:
108
108
  - MIT
109
109
  metadata: {}