ci_toolkit 1.5.17 → 1.5.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -1
- data/Gemfile.lock +1 -1
- data/lib/ci_toolkit/seetest_bot.rb +2 -1
- data/lib/ci_toolkit/{seetest_upload.rb → seetest_client.rb} +35 -45
- data/lib/ci_toolkit.rb +1 -1
- 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: 0caae7232b53d65bcd7f5eb7103b3ce36d56d22120beee7534bdcfa3beb8d1c9
|
4
|
+
data.tar.gz: 5a1bf7389dec806379b9b0f6544950f026638c53e614481bd2d8b4dd3152a980
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd550bfe914c50d9b3f21f691ee933d06f4048dbae2c430c7499f1b164757a5870bb51f561e789986bf35d6400c14b1ebcf90b6374a5135a3737a2fb1d4ad267
|
7
|
+
data.tar.gz: efc45ea4f35a27d452e56d43b51e32fe4cf1f407c692eeacaed5f438b3b808c58212200d5b87ae7c01a2672535d52ce8c0b9442b9a8cfd819e26d08f5232fd8c
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require "gitlab"
|
4
4
|
|
5
5
|
module CiToolkit
|
6
|
-
# Utility class that provides an
|
6
|
+
# Utility class that provides an faraday connection
|
7
7
|
class SeeTestBot
|
8
8
|
attr_reader :faraday_conn
|
9
9
|
|
@@ -27,6 +27,7 @@ module CiToolkit
|
|
27
27
|
f.request :authorization, "Bearer", credentials.access_token
|
28
28
|
f.request :multipart
|
29
29
|
f.request :url_encoded
|
30
|
+
f.response :json, parser_options: { object_class: OpenStruct }
|
30
31
|
f.adapter :net_http # A MUST for file upload to work with Faraday::Multipart::FilePart
|
31
32
|
end
|
32
33
|
)
|
@@ -5,19 +5,18 @@ require "faraday/net_http"
|
|
5
5
|
require "faraday/multipart"
|
6
6
|
|
7
7
|
module CiToolkit
|
8
|
-
#
|
8
|
+
# A client for Seetest webservice.
|
9
9
|
# See API doc for more info: https://docs.experitest.com/display/PM/How+To+Execute+Rest+API
|
10
10
|
# rubocop:disable Metrics/ClassLength
|
11
|
-
class
|
11
|
+
class SeeTestClient
|
12
12
|
SUCCESS = "SUCCESS"
|
13
|
-
BAD_REQUEST = "BAD_REQUEST"
|
14
13
|
OKAY = "OK"
|
15
14
|
ERROR = "ERROR"
|
15
|
+
API_VERSION = "v1"
|
16
|
+
attr_reader :faraday_conn
|
16
17
|
|
17
|
-
def initialize(
|
18
|
-
|
19
|
-
)
|
20
|
-
@bot = bot
|
18
|
+
def initialize(bot = CiToolkit::SeeTestBot.new)
|
19
|
+
@faraday_conn = bot.faraday_conn
|
21
20
|
end
|
22
21
|
|
23
22
|
# rubocop:disable Metrics/AbcSize
|
@@ -28,39 +27,41 @@ module CiToolkit
|
|
28
27
|
full_path_to_file:,
|
29
28
|
content_type: "application/octet-stream"
|
30
29
|
)
|
31
|
-
uploaded = ""
|
32
|
-
|
33
30
|
response = faraday_upload(
|
34
31
|
project_name,
|
35
32
|
unique_name,
|
36
33
|
full_path_to_file,
|
37
34
|
content_type
|
38
|
-
)
|
39
|
-
response_obj = get_response_body(response.body)
|
35
|
+
).body
|
40
36
|
|
41
|
-
# Application
|
42
|
-
if
|
43
|
-
|
44
|
-
|
37
|
+
# Application already exists. Replace it.
|
38
|
+
if response.status == SUCCESS && response.data.created == "false"
|
39
|
+
response = replace_existing_application(
|
40
|
+
response.data.id,
|
45
41
|
project_name,
|
46
42
|
unique_name,
|
47
43
|
full_path_to_file,
|
48
44
|
content_type
|
49
45
|
)
|
50
|
-
|
46
|
+
# Application with unique name already exist. Replace it.
|
47
|
+
elsif response.status == ERROR && !response.data.nil? && !response.data.uniqueName.nil?
|
51
48
|
application_info_response = faraday_get_application_info(unique_name)
|
52
49
|
application_id = application_info_response[0].id
|
53
|
-
|
50
|
+
response = replace_existing_application(
|
54
51
|
application_id,
|
55
52
|
project_name,
|
56
53
|
unique_name,
|
57
54
|
full_path_to_file,
|
58
55
|
content_type
|
59
56
|
)
|
60
|
-
else
|
61
|
-
uploaded = response_obj
|
62
57
|
end
|
63
|
-
|
58
|
+
|
59
|
+
unless response.status == SUCCESS
|
60
|
+
raise StandardError,
|
61
|
+
"Upload response from Seetest returned an error. Response body is: '#{response.marshal_dump}'"
|
62
|
+
end
|
63
|
+
|
64
|
+
response.status
|
64
65
|
end
|
65
66
|
# rubocop:enable Metrics/AbcSize Metrics/MethodLength
|
66
67
|
# rubocop:enable Metrics/MethodLength
|
@@ -84,14 +85,13 @@ module CiToolkit
|
|
84
85
|
full_path_to_file,
|
85
86
|
content_type
|
86
87
|
)
|
87
|
-
response = faraday_upload(project_name, unique_name, full_path_to_file, content_type)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
raise StandardError, "Upload response from Seetest returned an error. Response body is: '#{response.body}'"
|
88
|
+
response = faraday_upload(project_name, unique_name, full_path_to_file, content_type).body
|
89
|
+
unless response.status == SUCCESS && response.data.created == "true"
|
90
|
+
raise StandardError,
|
91
|
+
"Upload response from Seetest returned an error. Response body is: '#{response.marshal_dump}'"
|
92
92
|
end
|
93
93
|
|
94
|
-
|
94
|
+
response
|
95
95
|
end
|
96
96
|
|
97
97
|
def faraday_upload(
|
@@ -106,38 +106,28 @@ module CiToolkit
|
|
106
106
|
uniqueName: unique_name,
|
107
107
|
project: project_name
|
108
108
|
}
|
109
|
-
@
|
109
|
+
@faraday_conn.post("/api/#{API_VERSION}/applications/new", params)
|
110
110
|
end
|
111
111
|
|
112
112
|
def faraday_get_application_info(unique_name)
|
113
113
|
params = { uniqueName: unique_name }
|
114
|
-
response = @
|
115
|
-
|
116
|
-
if response_obj.empty?
|
114
|
+
response = @faraday_conn.get("/api/#{API_VERSION}/applications", params).body
|
115
|
+
if response.empty?
|
117
116
|
raise StandardError,
|
118
117
|
"Get application info for uniqueName: #{unique_name} from Seetest returned an error. "\
|
119
|
-
"Response body is: '#{response
|
118
|
+
"Response body is: '#{response}'"
|
120
119
|
end
|
121
|
-
|
122
|
-
response_obj
|
120
|
+
response
|
123
121
|
end
|
124
122
|
|
125
123
|
def faraday_delete_application(application_id)
|
126
|
-
response = @
|
127
|
-
|
128
|
-
response_obj = get_response_body(response.body)
|
129
|
-
|
130
|
-
unless response_obj.status == SUCCESS && response_obj.code == OKAY
|
124
|
+
response = @faraday_conn.post("/api/#{API_VERSION}/applications/#{application_id}/delete").body
|
125
|
+
unless response.status == SUCCESS && response.code == OKAY
|
131
126
|
raise StandardError,
|
132
127
|
"Delete application id: #{application_id} from Seetest returned an error. "\
|
133
|
-
"Response body is: '#{response.
|
128
|
+
"Response body is: '#{response.marshal_dump}'"
|
134
129
|
end
|
135
|
-
|
136
|
-
response_obj
|
137
|
-
end
|
138
|
-
|
139
|
-
def get_response_body(response)
|
140
|
-
JSON.parse(response, object_class: OpenStruct)
|
130
|
+
response
|
141
131
|
end
|
142
132
|
end
|
143
133
|
# rubocop:enable Metrics/ClassLength
|
data/lib/ci_toolkit.rb
CHANGED
@@ -11,7 +11,7 @@ require "ci_toolkit/gitlab_bot"
|
|
11
11
|
require "ci_toolkit/gitlab_pr"
|
12
12
|
require "ci_toolkit/gitlab_release"
|
13
13
|
require "ci_toolkit/seetest_bot"
|
14
|
-
require "ci_toolkit/
|
14
|
+
require "ci_toolkit/seetest_client"
|
15
15
|
require "ci_toolkit/dvcs_pr_factory"
|
16
16
|
require "ci_toolkit/git"
|
17
17
|
require "ci_toolkit/jira"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gero Keller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -248,7 +248,7 @@ files:
|
|
248
248
|
- lib/ci_toolkit/pr_messenger.rb
|
249
249
|
- lib/ci_toolkit/pr_messenger_text.rb
|
250
250
|
- lib/ci_toolkit/seetest_bot.rb
|
251
|
-
- lib/ci_toolkit/
|
251
|
+
- lib/ci_toolkit/seetest_client.rb
|
252
252
|
- transform_coverage_data.rb
|
253
253
|
homepage: https://github.com/crvshlab/ci_toolkit
|
254
254
|
licenses:
|