flow_project_manager 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/flow_project_manager.gemspec +1 -1
- data/lib/flow_api/manager.rb +3 -3
- data/lib/flow_project_manager.rb +1 -0
- data/lib/flow_project_manager/version.rb +1 -1
- data/lib/utils/junit_reader.rb +59 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6876dc1a9d216bb1919af8276961a339b08f6af9
|
4
|
+
data.tar.gz: c9d68542959a28d28041f5623c2cb855ace7e4eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1058e0504dc6153c1c7c17946bb953248fa7b9ffada72415e3c93c94cb4007d638edc413a523587f9f4c5b2db8966626aae114689a35ec9fd0090fb2a2cc7981
|
7
|
+
data.tar.gz: 5572132b27dacd8abb6b07f550c68973c105694806832edad7da3cf4f39deca50ed1f6bae2691a8cd6d055087d3659570589b0a2b7cdcda8e939184df9b41587
|
data/lib/flow_api/manager.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'api_tools'
|
2
|
-
require "crack"
|
3
2
|
require "json"
|
3
|
+
require_relative "../utils/junit_reader"
|
4
4
|
|
5
5
|
module FlowApi
|
6
6
|
class Rest < DefaultRest
|
@@ -11,7 +11,7 @@ module FlowApi
|
|
11
11
|
|
12
12
|
def base_params
|
13
13
|
{
|
14
|
-
|
14
|
+
project_api_token: ENV["FLOW_PROJECT_API_TOKEN"]
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
@@ -34,7 +34,7 @@ module FlowApi
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def send_test_log_json(file_path)
|
37
|
-
json_str =
|
37
|
+
json_str = JunitReader.build_json_from_juniter(file_path).to_json
|
38
38
|
FlowApi::Rest.send_log_json ENV["FLOW_PROJECT_ID"], ENV["FLOW_JOB_ID"], json_str
|
39
39
|
end
|
40
40
|
end
|
data/lib/flow_project_manager.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
class JunitReader
|
4
|
+
class << self
|
5
|
+
def build_json_from_juniter(file_path)
|
6
|
+
answer = {}
|
7
|
+
xml = File.read(file_path)
|
8
|
+
doc = Nokogiri::XML(xml) do |config|
|
9
|
+
config.options = Nokogiri::XML::ParseOptions::NOBLANKS
|
10
|
+
end
|
11
|
+
|
12
|
+
root_element = doc.root
|
13
|
+
answer["name"] = root_element["name"]
|
14
|
+
answer["tests"] = root_element["tests"]
|
15
|
+
answer["failures"] = root_element["failures"]
|
16
|
+
|
17
|
+
testsuites = root_element.children.map do |element|
|
18
|
+
# Read testsuite
|
19
|
+
next if element.name != "testsuite"
|
20
|
+
read_test_suite( element )
|
21
|
+
end
|
22
|
+
testsuites.reject! {|m| m == nil}
|
23
|
+
|
24
|
+
answer["testsuites"] = testsuites
|
25
|
+
answer
|
26
|
+
end
|
27
|
+
|
28
|
+
def read_test_suite(element)
|
29
|
+
test_suite = {}
|
30
|
+
test_suite["name"] = element["name"]
|
31
|
+
test_suite["tests"] = element["tests"]
|
32
|
+
test_suite["failures"] = element["failures"]
|
33
|
+
testcases = element.children.map do |element_testcase|
|
34
|
+
# Read testcase
|
35
|
+
next if element_testcase.name != "testcase"
|
36
|
+
read_test_case(element_testcase)
|
37
|
+
end
|
38
|
+
testcases.reject! {|m| m == nil}
|
39
|
+
|
40
|
+
test_suite["testcases"] = testcases
|
41
|
+
test_suite
|
42
|
+
end
|
43
|
+
|
44
|
+
def read_test_case(element)
|
45
|
+
testcase = {}
|
46
|
+
testcase["classname"] = element["classname"]
|
47
|
+
testcase["name"] = element["name"]
|
48
|
+
testcase["time"] = element["time"]
|
49
|
+
failure_node = element.children.first
|
50
|
+
if failure_node && failure_node.name == "failure"
|
51
|
+
testcase["failure"] = {
|
52
|
+
message: failure_node["message"],
|
53
|
+
__content__: failure_node.text
|
54
|
+
}
|
55
|
+
end
|
56
|
+
testcase
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flow_project_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- atpking
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: nokogiri
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- lib/flow_api/manager.rb
|
146
146
|
- lib/flow_project_manager.rb
|
147
147
|
- lib/flow_project_manager/version.rb
|
148
|
+
- lib/utils/junit_reader.rb
|
148
149
|
homepage: http://www.flow.ci
|
149
150
|
licenses:
|
150
151
|
- MIT
|