fastlane-plugin-aws_device_farm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4cce46e2ac22ec1565b4e0138937c51f03338882
4
+ data.tar.gz: aefcb8f44f0ade00a4671c6ea13d3b995615b73b
5
+ SHA512:
6
+ metadata.gz: 03a1e55318a56e4dfbc393100324eceb7a07f2181eacddc8223c9de680baa18104819b28cc891e270f212ee45857987bddfa068ca8c6f0d775120b6b506e388f
7
+ data.tar.gz: a8ca81a261c65329662bd280cdea930c593b05505279b6f6e09b486b6ec53c810dcb46110469cc52d40180ccbe670685fe1777f26bef3f917a5b5f0aea9a30ef
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Helmut Januschka <h.januschka@krone.at>
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.
@@ -0,0 +1,52 @@
1
+ # aws_device_farm plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-aws_device_farm)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-aws_device_farm`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin aws_device_farm
11
+ ```
12
+
13
+ ## About aws_device_farm
14
+
15
+ Run UI Tests on AWS Devicefarm
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
+
21
+ 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`.
22
+
23
+ **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)
24
+
25
+ ## Run tests for this plugin
26
+
27
+ To run both the tests, and code style validation, run
28
+
29
+ ```
30
+ rake
31
+ ```
32
+
33
+ To automatically fix many of the styling issues, use
34
+ ```
35
+ rubocop -a
36
+ ```
37
+
38
+ ## Issues and Feedback
39
+
40
+ For any other issues and feedback about this plugin, please submit it to this repository.
41
+
42
+ ## Troubleshooting
43
+
44
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.
45
+
46
+ ## Using `fastlane` Plugins
47
+
48
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).
49
+
50
+ ## About `fastlane`
51
+
52
+ `fastlane` is the easiest way to automate building and releasing your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/aws_device_farm/version'
2
+
3
+ module Fastlane
4
+ module AwsDeviceFarm
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::AwsDeviceFarm.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,240 @@
1
+ require 'aws-sdk'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class AwsDeviceFarmAction < Action
6
+ def self.run(params)
7
+ Actions.verify_gem!('aws-sdk')
8
+ UI.message 'Preparing the upload to the device farm.'
9
+
10
+ # Instantiate the client.
11
+ @client = ::Aws::DeviceFarm::Client.new()
12
+
13
+ # Fetch the project
14
+ project = fetch_project params[:name]
15
+ raise "Project '#{params[:name]}' not found." if project.nil?
16
+
17
+ # Fetch the device pool.
18
+ device_pool = fetch_device_pool project, params[:device_pool]
19
+ raise "Device pool '#{params[:device_pool]}' not found. 🙈" if device_pool.nil?
20
+
21
+ # Create the upload.
22
+ path = File.join Dir.pwd, params[:binary_path]
23
+ type = File.extname(path) == '.apk' ? 'ANDROID_APP' : 'IOS_APP'
24
+ upload = create_project_upload project, path, type
25
+
26
+ # Upload the application binary.
27
+ UI.message 'Uploading the application binary. ☕️'
28
+ upload upload, path
29
+
30
+ # Upload the test package if needed.
31
+ test_upload = nil
32
+ if params[:test_binary_path]
33
+ test_path = File.join Dir.pwd, params[:test_binary_path]
34
+ if type == "ANDROID_APP"
35
+ test_upload = create_project_upload project, test_path, 'INSTRUMENTATION_TEST_PACKAGE'
36
+ else
37
+
38
+ test_upload = create_project_upload project, test_path, 'XCTEST_UI_TEST_PACKAGE'
39
+ end
40
+
41
+ # Upload the test binary.
42
+ UI.message 'Uploading the test binary. ☕️'
43
+ upload test_upload, test_path
44
+
45
+ # Wait for test upload to finish.
46
+ UI.message 'Waiting for the test upload to succeed. ☕️'
47
+ test_upload = wait_for_upload test_upload
48
+ raise 'Test upload failed. 🙈' unless test_upload.status == 'SUCCEEDED'
49
+ end
50
+
51
+ # Wait for upload to finish.
52
+ UI.message 'Waiting for the application upload to succeed. ☕️'
53
+ upload = wait_for_upload upload
54
+ raise 'Binary upload failed. 🙈' unless upload.status == 'SUCCEEDED'
55
+
56
+ # Schedule the run.
57
+ run = schedule_run project, device_pool, upload, test_upload, type
58
+
59
+ # Wait for run to finish.
60
+ if params[:wait_for_completion]
61
+ UI.message 'Waiting for the run to complete. ☕️'
62
+ run = wait_for_run run
63
+ raise "#{run.message} 🙈" unless %w(PASSED WARNED).include? run.result
64
+
65
+ UI.message 'Successfully tested the application on the AWS device farm. ✅'.green
66
+ else
67
+ UI.message 'Successfully scheduled the tests on the AWS device farm. ✅'.green
68
+ end
69
+ end
70
+
71
+ #####################################################
72
+ # @!group Documentation
73
+ #####################################################
74
+
75
+ def self.description
76
+ 'Upload the application to the AWS device farm.'
77
+ end
78
+
79
+ def self.details
80
+ 'Upload the application to the AWS device farm.'
81
+ end
82
+
83
+ def self.available_options
84
+ [
85
+ FastlaneCore::ConfigItem.new(
86
+ key: :name,
87
+ env_name: 'FL_AWS_DEVICE_FARM_NAME',
88
+ description: 'Define the name of the device farm project',
89
+ is_string: true,
90
+ optional: false
91
+ ),
92
+ FastlaneCore::ConfigItem.new(
93
+ key: :binary_path,
94
+ env_name: 'FL_AWS_DEVICE_FARM_PATH',
95
+ description: 'Define the path of the application binary (apk or ipa) to upload to the device farm project',
96
+ is_string: true,
97
+ optional: false,
98
+ verify_block: proc do |value|
99
+ path = File.join Dir.pwd, value
100
+ raise "Application binary not found at path '#{path}'. 🙈".red unless File.exist?(path)
101
+ end
102
+ ),
103
+ FastlaneCore::ConfigItem.new(
104
+ key: :test_binary_path,
105
+ env_name: 'FL_AWS_DEVICE_FARM_TEST_PATH',
106
+ description: 'Define the path of the test binary (apk) to upload to the device farm project',
107
+ is_string: true,
108
+ optional: true,
109
+ verify_block: proc do |value|
110
+ path = File.join Dir.pwd, value
111
+ raise "Test binary not found at path '#{path}'. 🙈".red unless File.exist?(path)
112
+ end
113
+ ),
114
+ FastlaneCore::ConfigItem.new(
115
+ key: :path,
116
+ env_name: 'FL_AWS_DEVICE_FARM_PATH',
117
+ description: 'Define the path of the application binary (apk or ipa) to upload to the device farm project',
118
+ is_string: true,
119
+ optional: false
120
+ ),
121
+ FastlaneCore::ConfigItem.new(
122
+ key: :device_pool,
123
+ env_name: 'FL_AWS_DEVICE_FARM_POOL',
124
+ description: 'Define the device pool you want to use for running the applications',
125
+ is_string: true,
126
+ optional: false
127
+ ),
128
+ FastlaneCore::ConfigItem.new(
129
+ key: :wait_for_completion,
130
+ env_name: 'FL_AWS_DEVICE_FARM_WAIT_FOR_COMPLETION',
131
+ description: 'Wait for the scheduled run to complete',
132
+ is_string: false,
133
+ optional: true,
134
+ default_value: true
135
+ )
136
+ ]
137
+ end
138
+
139
+ def self.output
140
+ []
141
+ end
142
+
143
+ def self.return_value
144
+ end
145
+
146
+ def self.authors
147
+ ["fousa/fousa", "hjanuschka"]
148
+ end
149
+
150
+ def self.is_supported?(platform)
151
+ platform == :ios || platform == :android
152
+ end
153
+
154
+ private
155
+
156
+ POLLING_INTERVAL = 10
157
+
158
+ def self.fetch_project(name)
159
+ projects = @client.list_projects.projects
160
+ projects.detect { |p| p.name == name }
161
+ end
162
+
163
+ def self.create_project_upload(project, path, type)
164
+ @client.create_upload({
165
+ project_arn: project.arn,
166
+ name: File.basename(path),
167
+ content_type: 'application/octet-stream',
168
+ type: type
169
+ }).upload
170
+ end
171
+
172
+ def self.upload(upload, path)
173
+ url = URI.parse(upload.url)
174
+ contents = File.open(path, 'rb').read
175
+ Net::HTTP.start(url.host) do |http|
176
+ http.send_request("PUT", url.request_uri, contents, { 'content-type' => 'application/octet-stream' })
177
+ end
178
+ end
179
+
180
+ def self.fetch_upload_status(upload)
181
+ @client.get_upload({
182
+ arn: upload.arn
183
+ }).upload
184
+ end
185
+
186
+ def self.wait_for_upload(upload)
187
+ upload = fetch_upload_status upload
188
+ while upload.status == 'PROCESSING'
189
+ sleep POLLING_INTERVAL
190
+ upload = fetch_upload_status upload
191
+ end
192
+
193
+ upload
194
+ end
195
+
196
+ def self.fetch_device_pool(project, device_pool)
197
+ device_pools = @client.list_device_pools({
198
+ arn: project.arn
199
+ })
200
+ device_pools.device_pools.detect { |p| p.name == device_pool }
201
+ end
202
+
203
+ def self.schedule_run(project, device_pool, upload, test_upload, type)
204
+ # Prepare the test hash depening if you passed the test apk.
205
+ test_hash = { type: 'BUILTIN_FUZZ' }
206
+ if test_upload
207
+ test_hash[:type] = 'XCTEST_UI'
208
+ if type == "ANDROID_APP"
209
+ test_hash[:type] = 'INSTRUMENTATION'
210
+ end
211
+ test_hash[:test_package_arn] = test_upload.arn
212
+ end
213
+
214
+ @client.schedule_run({
215
+ project_arn: project.arn,
216
+ app_arn: upload.arn,
217
+ device_pool_arn: device_pool.arn,
218
+ test: test_hash
219
+ }).run
220
+ end
221
+
222
+ def self.fetch_run_status(run)
223
+ @client.get_run({
224
+ arn: run.arn
225
+ }).run
226
+ end
227
+
228
+ def self.wait_for_run(run)
229
+ while run.status != 'COMPLETED'
230
+ sleep POLLING_INTERVAL
231
+ run = fetch_run_status run
232
+ end
233
+ UI.message "The run ended with result #{run.result}."
234
+
235
+ run
236
+ end
237
+ end
238
+ end
239
+ end
240
+
@@ -0,0 +1,12 @@
1
+ module Fastlane
2
+ module Helper
3
+ class AwsDeviceFarmHelper
4
+ # class methods that you define here become available in your action
5
+ # as `Helper::AwsDeviceFarmHelper.your_method`
6
+ #
7
+ def self.show_message
8
+ UI.message("Hello from the aws_device_farm plugin helper!")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module AwsDeviceFarm
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-aws_device_farm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Helmut Januschka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fastlane
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.105.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.105.0
97
+ description:
98
+ email: h.januschka@krone.at
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - LICENSE
104
+ - README.md
105
+ - lib/fastlane/plugin/aws_device_farm.rb
106
+ - lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb
107
+ - lib/fastlane/plugin/aws_device_farm/helper/aws_device_farm_helper.rb
108
+ - lib/fastlane/plugin/aws_device_farm/version.rb
109
+ homepage:
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.8
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Run UI Tests on AWS Devicefarm
133
+ test_files: []