fastlane-plugin-lambdatest 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2c29d18b65ecf78e982c1fb33779bc322dc9ae2333f82abd22b5cdb55fdb929e
4
+ data.tar.gz: 7d99ee13cc4608d156e6b61de36d9aa357da2f3ef353b4c33e85541f7e7166f3
5
+ SHA512:
6
+ metadata.gz: 3d6da40b7f481dee047c1788ed5a2d9ba9107415d5a541ac80e2a55ab0a2a3998cc44f2f3a32122c3d68f9a14f2ed6c42ebbaf1588132c7cdc448d32645a0a5f
7
+ data.tar.gz: 1039cc02f134c81f014713edf66a3fa24042625621d3683f38936ec13febe1f7a2267067880d286b8b424e7ae91342dbaabbec86f84e8fbc793a0d2a72e6eadc
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 lambdatest <pawanr@lambdatest.com>
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,68 @@
1
+ # lambdatest plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-lambdatest)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-lambdatest`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin lambdatest
11
+ ```
12
+
13
+ ## About lambdatest
14
+
15
+ Upload apps to lambdatest for testing.
16
+
17
+ **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
18
+
19
+ ## Example
20
+ In order to configure the plugin add below action in your Fastfile.
21
+
22
+ ```
23
+ upload_to_lambdatest(
24
+ lt_username: ENV["LT_USERNAME"],
25
+ lt_access_key: ENV["LT_ACCESS_KEY"],
26
+ file_path: "app_file_path"
27
+ )
28
+ ```
29
+
30
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
31
+
32
+ Once the app is uploaded , the app_url of the app will be stored in an environment variable, "APP_URL" and it can be accessed in your tests in the following way :
33
+
34
+ ```
35
+ String app = System.getenv("APP_URL"); // Get app url from environment variable.
36
+ capabilities.setCapability("app", app); // Add app url to driver capability.
37
+ ```
38
+
39
+ **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
40
+
41
+ ## Run tests for this plugin
42
+
43
+ To run both the tests, and code style validation, run
44
+
45
+ ```
46
+ rake
47
+ ```
48
+
49
+ To automatically fix many of the styling issues, use
50
+ ```
51
+ rubocop -a
52
+ ```
53
+
54
+ ## Issues and Feedback
55
+
56
+ For any other issues and feedback about this plugin, please submit it to this repository.
57
+
58
+ ## Troubleshooting
59
+
60
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
61
+
62
+ ## Using _fastlane_ Plugins
63
+
64
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
65
+
66
+ ## About _fastlane_
67
+
68
+ _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).
@@ -0,0 +1,118 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/lambdatest_helper'
3
+ require 'json'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ module SharedValues
8
+ APP_URL ||= :APP_URL
9
+ end
10
+ class UploadToLambdatestAction < Action
11
+
12
+ UPLOAD_API_ENDPOINT = "https://manual-api.lambdatest.com/app/upload/realDevice"
13
+ SUPPORTED_FILE_EXTENSIONS = ["apk", "ipa", "aab"]
14
+
15
+ def self.run(params)
16
+ lt_username = params[:lt_username] # Required
17
+ lt_access_key = params[:lt_access_key] # Required
18
+ file_path = params[:file_path].to_s # Required
19
+
20
+ validate_file_path(file_path)
21
+
22
+ UI.message("Started Uploading app to Lambdatest...")
23
+
24
+ lt_app_url = Helper::LambdatestHelper.upload_file(lt_username, lt_access_key, file_path, UPLOAD_API_ENDPOINT)
25
+
26
+ # Set 'APP_URL' environment variable, if app upload was successful.
27
+ ENV['APP_URL'] = lt_app_url
28
+
29
+
30
+ UI.success("Successfully uploaded app " + file_path + " to Lambdatest with app_url : " + lt_app_url + " ✅ ")
31
+
32
+ UI.success("Setting Environment variable APP_URL = " + lt_app_url)
33
+
34
+ # Setting APP_URL in SharedValues, which can be used by other fastlane actions.
35
+ Actions.lane_context[SharedValues::APP_URL] = lt_app_url
36
+ end
37
+
38
+ # Validate file_path.
39
+ def self.validate_file_path(file_path)
40
+ UI.user_error!("file not found at '#{file_path}' ❌ .") unless File.exist?(file_path)
41
+
42
+ # Validate file extension.
43
+ file_path_parts = file_path.split(".")
44
+ unless file_path_parts.length > 1 && SUPPORTED_FILE_EXTENSIONS.include?(file_path_parts.last)
45
+ UI.user_error!("Invalid file extension, only files with extensions " + SUPPORTED_FILE_EXTENSIONS.to_s + " are allowed to be uploaded.")
46
+ end
47
+ end
48
+
49
+ def self.description
50
+ "LambdaTest fastlane plugin for android and ios apps."
51
+ end
52
+
53
+ def self.authors
54
+ ["Pawan Rai"]
55
+ end
56
+
57
+ def self.details
58
+ "Uploads IPA and APK files to Lambdatest for test."
59
+ end
60
+
61
+ def self.default_file_path
62
+ platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
63
+ if platform == :ios
64
+ # Shared value for ipa path if it was generated by gym https://docs.fastlane.tools/actions/gym/.
65
+ return Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH]
66
+ else
67
+ # Shared value for apk if it was generated by gradle.
68
+ return Actions.lane_context[Actions::SharedValues::GRADLE_APK_OUTPUT_PATH]
69
+ end
70
+ end
71
+
72
+ def self.available_options
73
+ [
74
+ FastlaneCore::ConfigItem.new(key: :lt_username,
75
+ description: "Lambdatest's username",
76
+ optional: false,
77
+ is_string: true,
78
+ verify_block: proc do |value|
79
+ UI.user_error!("No LT username given.") if value.to_s.empty?
80
+ end),
81
+ FastlaneCore::ConfigItem.new(key: :lt_access_key,
82
+ description: "Lambdatest's access token",
83
+ optional: false,
84
+ is_string: true,
85
+ verify_block: proc do |value|
86
+ UI.user_error!("No lt_access_key given.") if value.to_s.empty?
87
+ end),
88
+ FastlaneCore::ConfigItem.new(key: :file_path,
89
+ description: "app file path",
90
+ optional: true,
91
+ is_string: true,
92
+ default_value: default_file_path)
93
+ ]
94
+ end
95
+
96
+ def self.is_supported?(platform)
97
+ [:ios, :android].include?(platform)
98
+ end
99
+
100
+ def self.output
101
+ [
102
+ ['APP_URL', 'App URL of uploaded app.']
103
+ ]
104
+ end
105
+
106
+ def self.example_code
107
+ [
108
+ 'upload_to_lambdatest',
109
+ 'upload_to_lambdatest(
110
+ lt_username: ENV["LT_USERNAME"],
111
+ lt_access_key: ENV["LT_ACCESS_KEY"],
112
+ file_path: "path_to_app_file"
113
+ )'
114
+ ]
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,66 @@
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 LambdatestHelper
9
+ # class methods that you define here become available in your action
10
+ # as `Helper::LambdatestHelper.your_method`
11
+ #
12
+ def self.show_message
13
+ UI.message("Hello from the Lambdatest plugin helper!")
14
+ end
15
+
16
+ # Uploads file to Lambdatest
17
+ # Params :
18
+ # +lt_username+:: Lambdatest's username.
19
+ # +lt_access_key+:: Lambdatest's access key.
20
+ # +custom_id+:: Custom id for app upload.
21
+ # +file_path+:: Path to the file to be uploaded.
22
+ # +url+:: Lambdatest's app upload endpoint.
23
+ def self.upload_file(lt_username, lt_access_key, file_path, url, custom_id = nil)
24
+ payload = {
25
+ name: "xyz",
26
+ appFile: File.new(file_path, 'rb')
27
+ }
28
+
29
+ unless custom_id.nil?
30
+ payload[:data] = '{ "custom_id": "' + custom_id + '" }'
31
+ end
32
+
33
+ headers = {
34
+ "User-Agent" => "fastlane_plugin_lambdatest"
35
+ }
36
+ begin
37
+ response = RestClient::Request.execute(
38
+ method: :post,
39
+ url: url,
40
+ user: lt_username,
41
+ password: lt_access_key,
42
+ payload: payload,
43
+ headers: headers
44
+ )
45
+ response_json = JSON.parse(response.to_s)
46
+
47
+ if !response_json["custom_id"].nil?
48
+ return response_json["custom_id"]
49
+ else
50
+ return response_json["app_url"]
51
+ end
52
+ rescue RestClient::ExceptionWithResponse => err
53
+ begin
54
+ error_response = JSON.parse(err.response.to_s)["message"]
55
+ rescue
56
+ error_response = "Internal server error"
57
+ end
58
+ # Give error if upload failed.
59
+ UI.user_error!("App upload failed!!! Reason : #{error_response}")
60
+ rescue StandardError => error
61
+ UI.user_error!("App upload failed!!! Reason : #{error.message}")
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Lambdatest
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/lambdatest/version'
2
+
3
+ module Fastlane
4
+ module Lambdatest
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::Lambdatest.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-lambdatest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - LambdaTest
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-12 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@lambdatest.com
161
+ executables: []
162
+ extensions: []
163
+ extra_rdoc_files: []
164
+ files:
165
+ - LICENSE
166
+ - README.md
167
+ - lib/fastlane/plugin/lambdatest.rb
168
+ - lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb
169
+ - lib/fastlane/plugin/lambdatest/helper/lambdatest_helper.rb
170
+ - lib/fastlane/plugin/lambdatest/version.rb
171
+ homepage: https://github.com/LambdaTest/lambdatest-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
+ rubygems_version: 3.0.1
191
+ signing_key:
192
+ specification_version: 4
193
+ summary: fastlane plugin to upload app to lambdatest
194
+ test_files: []