gunter_reporter 0.1.3 → 0.1.4

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: 7383a1906690d9f48dd4177b6349fc9dd6672e6d4c52915fc044d294fa886c3e
4
- data.tar.gz: 2799babc54165b45fb228fbced75e3c7a52cbc9ef5d11148bf9399185b1b9d6e
3
+ metadata.gz: 576c96201a4e7e5306b0fb0037e913f59d0e2d74d399473a135aec5ac7d3261c
4
+ data.tar.gz: fc82243de38cdbb87411d81d6c299cc2279eb61132c9d8690fd6b9ff2adbc2c5
5
5
  SHA512:
6
- metadata.gz: 1fad6bc55d5e48d80c9102ab82100739dd8240763899e4107eff925d6cf6d97680f156a846637b35990a9c4129fa9fd60720db7df4d58da03c035326a67ea60c
7
- data.tar.gz: f7a29e1379719667c20cb94fef31a986a113882f50eaa0d0ccd969258fec20245616465de967b63eb498f90d5758bfcd1699509daf474d76dde12c0351cbc71d
6
+ metadata.gz: 5e67841b69815f301f0e3c8c6ec0f579f431e8921ca349ce9f7a9f72a3dd84d51d3174fda52883782cf6e461d65797a64b41ff95819c6c0ad0f25b9398b783a1
7
+ data.tar.gz: ff6405d14d36868732a9df7b508e46fe2ae91f6c0e9d049a0ed59d55612deb321b5d11aafc1635610f2d6fe3ab9b349f7fe8e667df781ff63a72c4716169d4d7
data/Gemfile CHANGED
@@ -6,3 +6,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
6
  gemspec
7
7
 
8
8
  gem 'pry'
9
+ gem 'xml-simple'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gunter_reporter (0.1.3)
4
+ gunter_reporter (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -26,6 +26,7 @@ GEM
26
26
  diff-lcs (>= 1.2.0, < 2.0)
27
27
  rspec-support (~> 3.7.0)
28
28
  rspec-support (3.7.0)
29
+ xml-simple (1.1.5)
29
30
 
30
31
  PLATFORMS
31
32
  ruby
@@ -36,6 +37,7 @@ DEPENDENCIES
36
37
  pry
37
38
  rake (~> 10.0)
38
39
  rspec (~> 3.0)
40
+ xml-simple
39
41
 
40
42
  BUNDLED WITH
41
- 1.16.1
43
+ 1.16.3
@@ -1,3 +1,3 @@
1
1
  class GunterReporter
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -1,8 +1,9 @@
1
1
  require "gunter_reporter/version"
2
2
  require 'securerandom'
3
+ require 'uri'
3
4
  require 'net/http'
4
5
  require 'json'
5
- require 'uri'
6
+ require 'xmlsimple'
6
7
 
7
8
  class GunterReporter
8
9
  def initialize
@@ -16,9 +17,9 @@ class GunterReporter
16
17
 
17
18
  def submit_results(environment_variables)
18
19
  files = Dir.glob("tmp/gunter/#{environment_variables['TASK_ID']}/*")
19
- no_results_error if files.empty?
20
20
  files.each do |file|
21
21
  report = File.read(file)
22
+ next unless XmlSimple.xml_in(report).key?('testcase')
22
23
  form_data = environment_variables.merge(build_data).merge('report' => report)
23
24
  response = submit_result(form_data)
24
25
  print_result(response)
@@ -29,19 +30,17 @@ class GunterReporter
29
30
 
30
31
  def build_data
31
32
  @build_data ||= {
32
- 'APP_NAME' => ENV.fetch('APP_NAME'),
33
33
  'BUILD_UUID' => SecureRandom.uuid,
34
34
  'BUILD_NUMBER' => ENV['BUILD_NUMBER'],
35
35
  'APP_ENV' => ENV['APP_ENV'],
36
+ 'ORIGIN' => ENV['ORIGIN'],
36
37
  'DEVELOPER' => ENV['DEVELOPER'],
37
- 'BRANCH' => ENV.fetch('CIRCLE_BRANCH', `git rev-parse --abbrev-ref HEAD`.chomp),
38
+ 'BRANCH' => ENV['BRANCH'],
38
39
  'CI' => ENV.key?('CI')
39
40
  }
40
41
  end
41
42
 
42
43
  def submit_result(form_data)
43
- url = URI(ENV.fetch('GUNTER_API_URL', 'https://gunter-oasis-stage.alamoapp.octanner.io/api/v1/testsuites'))
44
-
45
44
  http = Net::HTTP.new(url.host, url.port)
46
45
  http.use_ssl = (url.scheme == 'https')
47
46
 
@@ -54,16 +53,24 @@ class GunterReporter
54
53
  http.request(request)
55
54
  end
56
55
 
56
+ def url
57
+ @url ||= begin
58
+ if ENV['GUNTER_ENV'].to_s.casecmp?('prod') || (ENV['GUNTER_ENV'].nil? && ENV['ORIGIN'])
59
+ URI('https://gunter.octanner.io/api/v1/testsuites')
60
+ elsif ENV['GUNTER_ENV'].to_s.casecmp?('dev')
61
+ URI('http://localhost:3000/api/v1/testsuites')
62
+ else
63
+ URI('https://gunter-oasis-stage.alamoapp.octanner.io/api/v1/testsuites')
64
+ end
65
+ end
66
+ end
67
+
57
68
  def print_result(response)
58
69
  if response.code == '201'
59
- puts "✅ Results reported successfully. Testsuite ID: #{JSON.parse(response.body)['id']}"
70
+ puts "✅ Gunter results: #{JSON.parse(response.body)['url']}"
60
71
  else
61
72
  open('tmp/gunter/error.html', 'w') { |f| f << response.body }
62
- puts '⚠️ GunterError: Results reporting failed. Please report this to Calaway. Thank you.'
73
+ puts '⚠️ Gunter results reporting failed. Please report this to Calaway. Thank you.'
63
74
  end
64
75
  end
65
-
66
- def no_results_error
67
- puts '⚠️ GunterError: No results found. Please report this to Calaway. Thank you.'
68
- end
69
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gunter_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calaway
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-05 00:00:00.000000000 Z
11
+ date: 2018-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.7.2
95
+ rubygems_version: 2.7.6
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Report test results to Gunter.