fastlane-plugin-browserstack 0.1.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +49 -0
- data/lib/fastlane/plugin/browserstack.rb +16 -0
- data/lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb +117 -0
- data/lib/fastlane/plugin/browserstack/helper/browserstack_helper.rb +46 -0
- data/lib/fastlane/plugin/browserstack/version.rb +5 -0
- metadata +195 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ccb7886b844e0140c328aa55be44dba043bf1f34e35d5ca5ac8fd08b52139e52
|
4
|
+
data.tar.gz: 77374e5968af3c0d59b8bab572cd30cba18907dea3652a78a44f4d1e80dc2492
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b86a0abf7a9af9cadb98000cfcb4244026675499da55be47f752cc4a66ec454aed14fb4d04eef737a540ad8287df4b986c14af9257d16057b60fb657347adbdf
|
7
|
+
data.tar.gz: cc186b6bc2d13757a7db57863243e6a36bc9b7f92c936f25250bb4bb203fd26141908f414b5b737987e127eac03581e4c74d274f6523c7bd5f5208af2bd5a4e2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 BrowserStack
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# browserstack-fastlane-plugin
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/fastlane-plugin-browserstack)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-browserstack`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin browserstack
|
11
|
+
```
|
12
|
+
|
13
|
+
## About browserstack
|
14
|
+
|
15
|
+
Uploads IPA and APK files to BrowserStack for automation testing.
|
16
|
+
|
17
|
+
## Example
|
18
|
+
|
19
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by including that in your project's Fastfile, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
20
|
+
|
21
|
+
## Run tests for this plugin
|
22
|
+
|
23
|
+
To run both the tests, and code style validation, run
|
24
|
+
|
25
|
+
```
|
26
|
+
rake
|
27
|
+
```
|
28
|
+
|
29
|
+
To automatically fix many of the styling issues, use
|
30
|
+
```
|
31
|
+
rubocop -a
|
32
|
+
```
|
33
|
+
|
34
|
+
## Issues and Feedback
|
35
|
+
|
36
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
37
|
+
|
38
|
+
## Troubleshooting
|
39
|
+
|
40
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
41
|
+
|
42
|
+
## Using _fastlane_ Plugins
|
43
|
+
|
44
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
45
|
+
|
46
|
+
## About _fastlane_
|
47
|
+
|
48
|
+
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
49
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/browserstack/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Browserstack
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::Browserstack.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/browserstack_helper'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
module Actions
|
7
|
+
module SharedValues
|
8
|
+
BROWSERSTACK_APP_ID ||= :BROWSERSTACK_APP_ID
|
9
|
+
end
|
10
|
+
class UploadToBrowserstackAppAutomateAction < Action
|
11
|
+
SUPPORTED_FILE_EXTENSIONS = ["apk", "ipa"]
|
12
|
+
UPLOAD_API_ENDPOINT = "https://api-cloud.browserstack.com/app-automate/upload"
|
13
|
+
|
14
|
+
def self.run(params)
|
15
|
+
browserstack_username = params[:browserstack_username] # Required
|
16
|
+
browserstack_access_key = params[:browserstack_access_key] # Required
|
17
|
+
file_path = params[:file_path].to_s # Required
|
18
|
+
|
19
|
+
validate_file_path(file_path)
|
20
|
+
|
21
|
+
UI.message("Uploading app to BrowserStack AppAutomate...")
|
22
|
+
|
23
|
+
browserstack_app_id = Helper::BrowserstackHelper.upload_file(browserstack_username, browserstack_access_key, file_path, UPLOAD_API_ENDPOINT)
|
24
|
+
|
25
|
+
# Set 'BROWSERSTACK_APP_ID' environment variable, if app upload was successful.
|
26
|
+
ENV['BROWSERSTACK_APP_ID'] = browserstack_app_id
|
27
|
+
|
28
|
+
UI.success("Successfully uploaded app " + file_path + " to BrowserStack AppAutomate with app_url : " + browserstack_app_id)
|
29
|
+
|
30
|
+
UI.success("Setting Environment variable BROWSERSTACK_APP_ID = " + browserstack_app_id)
|
31
|
+
|
32
|
+
# Setting app id in SharedValues, which can be used by other fastlane actions.
|
33
|
+
Actions.lane_context[SharedValues::BROWSERSTACK_APP_ID] = browserstack_app_id
|
34
|
+
end
|
35
|
+
|
36
|
+
# Validate file_path.
|
37
|
+
def self.validate_file_path(file_path)
|
38
|
+
UI.user_error!("No file found at '#{file_path}'.") unless File.exist?(file_path)
|
39
|
+
|
40
|
+
# Validate file extension.
|
41
|
+
file_path_parts = file_path.split(".")
|
42
|
+
unless file_path_parts.length > 1 && SUPPORTED_FILE_EXTENSIONS.include?(file_path_parts.last)
|
43
|
+
UI.user_error!("file_path is invalid, only files with extensions apk and ipa are allowed to be uploaded.")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.description
|
48
|
+
"Uploads IPA and APK files to BrowserStack AppAutomate for running automated tests."
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.authors
|
52
|
+
["Hitesh Raghuvanshi"]
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.details
|
56
|
+
"Uploads IPA and APK files to BrowserStack AppAutomate for running automated tests."
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.output
|
60
|
+
[
|
61
|
+
['BROWSERSTACK_APP_ID', 'App id of uploaded app.']
|
62
|
+
]
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.default_file_path
|
66
|
+
platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
|
67
|
+
|
68
|
+
if platform == :ios
|
69
|
+
# Shared value for ipa path if it was generated by gym https://docs.fastlane.tools/actions/gym/.
|
70
|
+
return Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH]
|
71
|
+
else
|
72
|
+
# Shared value for apk if it was generated by gradle.
|
73
|
+
return Actions.lane_context[Actions::SharedValues::GRADLE_APK_OUTPUT_PATH]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.available_options
|
78
|
+
[
|
79
|
+
FastlaneCore::ConfigItem.new(key: :browserstack_username,
|
80
|
+
description: "BrowserStack's username",
|
81
|
+
optional: false,
|
82
|
+
is_string: true,
|
83
|
+
verify_block: proc do |value|
|
84
|
+
UI.user_error!("No browserstack_username given.") if value.to_s.empty?
|
85
|
+
end),
|
86
|
+
FastlaneCore::ConfigItem.new(key: :browserstack_access_key,
|
87
|
+
description: "BrowserStack's access key",
|
88
|
+
optional: false,
|
89
|
+
is_string: true,
|
90
|
+
verify_block: proc do |value|
|
91
|
+
UI.user_error!("No browserstack_access_key given.") if value.to_s.empty?
|
92
|
+
end),
|
93
|
+
FastlaneCore::ConfigItem.new(key: :file_path,
|
94
|
+
description: "Path to the app file",
|
95
|
+
optional: true,
|
96
|
+
is_string: true,
|
97
|
+
default_value: default_file_path)
|
98
|
+
]
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.is_supported?(platform)
|
102
|
+
[:ios, :android].include?(platform)
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.example_code
|
106
|
+
[
|
107
|
+
'upload_to_browserstack_app_automate',
|
108
|
+
'upload_to_browserstack_app_automate(
|
109
|
+
browserstack_username: ENV["BROWSERSTACK_USERNAME"],
|
110
|
+
browserstack_access_key: ENV["BROWSERSTACK_ACCESS_KEY"],
|
111
|
+
file_path: "path_to_apk_or_ipa_file"
|
112
|
+
)'
|
113
|
+
]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
6
|
+
|
7
|
+
module Helper
|
8
|
+
class BrowserstackHelper
|
9
|
+
# class methods that you define here become available in your action
|
10
|
+
# as `Helper::BrowserstackHelper.your_method`
|
11
|
+
#
|
12
|
+
def self.show_message
|
13
|
+
UI.message("Hello from the browserstack plugin helper!")
|
14
|
+
end
|
15
|
+
|
16
|
+
# Uploads file to BrowserStack
|
17
|
+
# Params :
|
18
|
+
# +browserstack_username+:: BrowserStack's username.
|
19
|
+
# +browserstack_access_key+:: BrowserStack's access key.
|
20
|
+
# +file_path+:: Path to the file to be uploaded.
|
21
|
+
# +url+:: BrowserStack's app upload endpoint.
|
22
|
+
def self.upload_file(browserstack_username, browserstack_access_key, file_path, url)
|
23
|
+
begin
|
24
|
+
response = RestClient::Request.execute(
|
25
|
+
method: :post,
|
26
|
+
url: url,
|
27
|
+
user: browserstack_username,
|
28
|
+
password: browserstack_access_key,
|
29
|
+
payload: {
|
30
|
+
multipart: true,
|
31
|
+
file: File.new(file_path, 'rb')
|
32
|
+
}
|
33
|
+
)
|
34
|
+
rescue RestClient::ExceptionWithResponse => err
|
35
|
+
error_response = err.response
|
36
|
+
end
|
37
|
+
|
38
|
+
# Return app_url if file was uploaded successfully.
|
39
|
+
return JSON.parse(response.to_s)["app_url"] unless response.nil?
|
40
|
+
|
41
|
+
# Give error if upload failed.
|
42
|
+
UI.user_error!("App upload failed!!! Reason : " + JSON.parse(error_response.to_s)["error"]) unless error_response.nil?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-browserstack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- BrowserStack
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: pry
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec_junit_formatter
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rake
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rubocop
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - '='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.49.1
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 0.49.1
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rubocop-require_tools
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: simplecov
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: fastlane
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 2.96.1
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 2.96.1
|
159
|
+
description:
|
160
|
+
email: support@browserstack.com
|
161
|
+
executables: []
|
162
|
+
extensions: []
|
163
|
+
extra_rdoc_files: []
|
164
|
+
files:
|
165
|
+
- LICENSE
|
166
|
+
- README.md
|
167
|
+
- lib/fastlane/plugin/browserstack.rb
|
168
|
+
- lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb
|
169
|
+
- lib/fastlane/plugin/browserstack/helper/browserstack_helper.rb
|
170
|
+
- lib/fastlane/plugin/browserstack/version.rb
|
171
|
+
homepage: https://github.com/browserstack/browserstack-fastlane-plugin
|
172
|
+
licenses:
|
173
|
+
- MIT
|
174
|
+
metadata: {}
|
175
|
+
post_install_message:
|
176
|
+
rdoc_options: []
|
177
|
+
require_paths:
|
178
|
+
- lib
|
179
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
requirements: []
|
190
|
+
rubyforge_project:
|
191
|
+
rubygems_version: 2.7.6
|
192
|
+
signing_key:
|
193
|
+
specification_version: 4
|
194
|
+
summary: Uploads IPA and APK files to BrowserStack for automation testing.
|
195
|
+
test_files: []
|