ci_toolkit 1.6.0 → 1.6.2

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: 86cd888726c86a779288d7e4a7d04bea4a1d1a52c479dcb862812f40ffa4f509
4
- data.tar.gz: 75833b08101042e0d7d9b3dae759d5ff505525f95bc547295eb2eaa734381ffb
3
+ metadata.gz: fcff525b13f81bed444cb020bd0b41da763c049a3fc701ab69667b95667c45f1
4
+ data.tar.gz: 7838f0ab23174aef2eacf27438fa01359a35d0a39742d734372a25b18af239ad
5
5
  SHA512:
6
- metadata.gz: 83eed0a9c51b4b4266648a505ba5cb1b861903631eca68ddc8bcb8ca8ade51e15727d882bde644f88f11ed2d2eb6375f5c990f98f2c112fc9b0971f98ddc9e80
7
- data.tar.gz: d05f1b050e19d31291d570132deb5c3898fc1616629f7a4887813fec95e128bed07a08b38c5cfea82de491c375541a4b17a04bb5c7488f35bc41ff2c9e3a96b8
6
+ metadata.gz: 777b3ed09754c520fc539b29021f50f6b814b56a4cb2aee5d1cc4169b1840159aca5d16d6091677497dec6b7528c7ae1feb72cc1f306b6a43113513d27f63a7d
7
+ data.tar.gz: 9db6afb245cd1f70fbb8fbef7b35d1198b0b5937ea70c7c8e78962d9001022443d787f5cd8a7227b1e9ea318729d720fd914b64cc1f30389ce834fbf5af4c45e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ci_toolkit (1.6.0)
4
+ ci_toolkit (1.6.2)
5
5
  faraday
6
6
  faraday-multipart
7
7
  faraday_middleware
data/ci_toolkit.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "ci_toolkit"
5
- spec.version = "1.6.0"
5
+ spec.version = "1.6.2"
6
6
  spec.authors = ["Gero Keller"]
7
7
  spec.email = ["gero.f.keller@gmail.com"]
8
8
 
@@ -8,7 +8,8 @@ module CiToolkit
8
8
  def initialize(
9
9
  env = CiToolkit::BitriseEnv.new,
10
10
  build_types = ENV["BUILD_TYPES"]&.split(/,/) || ["BluetoothDemo", "Acceptance PreProd", "Acceptance Prod",
11
- "Latest Prod", "Latest PreProd", "Mock", "Design System"],
11
+ "Latest Prod", "Latest PreProd", "Mock", "Design System",
12
+ "Acceptance Prod DEBUG"],
12
13
 
13
14
  bot = CiToolkit::GitlabBot.new
14
15
  )
@@ -7,7 +7,6 @@ require "faraday/multipart"
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
- # rubocop:disable Metrics/ClassLength
11
10
  class SeeTestClient
12
11
  SUCCESS = "SUCCESS"
13
12
  OKAY = "OK"
@@ -19,30 +18,14 @@ module CiToolkit
19
18
  @faraday_conn = bot.faraday_conn
20
19
  end
21
20
 
22
- # rubocop:disable Metrics/MethodLength
23
21
  def upload_file(
24
22
  project_name:,
25
23
  unique_name:,
26
24
  full_path_to_file:,
27
25
  content_type: "application/octet-stream"
28
26
  )
29
- response = faraday_upload(
30
- project_name,
31
- unique_name,
32
- full_path_to_file,
33
- content_type
34
- ).body
35
-
36
- # Application already exists. Replace it.
37
- if (response["status"] == SUCCESS && response["data"]["created"] == "false") ||
38
- (response["status"] == ERROR && response.dig("data", "uniqueName"))
39
- response = replace_existing_application_by_unique_name(
40
- project_name,
41
- unique_name,
42
- full_path_to_file,
43
- content_type
44
- )
45
- end
27
+
28
+ response = upload_or_replace(project_name, unique_name, full_path_to_file, content_type)
46
29
 
47
30
  unless response["status"] == SUCCESS
48
31
  raise StandardError,
@@ -51,10 +34,24 @@ module CiToolkit
51
34
 
52
35
  response["status"]
53
36
  end
54
- # rubocop:enable Metrics/MethodLength
55
37
 
56
38
  private
57
39
 
40
+ def upload_or_replace(project_name, unique_name, full_path_to_file, content_type)
41
+ application_info_response = faraday_get_application_info(unique_name)
42
+ if application_info_response.empty?
43
+ return faraday_upload(project_name, unique_name, full_path_to_file, content_type).body
44
+ end
45
+
46
+ application_info_response.each do |app_response|
47
+ next unless app_response["uniqueName"] == unique_name
48
+
49
+ response = replace_existing_application(app_response["id"], project_name, unique_name, full_path_to_file,
50
+ content_type)
51
+ return response if response["status"] == SUCCESS
52
+ end
53
+ end
54
+
58
55
  def replace_existing_application(
59
56
  application_id,
60
57
  project_name,
@@ -63,24 +60,12 @@ module CiToolkit
63
60
  content_type
64
61
  )
65
62
  response = faraday_delete_application(application_id)
66
-
67
63
  if response["status"] == SUCCESS && response["code"] == OKAY
68
64
  response = faraday_upload_file_with_error_handling(project_name, unique_name, full_path_to_file, content_type)
69
65
  end
70
66
  response
71
67
  end
72
68
 
73
- def replace_existing_application_by_unique_name(project_name, unique_name, full_path_to_file, content_type)
74
- application_info_response = faraday_get_application_info(unique_name)
75
- application_info_response.each do |app_response|
76
- next unless app_response["uniqueName"] == unique_name
77
-
78
- response = replace_existing_application(app_response["id"], project_name, unique_name, full_path_to_file,
79
- content_type)
80
- return response if response["status"] == SUCCESS
81
- end
82
- end
83
-
84
69
  def faraday_upload_file_with_error_handling(
85
70
  project_name,
86
71
  unique_name,
@@ -113,13 +98,7 @@ module CiToolkit
113
98
 
114
99
  def faraday_get_application_info(unique_name)
115
100
  params = { uniqueName: unique_name }
116
- response = @faraday_conn.get("/api/#{API_VERSION}/applications", params).body
117
- if response.empty?
118
- raise StandardError,
119
- "Get application info for uniqueName: #{unique_name} from Seetest returned an error. " \
120
- "Response body is: '#{response}'"
121
- end
122
- response
101
+ @faraday_conn.get("/api/#{API_VERSION}/applications", params).body
123
102
  end
124
103
 
125
104
  def faraday_delete_application(application_id)
@@ -132,5 +111,4 @@ module CiToolkit
132
111
  response
133
112
  end
134
113
  end
135
- # rubocop:enable Metrics/ClassLength
136
114
  end
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.6.0
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gero Keller
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-26 00:00:00.000000000 Z
11
+ date: 2023-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -260,7 +260,7 @@ metadata:
260
260
  source_code_uri: https://github.com/crvshlab/ci_toolkit
261
261
  changelog_uri: https://github.com/crvshlab/ci_toolkit/CHANGELOG.md
262
262
  rubygems_mfa_required: 'true'
263
- post_install_message:
263
+ post_install_message:
264
264
  rdoc_options: []
265
265
  require_paths:
266
266
  - lib
@@ -276,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
276
  version: '0'
277
277
  requirements: []
278
278
  rubygems_version: 3.4.10
279
- signing_key:
279
+ signing_key:
280
280
  specification_version: 4
281
281
  summary: Set of CI utilities
282
282
  test_files: []