fastlane-plugin-diawi 1.4.0 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77472d0e23aaeb498ab1ad1b35187fa1b3e21aee9fa53702b30c71f1b006104a
4
- data.tar.gz: 1a8279eabdc3c550cb9d9a2ccf7cac31e560557ecba45a2d90c357fb5da86f56
3
+ metadata.gz: beb66e054f5c65c772f26c84c021e5b9342f243e9d4c68b7e081023620f8493b
4
+ data.tar.gz: a12c675d601fdc47ec2beb845c8c968a19f3828f5aa6afac8bac9c29cacae48a
5
5
  SHA512:
6
- metadata.gz: 4a8781a35ccbe70da2f1b340e2a3ce17d4b7cfeb064b13eafc023025f2c2404f6c51f52df80b70334ce411fcae396b9c7c17a1d2dc40a1988aba4895e75af73e
7
- data.tar.gz: 1eb93676dbe1b3d22b56184f9c95e3bed4be15ec0e5177e38e78d0eafbd33be2e2f519765fe90fb3ecfe9ac4aeb049e194db287b431d26790df0b5e7263ede1e
6
+ metadata.gz: 792373c4a13c426947837f2410a304c50a7f5bf832072616c6961d094be6e235a9222dc8a335455a150bcefde03afa1e2246362b60732c477dd6ff7cf3e2ea93
7
+ data.tar.gz: cd34ad8b4cb27d5e560812a038d9398dce7861c1997eaad376f4fcd12d798ee449542d93887968c3225ae612bd11d065fd69b6c0e3db39dde07ba18055abb77b
data/README.md CHANGED
@@ -15,12 +15,22 @@ fastlane add_plugin diawi
15
15
  Diawi is a tool for developers to deploy Development and In-house applications directly to the devices.
16
16
  This plugin can upload .ipa and .apk file to diawi.
17
17
 
18
+ ## Migration to 2.0.0
19
+
20
+ `last_hope_attempts_count` - removed.
21
+
22
+ `last_hope_attempts_backoff` - renamed to `check_status_delay`.
23
+
24
+ `timeout` - new key.
25
+
26
+ For more info see [2.0.0 pull request](https://github.com/pacification/fastlane-plugin-diawi/pull/16).
27
+
18
28
  ## Available options
19
29
 
20
30
  Key | Required | Type | Description
21
31
  --- | --- | --- | ---
22
32
  **token** | **`true`** | `String` | [API access token](https://dashboard.diawi.com/profile/api)
23
- **file** | `false` | `String` | Path to .ipa or .apk file. Default - `IPA_OUTPUT_PATH` or `GRADLE_APK_OUTPUT_PATH` based on platform
33
+ **file** | `false` | `String` | Path to .ipa or .apk file.<br>**Default**: `IPA_OUTPUT_PATH` or `GRADLE_APK_OUTPUT_PATH` based on platform
24
34
  **find_by_udid** | `false` | `Boolean` | Allow your testers to find the app on diawi's mobile web app using their UDID (**iOS only**)
25
35
  **wall_of_apps** | `false` | `Boolean` | Allow diawi to display the app's icon on the wall of apps
26
36
  **password** | `false` | `String` | Protect your app with a password: it will be required to access the installation page
@@ -28,32 +38,8 @@ Key | Required | Type | Description
28
38
  **callback_url** | `false` | `String` | The URL diawi should call with the result
29
39
  **callback_emails** | `false` | `String` | The email addresses diawi will send the result to (up to 5 separated by commas for starter/premium/enterprise accounts, 1 for free accounts). Emails should be a string. Ex: "example@test.com,example1@test.com"
30
40
  **installation_notifications** | `false` | `Boolean` | Receive notifications each time someone installs the app (only starter/premium/enterprise accounts)
31
- **last_hope_attempts_count**⁺ | `false` | `Int` | Number of extra attempts to check file status (default: 1, max: 5, not in range (1...5): 1)
32
- **last_hope_attempts_backoff**⁺ | `false` | `Int` | Number of seconds to wait between repeated attempts at checking upload status. Default - 2
33
-
34
- <details><summary>⁺ Explanation</summary><p>
35
-
36
- From [diawi's documentation](https://dashboard.diawi.com/docs/apis/upload):
37
-
38
- > Polling frequence
39
- > If possible, prefer using the callbacks than the polling: they will always provide you with the result as soon as it is available.
40
- >
41
- > Usually, processing of an upload will take a few seconds: so, a base rule would be to poll every 2 seconds for up to 5 times and should match most simple use-cases.
42
- >
43
- > For larger apps, a longer processing might be needed on our side. A rule of thumb would be to wait up to 1 second for each 10 MB of the app. In other words, up to 10 seconds for a 100 MB app, 50 seconds for a 500 MB app, and so on…
44
- >
45
- > If the status is still 2001 after that duration, there probably is a problem, let us know.
46
-
47
- Technically your app can be uploaded to diawi, but still processing for a while. In this case `last_hope_attempts_count` can add extra `n` check status requests.
48
-
49
- Example:
50
- ```ruby
51
- last_hope_attempts_count = 3
52
- app_size = 23 MB
53
- check_attempts = 23 / 10 + last_hope_attempts_count = 5 # total attempts is 5; but it will return at first success response
54
- ```
55
-
56
- </p></details>
41
+ **timeout** | `false` | `Int` | Timeout for checking upload status in seconds.<br>**Default**: 60<br>**Range**: (5, 240)
42
+ **check_status_delay** | `false` | `Int` | Number of seconds to wait between repeated attempts at checking upload status.<br>**Default**: 3<br>**Range**: (1, 30)
57
43
 
58
44
  ## Result link
59
45
 
@@ -56,48 +56,33 @@ module Fastlane
56
56
  end
57
57
 
58
58
  job = JSON.parse(response.body)['job']
59
-
59
+
60
60
  if job
61
- return self.check_status(options[:token], options[:file], job, options[:last_hope_attempts_count], options[:last_hope_attempts_backoff])
61
+ timeout = options[:timeout].clamp(5, 240)
62
+ check_status_delay = options[:check_status_delay].clamp(1, 30)
63
+
64
+ if check_status_delay > timeout
65
+ UI.important("`check_status_delay` is greater than `timeout`")
66
+ end
67
+
68
+ UI.success("Upload completed successfully.")
69
+ UI.success("\n\nProcessing started with params:\n\njob: #{job}\ntimeout: #{timeout},\ncheck_status_delay: #{check_status_delay}\n")
70
+ return self.check_status(options[:token], options[:file], job, options[:timeout], options[:check_status_delay])
62
71
  end
63
72
 
64
73
  UI.important("Something went wrong and `job` value didn't come from uploading request. Check out your dashboard: https://dashboard.diawi.com/. Maybe your file already has been uploaded successfully.")
65
74
  UI.important("If not, try to upload file by yourself. Path: #{options[:file]}")
66
75
  end
67
76
 
68
- def self.check_status(token, file, job, last_hope_attempts_count, last_hope_attempts_backoff)
69
- # From documendation:
70
-
71
- # Polling frequence
72
- # Usually, processing of an upload will take a few seconds:
73
- # so, a base rule would be to poll every 2 seconds for up to 5 times and should match most simple use-cases.
74
-
75
- # For larger apps, a longer processing might be needed on our side.
76
- # A rule of thumb would be to wait up to 1 second for each 10 MB of the app.
77
- # In other words, up to 10 seconds for a 100 MB app, 50 seconds for a 500 MB app, and so on…
78
-
79
- # ^ Based on this here we calculate polling_count
80
-
81
- file_size = (File.size(file).to_i) / 2**20
82
- additional_polling_count = last_hope_attempts_count.between?(1, 5) ? last_hope_attempts_count : 1
83
- polling_count = file_size / 10 + additional_polling_count # also add "last hope" attempts
84
-
85
- polling_attempts = 0
86
-
77
+ def self.check_status(token, file, job, timeout, check_status_delay)
87
78
  status_ok = 2000
88
79
  status_in_progress = 2001
89
80
  status_error = 4000
90
81
 
91
- # According to:
92
- #
93
- # "processing of an upload will take a few seconds: a base rule would be to poll every 2 seconds".
94
- #
95
- # here introduced sleep 2 seconds before first check requst.
96
- # it should solve the problem with check status of small file size (> 10 mb).
97
- # if you need more attempts, use `DIAWI_LAST_HOPE_ATTEMPTS_COUNT`.
98
- sleep(2)
82
+ timeout_time = Time.now + timeout
83
+ current_time = Time.now
99
84
 
100
- while polling_count > polling_attempts do
85
+ while timeout_time > current_time do
101
86
  response = RestClient.get STATUS_CHECK_URL, {params: {token: token, job: job}}
102
87
 
103
88
  begin
@@ -105,8 +90,8 @@ module Fastlane
105
90
  rescue RestClient::ExceptionWithResponse => error
106
91
  UI.important("Check file status request error:")
107
92
  UI.important(error)
108
- polling_attempts += 1
109
- sleep(2)
93
+ sleep(check_status_delay)
94
+ current_time = Time.now
110
95
  next
111
96
  end
112
97
 
@@ -129,8 +114,8 @@ module Fastlane
129
114
  UI.important("Unknown error uploading file to diawi.")
130
115
  end
131
116
 
132
- polling_attempts += 1
133
- sleep(last_hope_attempts_backoff)
117
+ sleep(check_status_delay)
118
+ current_time = Time.now
134
119
  end
135
120
 
136
121
  UI.important("File is not processed.")
@@ -193,18 +178,18 @@ module Fastlane
193
178
  description: "Receive notifications each time someone installs the app (only starter/premium/enterprise accounts)",
194
179
  is_string: false,
195
180
  optional: true),
196
- FastlaneCore::ConfigItem.new(key: :last_hope_attempts_count,
197
- env_name: "DIAWI_LAST_HOPE_ATTEMPTS_COUNT",
198
- description: "Number of attempts to check status after last attempt. Default - 1, max - 5. (See more at `self.check_status` func comment)",
181
+ FastlaneCore::ConfigItem.new(key: :timeout,
182
+ env_name: "DIAWI_TIMEOUT",
183
+ description: "Timeout for checking upload status in seconds. Default: 60, range: (5, 240)",
199
184
  is_string: false,
200
185
  optional: true,
201
- default_value: 1),
202
- FastlaneCore::ConfigItem.new(key: :last_hope_attempts_backoff,
203
- env_name: "DIAWI_LAST_HOPE_ATTEMPTS_BACKOFF",
204
- description: "Number of seconds to wait between repeated attempts at checking upload status. Default - 2. (See more at `self.check_status` func comment)",
186
+ default_value: 60),
187
+ FastlaneCore::ConfigItem.new(key: :check_status_delay,
188
+ env_name: "DIAWI_CHECK_STATUS_DELAY",
189
+ description: "Number of seconds to wait between repeated attempts at checking upload status. Default: 3, range: (1, 30)",
205
190
  is_string: false,
206
191
  optional: true,
207
- default_value: 2)
192
+ default_value: 3)
208
193
  ]
209
194
  end
210
195
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Diawi
3
- VERSION = "1.4.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-diawi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pacification
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-22 00:00:00.000000000 Z
11
+ date: 2020-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client