gunter_reporter 0.1.3 → 0.1.4
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/Gemfile +1 -0
- data/Gemfile.lock +4 -2
- data/lib/gunter_reporter/version.rb +1 -1
- data/lib/gunter_reporter.rb +19 -12
- 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: 576c96201a4e7e5306b0fb0037e913f59d0e2d74d399473a135aec5ac7d3261c
|
4
|
+
data.tar.gz: fc82243de38cdbb87411d81d6c299cc2279eb61132c9d8690fd6b9ff2adbc2c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e67841b69815f301f0e3c8c6ec0f579f431e8921ca349ce9f7a9f72a3dd84d51d3174fda52883782cf6e461d65797a64b41ff95819c6c0ad0f25b9398b783a1
|
7
|
+
data.tar.gz: ff6405d14d36868732a9df7b508e46fe2ae91f6c0e9d049a0ed59d55612deb321b5d11aafc1635610f2d6fe3ab9b349f7fe8e667df781ff63a72c4716169d4d7
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gunter_reporter (0.1.
|
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.
|
43
|
+
1.16.3
|
data/lib/gunter_reporter.rb
CHANGED
@@ -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 '
|
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
|
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 "✅
|
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 '⚠️
|
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.
|
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-
|
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.
|
95
|
+
rubygems_version: 2.7.6
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Report test results to Gunter.
|