fastlane-plugin-pcloudy 0.2.0 → 0.3.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: 5beb8f759d9c8483fbb1d9185edc83e0d09c6d22e900c4e848ff635adff4f1e7
4
- data.tar.gz: 4c21078f470ecbf008c417c60a6afac259b84750850b9c6d489048715d8311cd
3
+ metadata.gz: 7943aa34838d8ab7194a838a3d1ea68b2dabcc289cd7114f5a02db2473cce783
4
+ data.tar.gz: a3e9a85568b6e84c20413b8e3a084b9cbe1059d1e903eefa096bd2996d406b07
5
5
  SHA512:
6
- metadata.gz: baa15536e27dc025e5e56845f256fc35d4c4d4f37b2781a7e8052f946b9649d817caccd2adfaebe233e718d172f812433c103b81419ba51251a5639c9f06e696
7
- data.tar.gz: 07a4aceb6833f999a52be92af8cd1aaf1b02c6f94ec2408768c70f18576c2b10014ad761c1caac714b55e4e66517f99e94526bf576ed8744fd669a1ae018f472
6
+ metadata.gz: 40f9ccc7e9b532d9421c56288264db84c318c49d3bffdfa5a5028ab485816104d4a7e77c56e87055a3074a2105b39e617cc0ad7c05d8f16ed67a607aec3474fd
7
+ data.tar.gz: 9f2b9b43ead83dc81f8e6d4585f5f326584f89ac9c84cfa46e3e2a33fb3aaec4a1ca63c7e56b5bb116220f168f50676dcc5374281f9474eff1ec1887ef7341ba
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0
4
+
5
+ - `pcloudy_upload_app` and `pcloudy_resign_app` now also set `PCLOUDY_UPLOADED_FILE`, `PCLOUDY_RESIGNED_FILE`
6
+ and `PCLOUDY_APP_FILE` as environment variables, so Appium test runners started with `sh` can read
7
+ `PCLOUDY_APP_FILE` directly.
8
+ - A new upload without `resign` clears `PCLOUDY_RESIGNED_FILE`, so it never points at an earlier app.
9
+ - `pcloudy_upload_app` accepts Android App Bundles (`.aab`) and uses the `.aab` from `gradle` bundle tasks
10
+ when no `.ipa` or `.apk` was built.
11
+
12
+ ## 0.2.1
13
+
14
+ - Network failures such as timeouts, dropped connections during large uploads, and unreachable hosts
15
+ now fail the lane with a clear "Could not reach pCloudy" error instead of a Ruby stack trace.
16
+ - HTTP errors now include pCloudy's own error message (e.g. a wrong API key) when pCloudy sends one.
17
+ - Error messages no longer show "(code n/a)" when pCloudy returns no result code.
18
+ - `pcloudy_upload_app` has a new `poll_interval` option for `resign: true`, matching `pcloudy_resign_app`.
19
+ - The gem is now maintained and published by pCloudy.
20
+
3
21
  ## 0.2.0
4
22
 
5
23
  - New `pcloudy_upload_app`: uploads an `.ipa` or `.apk` to pCloudy My Apps. Picks up the output of
data/README.md CHANGED
@@ -5,7 +5,7 @@ A [fastlane](https://fastlane.tools) plugin for [pCloudy](https://www.pcloudy.co
5
5
  | Action | Status |
6
6
  |---|---|
7
7
  | `pcloudy_list_devices`: list available devices | ✅ Available |
8
- | `pcloudy_upload_app`: upload an `.ipa` / `.apk` | ✅ Available |
8
+ | `pcloudy_upload_app`: upload an `.ipa` / `.apk` / `.aab` | ✅ Available |
9
9
  | `pcloudy_resign_app`: re-sign an `.ipa` for pCloudy devices | ✅ Available |
10
10
  | `pcloudy_book_device` / `pcloudy_release_device` | Planned |
11
11
  | `pcloudy_install_app`: install and launch on a booked device | Planned |
@@ -46,9 +46,25 @@ end
46
46
 
47
47
  The app then appears in **pCloudy → My Apps**, ready to install on real devices.
48
48
 
49
+ ## Running Appium tests after the upload
50
+
51
+ The upload and re-sign actions set `PCLOUDY_APP_FILE` as an environment variable, so a test runner started with `sh` can read it directly:
52
+
53
+ ```ruby
54
+ lane :pcloudy_appium do
55
+ build_app(scheme: "MyApp", export_method: "development")
56
+ pcloudy_upload_app(resign: true) # sets ENV["PCLOUDY_APP_FILE"]
57
+ sh("cd .. && mvn test") # or pytest, npm test, ...
58
+ end
59
+ ```
60
+
61
+ ```java
62
+ caps.setCapability("pCloudy_ApplicationName", System.getenv("PCLOUDY_APP_FILE"));
63
+ ```
64
+
49
65
  ## `pcloudy_upload_app`
50
66
 
51
- Uploads an `.ipa` or `.apk` to pCloudy My Apps. If you don't pass `file:`, it uses the `.ipa` from `build_app` or the `.apk` from `gradle`.
67
+ Uploads an `.ipa`, `.apk` or `.aab` to pCloudy My Apps. If you don't pass `file:`, it uses the `.ipa` from `build_app`, or else the `.apk` from `gradle` (`assemble…` tasks), or else the `.aab` from `gradle` (`bundle…` tasks).
52
68
 
53
69
  When a file with the same name already exists, pCloudy saves the upload under a new, timestamped name (e.g. `MyApp-1794551836.ipa`). The action returns that name, so always use the return value or `PCLOUDY_UPLOADED_FILE`, never the local file name.
54
70
 
@@ -60,17 +76,18 @@ name = pcloudy_upload_app(file: "./build/MyApp.apk")
60
76
 
61
77
  | Option | Env var | Default | Description |
62
78
  |---|---|---|---|
63
- | `file` | `PCLOUDY_APP_PATH` | output of `build_app` / `gradle` | Path to the `.ipa` or `.apk` |
79
+ | `file` | `PCLOUDY_APP_PATH` | output of `build_app` / `gradle` | Path to the `.ipa`, `.apk` or `.aab` |
64
80
  | `resign` | `PCLOUDY_RESIGN` | `false` | Re-sign the `.ipa` after uploading (iOS only) |
65
81
  | `wait_for_processing` | `PCLOUDY_WAIT_FOR_PROCESSING` | `true` | Wait until the file appears in My Apps |
66
82
  | `upload_timeout` | `PCLOUDY_UPLOAD_TIMEOUT` | `600` | Seconds allowed for the upload |
67
83
  | `processing_timeout` | `PCLOUDY_PROCESSING_TIMEOUT` | `120` | Seconds to wait for the file to appear in My Apps |
68
84
  | `resign_timeout` | `PCLOUDY_RESIGN_TIMEOUT` | `600` | Seconds to wait for re-signing (with `resign: true`) |
85
+ | `poll_interval` | — | `5` | Seconds between re-sign progress checks (with `resign: true`) |
69
86
 
70
87
  Plus `username`, `api_key` and `cloud_url`, as for every action.
71
88
 
72
89
  **Returns:** the file name in My Apps (the re-signed copy when `resign: true`).
73
- **Sets:** `PCLOUDY_UPLOADED_FILE`, `PCLOUDY_APP_FILE`, and with `resign: true`, `PCLOUDY_RESIGNED_FILE`.
90
+ **Sets** (in `lane_context` and as environment variables): `PCLOUDY_UPLOADED_FILE`, `PCLOUDY_APP_FILE`, and with `resign: true`, `PCLOUDY_RESIGNED_FILE`. A new upload without `resign` clears `PCLOUDY_RESIGNED_FILE`.
74
91
 
75
92
  ## `pcloudy_resign_app`
76
93
 
@@ -90,7 +107,7 @@ pcloudy_resign_app(file: "MyApp-1794551836.ipa") # a file already in My Apps
90
107
  | `poll_interval` | — | `5` | Seconds between progress checks |
91
108
 
92
109
  **Returns:** the re-signed file name, e.g. `MyApp-1794551836_Resigned1794551854668.ipa`.
93
- **Sets:** `PCLOUDY_RESIGNED_FILE` and `PCLOUDY_APP_FILE`.
110
+ **Sets** (in `lane_context` and as environment variables): `PCLOUDY_RESIGNED_FILE` and `PCLOUDY_APP_FILE`.
94
111
 
95
112
  ## `pcloudy_list_devices`
96
113
 
@@ -90,7 +90,7 @@ module Fastlane
90
90
  end
91
91
 
92
92
  def self.authors
93
- ["bikee1235"]
93
+ ["pCloudy"]
94
94
  end
95
95
 
96
96
  def self.return_value
@@ -12,8 +12,8 @@ module Fastlane
12
12
  client = Helper::PcloudyOptions.client(params)
13
13
  signed = Helper::PcloudyOptions.resign(client, filename, timeout: params[:timeout], interval: params[:poll_interval])
14
14
 
15
- Actions.lane_context[SharedValues::PCLOUDY_RESIGNED_FILE] = signed
16
- Actions.lane_context[SharedValues::PCLOUDY_APP_FILE] = signed
15
+ Helper::PcloudyOptions.export(SharedValues::PCLOUDY_RESIGNED_FILE, signed)
16
+ Helper::PcloudyOptions.export(SharedValues::PCLOUDY_APP_FILE, signed)
17
17
  signed
18
18
  rescue Helper::PcloudyClient::Error => e
19
19
  UI.user_error!(e.message)
@@ -33,7 +33,7 @@ module Fastlane
33
33
  end
34
34
 
35
35
  def self.authors
36
- ["bikee1235"]
36
+ ["pCloudy"]
37
37
  end
38
38
 
39
39
  def self.return_value
@@ -10,7 +10,7 @@ module Fastlane
10
10
  end
11
11
 
12
12
  class PcloudyUploadAppAction < Action
13
- EXTENSIONS = %w(.ipa .apk).freeze
13
+ EXTENSIONS = %w(.ipa .apk .aab).freeze
14
14
 
15
15
  def self.run(params)
16
16
  path = params[:file] || default_file
@@ -19,7 +19,7 @@ module Fastlane
19
19
  path = File.expand_path(path)
20
20
  UI.user_error!("File not found: #{path}") unless File.file?(path)
21
21
  ext = File.extname(path).downcase
22
- UI.user_error!("Unsupported file type '#{ext}'. pCloudy apps must be #{EXTENSIONS.join(' or ')}") unless EXTENSIONS.include?(ext)
22
+ UI.user_error!("Unsupported file type '#{ext}'. pCloudy apps must be #{EXTENSIONS.join(', ')}") unless EXTENSIONS.include?(ext)
23
23
  UI.user_error!("resign: true only works for iOS apps (.ipa); #{File.basename(path)} is #{ext}") if params[:resign] && ext != ".ipa"
24
24
 
25
25
  client = Helper::PcloudyOptions.client(params)
@@ -33,13 +33,15 @@ module Fastlane
33
33
  client.wait_for_file(name, timeout: params[:processing_timeout])
34
34
  end
35
35
 
36
- Actions.lane_context[SharedValues::PCLOUDY_UPLOADED_FILE] = name
37
- Actions.lane_context[SharedValues::PCLOUDY_APP_FILE] = name
36
+ Helper::PcloudyOptions.export(SharedValues::PCLOUDY_UPLOADED_FILE, name)
37
+ Helper::PcloudyOptions.export(SharedValues::PCLOUDY_APP_FILE, name)
38
+ # Don't leave a re-signed name from an earlier upload in this lane pointing at a different app.
39
+ Helper::PcloudyOptions.export(SharedValues::PCLOUDY_RESIGNED_FILE, nil)
38
40
 
39
41
  if params[:resign]
40
- name = Helper::PcloudyOptions.resign(client, name, timeout: params[:resign_timeout], interval: 5)
41
- Actions.lane_context[SharedValues::PCLOUDY_RESIGNED_FILE] = name
42
- Actions.lane_context[SharedValues::PCLOUDY_APP_FILE] = name
42
+ name = Helper::PcloudyOptions.resign(client, name, timeout: params[:resign_timeout], interval: params[:poll_interval])
43
+ Helper::PcloudyOptions.export(SharedValues::PCLOUDY_RESIGNED_FILE, name)
44
+ Helper::PcloudyOptions.export(SharedValues::PCLOUDY_APP_FILE, name)
43
45
  end
44
46
 
45
47
  name
@@ -47,10 +49,11 @@ module Fastlane
47
49
  UI.user_error!(e.message)
48
50
  end
49
51
 
50
- # The .ipa from build_app/gym, or else the .apk from gradle.
52
+ # The .ipa from build_app/gym, else the .apk from gradle, else the .aab from gradle (bundle tasks).
51
53
  def self.default_file
52
54
  context = Actions.lane_context
53
- [context[:IPA_OUTPUT_PATH], context[:GRADLE_APK_OUTPUT_PATH]].find { |value| !value.to_s.empty? }
55
+ [context[:IPA_OUTPUT_PATH], context[:GRADLE_APK_OUTPUT_PATH], context[:GRADLE_AAB_OUTPUT_PATH]]
56
+ .find { |value| !value.to_s.empty? }
54
57
  end
55
58
 
56
59
  def self.format_size(bytes)
@@ -62,17 +65,19 @@ module Fastlane
62
65
  #####################################################
63
66
 
64
67
  def self.description
65
- "Uploads an .ipa or .apk to pCloudy (My Apps), optionally re-signing the .ipa"
68
+ "Uploads an .ipa, .apk or .aab to pCloudy (My Apps), optionally re-signing the .ipa"
66
69
  end
67
70
 
68
71
  def self.details
69
72
  "Uploads the app built by build_app or gradle (or any file you pass) to pCloudy, waits until pCloudy has " \
70
73
  "registered it, and returns the name pCloudy stored it under. pCloudy adds a timestamp to the name when " \
71
- "a file with the same name already exists, so always use the returned name or PCLOUDY_UPLOADED_FILE."
74
+ "a file with the same name already exists, so always use the returned name or PCLOUDY_APP_FILE. " \
75
+ "The names are also set as environment variables, so test scripts started with sh can read " \
76
+ "PCLOUDY_APP_FILE directly."
72
77
  end
73
78
 
74
79
  def self.authors
75
- ["bikee1235"]
80
+ ["pCloudy"]
76
81
  end
77
82
 
78
83
  def self.return_value
@@ -91,7 +96,7 @@ module Fastlane
91
96
  Helper::PcloudyOptions.auth + [
92
97
  FastlaneCore::ConfigItem.new(key: :file,
93
98
  env_name: "PCLOUDY_APP_PATH",
94
- description: "Path to the .ipa or .apk. Defaults to the output of build_app or gradle",
99
+ description: "Path to the .ipa, .apk or .aab. Defaults to the output of build_app or gradle",
95
100
  optional: true,
96
101
  type: String),
97
102
  FastlaneCore::ConfigItem.new(key: :resign,
@@ -118,6 +123,10 @@ module Fastlane
118
123
  env_name: "PCLOUDY_RESIGN_TIMEOUT",
119
124
  description: "Seconds to wait for re-signing to finish (when resign: true)",
120
125
  default_value: 600,
126
+ type: Integer),
127
+ FastlaneCore::ConfigItem.new(key: :poll_interval,
128
+ description: "Seconds between re-sign progress checks (when resign: true)",
129
+ default_value: 5,
121
130
  type: Integer)
122
131
  ]
123
132
  end
@@ -1,5 +1,6 @@
1
1
  require "json"
2
2
  require "net/http"
3
+ require "openssl"
3
4
  require "uri"
4
5
 
5
6
  module Fastlane
@@ -11,6 +12,11 @@ module Fastlane
11
12
 
12
13
  DEFAULT_CLOUD_URL = "https://device.pcloudy.com".freeze
13
14
 
15
+ # Connection failures turned into Error. Net::OpenTimeout/ReadTimeout/WriteTimeout are Timeout::Errors.
16
+ NETWORK_ERRORS = [SocketError, Timeout::Error, EOFError, OpenSSL::SSL::SSLError,
17
+ Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE,
18
+ Errno::ETIMEDOUT, Errno::EHOSTUNREACH, Errno::ENETUNREACH].freeze
19
+
14
20
  def initialize(username:, api_key:, cloud_url: DEFAULT_CLOUD_URL, timeout: 60)
15
21
  @username = username
16
22
  @api_key = api_key
@@ -130,24 +136,42 @@ module Fastlane
130
136
  end
131
137
 
132
138
  path = request.path
133
- raise(Error, "pCloudy #{path} returned HTTP #{response.code}") unless response.is_a?(Net::HTTPSuccess)
139
+ unless response.is_a?(Net::HTTPSuccess)
140
+ message = error_message(parse_result(response.body))
141
+ raise(Error, "pCloudy #{path} returned HTTP #{response.code}#{message ? ": #{message}" : ''}")
142
+ end
134
143
 
135
144
  result = JSON.parse(response.body.to_s)["result"]
136
145
  raise(Error, "pCloudy #{path} returned an unexpected response") unless result.kind_of?(Hash)
137
146
 
138
147
  # Some endpoints (e.g. upload_file) omit "code"; treat an explicit error or a non-200 code as failure.
139
148
  if result["error"] || (result.key?("code") && result["code"].to_i != 200)
140
- message = result["error"] || result["msg"] || result["message"] || "unknown error"
141
- raise(Error, "pCloudy #{path} failed (code #{result['code'] || 'n/a'}): #{message}")
149
+ code = result.key?("code") ? " (code #{result['code']})" : ""
150
+ raise(Error, "pCloudy #{path} failed#{code}: #{error_message(result) || 'unknown error'}")
142
151
  end
143
152
 
144
153
  result
145
154
  rescue JSON::ParserError
146
155
  raise(Error, "pCloudy #{request.path} returned invalid JSON")
147
- rescue SocketError, Timeout::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, OpenSSL::SSL::SSLError => e
156
+ rescue *NETWORK_ERRORS => e
148
157
  raise(Error, "Could not reach pCloudy at #{@base}: #{e.message}")
149
158
  end
150
159
 
160
+ # The "result" hash of an error response body, or nil when the body is not pCloudy JSON.
161
+ def parse_result(body)
162
+ result = JSON.parse(body.to_s)["result"]
163
+ result.kind_of?(Hash) ? result : nil
164
+ rescue JSON::ParserError, TypeError
165
+ nil
166
+ end
167
+
168
+ def error_message(result)
169
+ return nil unless result
170
+
171
+ message = result["error"] || result["msg"] || result["message"]
172
+ message.to_s.empty? ? nil : message.to_s
173
+ end
174
+
151
175
  def endpoint(path)
152
176
  URI.join(@base.to_s.end_with?("/") ? @base.to_s : "#{@base}/", path.sub(%r{^/}, ""))
153
177
  end
@@ -27,6 +27,15 @@ module Fastlane
27
27
  ]
28
28
  end
29
29
 
30
+ # Stores a result in lane_context and in ENV under the same name, so lanes can read
31
+ # lane_context[SharedValues::PCLOUDY_APP_FILE] and test scripts started with sh(...)
32
+ # can read the environment variable PCLOUDY_APP_FILE without any extra wiring.
33
+ # A nil value clears both.
34
+ def self.export(key, value)
35
+ Actions.lane_context[key] = value
36
+ value.nil? ? ENV.delete(key.to_s) : ENV[key.to_s] = value.to_s
37
+ end
38
+
30
39
  def self.client(params)
31
40
  PcloudyClient.new(username: params[:username],
32
41
  api_key: params[:api_key],
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Pcloudy
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,34 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-pcloudy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - bikee1235
7
+ - pCloudy
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: bundler
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - ">="
17
- - !ruby/object:Gem::Version
18
- version: '1.17'
19
- - - "<"
20
- - !ruby/object:Gem::Version
21
- version: '3'
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- version: '1.17'
29
- - - "<"
30
- - !ruby/object:Gem::Version
31
- version: '3'
32
12
  - !ruby/object:Gem::Dependency
33
13
  name: fastlane
34
14
  requirement: !ruby/object:Gem::Requirement
@@ -92,10 +72,8 @@ dependencies:
92
72
  - !ruby/object:Gem::Version
93
73
  version: '3.0'
94
74
  description: 'Use pCloudy (device.pcloudy.com or a private cloud) from your fastlane
95
- lanes: list available real iOS and Android devices, upload the .ipa or .apk you
96
- just built, and re-sign iOS apps with pCloudy''s certificate.'
97
- email:
98
- - bikee.bihari@sstsinc.com
75
+ lanes: list available real iOS and Android devices, upload the .ipa, .apk or .aab
76
+ you just built, and re-sign iOS apps with pCloudy''s certificate.'
99
77
  executables: []
100
78
  extensions: []
101
79
  extra_rdoc_files: []
@@ -110,13 +88,11 @@ files:
110
88
  - lib/fastlane/plugin/pcloudy/helper/pcloudy_client.rb
111
89
  - lib/fastlane/plugin/pcloudy/helper/pcloudy_options.rb
112
90
  - lib/fastlane/plugin/pcloudy/version.rb
113
- homepage: https://github.com/Smart-Software-Testing-Solutions-Opkey/fastlane-plugin-pcloudy
91
+ homepage: https://www.pcloudy.com
114
92
  licenses:
115
93
  - MIT
116
94
  metadata:
117
- homepage_uri: https://github.com/Smart-Software-Testing-Solutions-Opkey/fastlane-plugin-pcloudy
118
- changelog_uri: https://github.com/Smart-Software-Testing-Solutions-Opkey/fastlane-plugin-pcloudy/blob/main/CHANGELOG.md
119
- bug_tracker_uri: https://github.com/Smart-Software-Testing-Solutions-Opkey/fastlane-plugin-pcloudy/issues
95
+ homepage_uri: https://www.pcloudy.com
120
96
  rubygems_mfa_required: 'true'
121
97
  rdoc_options: []
122
98
  require_paths: