fastlane-plugin-saucectl 0.1.0.pre.beta.2 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e57867e9ee59c0310b1a657cc77cedad2b6ecd0e7baa01cb03b4862198790b0
4
- data.tar.gz: e1e6583d43e376f642cec87a05d8cc8cd67d542878b142d8baa0bbac985d4ff9
3
+ metadata.gz: ecc67f53ebd122fc5083aeb466912f6cec328f7d5f966221c504c02577aa9534
4
+ data.tar.gz: c735f2e42ff6199e6429a9d8927a6164e59adce8d1e08dd6633a6bcef9e6d0fe
5
5
  SHA512:
6
- metadata.gz: 74976f753280b80f14e02865179eafb767066988bfbb4ac59ff4cf9564468d29ce4a7bde7b11a642d5d03ceba8a592bcfe955479985387a763799d8d1cd6b747
7
- data.tar.gz: 85ab453571d3de28d56e6ed9460708d3f5e40af21e2a1f1d24987b26caa2a9ea68e556df0080154dc2389ffe13dd7743b4b5d00bcc3c99c5a215d57cb6923806
6
+ metadata.gz: 5057e84ec4249ff5d9568a94838334c4324ffbc08be2d4fe83510a771b56512800adce790c8f4169eba62d30957a724401befab78c0f224e79b0db4fcf4faad6
7
+ data.tar.gz: 29bcaa1636728cb1915d135267233d7601901a1a6619d12c75bbef23c91dc513a470345e1306f620930c62e68b4e39ce3f43fd65228a10d5c510e6a4831b9579
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Ian Hamilton <ian.ross.hamilton@gmail.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,81 @@
1
+ # fastlane-plugin-saucectl
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-saucectl)
4
+ [![Gem Version](https://badge.fury.io/rb/fastlane-plugin-saucectl.svg)](https://badge.fury.io/rb/fastlane-plugin-saucectl)
5
+ [![Gem Downloads](https://img.shields.io/gem/dt/fastlane-plugin-saucectl?color=light-green)](https://img.shields.io/gem/dt/fastlane-plugin-saucectl)
6
+
7
+ ## Getting Started
8
+
9
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-saucectl`, add it to your project by running:
10
+
11
+ ```bash
12
+ fastlane add_plugin saucectl
13
+ ```
14
+
15
+ ## About fastlane-plugin-saucectl
16
+
17
+ The purpose of this plugin is to simplify the set up, configuration, upload, and execution of espresso and XCUITest on the Sauce Labs platform by utilizing fastlane which will enable you to test your iOS and Android apps at scale.
18
+
19
+ **IMPORTANT:** in order for you to use this plugin to execute UI tests, your test class names must proceed with `Spec`, `Specs`, `Tests`, or `Test`, for example `ExampleSpec`, `ExampleSpecs`, `ExampleTest`, `ExampleTests`. Your test case names must also begin with test, for example `testIDoSomething`, `testIDoSomethingElse`. This is so that the the plugin can search for test classes and their included test cases.
20
+
21
+ Failure to do this will result in missing test classes and test cases from your test run.
22
+
23
+ **For a detailed introduction to each of the actions available within this plugin, please see the [documentation](https://ianrhamilton.github.io/fastlane-plugin-saucectl/#fastlane-plugin-saucectl)**.
24
+
25
+ | Available Actions | Description |
26
+ |---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
27
+ | `install_saucectl` | Downloads the Sauce Labs saucectl cli binary for test execution. Optionally specify the [version](https://github.com/saucelabs/saucectl/releases/) you wish to install or automatically download the latest. |
28
+ | `sauce_upload` | Upload test artifacts to sauce labs storage |
29
+ | `sauce_config` | Create SauceLabs configuration file for test execution based on given parameters |
30
+ | `sauce_runner` | Execute automated tests on sauce labs platform via saucectl binary for specified configuration |
31
+ | `delete_from_storage` | Delete test artifacts from sauce labs storage by storage id or group id |
32
+ | `sauce_apps` | Returns the set of files by specific app id that have been uploaded to Sauce Storage by the requester |
33
+ | `sauce_devices` | Returns a list of Device IDs for all devices in the data center that are currently free for testing. |
34
+ | `disabled_tests` | Fetches any disabled ui test cases (for android searches for @Ignore tests, and for ios skipped tests within an xcode test plan). Plan is to use this in the future for generating pretty HTML reports |
35
+
36
+ An order of which you may utilize the above actions in your continuous integration platform could be:
37
+ 1. Install the saucectl binary via `install_saucectl`
38
+ 2. Upload your test artifacts to Sauce Labs storage (for example app apk, and test runner apk)
39
+ 3. Create config.yml for given parameters via `sauce_config`
40
+ 4. Execute test based on specified config via `sauce_runner`
41
+ 5. Delete test artifacts via `delete_from_storage` so that your storage does not fill up (if you're executing tests on every PR, for example)
42
+
43
+ ## Example
44
+
45
+ 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`.
46
+
47
+ **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)
48
+
49
+ ## Run tests for this plugin
50
+
51
+ To run both the tests, and code style validation, run
52
+
53
+ ```
54
+ rake
55
+ ```
56
+
57
+ To automatically fix many of the styling issues, use
58
+ ```
59
+ rubocop -a
60
+ ```
61
+
62
+ ## Issues and Feedback
63
+
64
+ For any other issues and feedback about this plugin, please submit it to this repository.
65
+
66
+ ## Troubleshooting
67
+
68
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
69
+
70
+ ## Using _fastlane_ Plugins
71
+
72
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
73
+
74
+ ## About _fastlane_
75
+
76
+ _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).
77
+
78
+ ## Buy me a coffee
79
+ If you're enjoying this plugin, feel free to **optionally** buy me a coffee :)
80
+
81
+ [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/ianrhamilton)
@@ -32,6 +32,10 @@ module Fastlane
32
32
  "Fetches any disabled ui test cases (for android searches for @Ignore tests, and for ios skipped tests within an xcode test plan). Will be used in future for generating pretty HTML reports"
33
33
  end
34
34
 
35
+ def self.details
36
+ "Fetches any disabled ui test cases (for android searches for @Ignore tests, and for ios skipped tests within an xcode test plan). Will be used in future for generating pretty HTML reports"
37
+ end
38
+
35
39
  def self.available_options
36
40
  [
37
41
  FastlaneCore::ConfigItem.new(key: :platform,
@@ -0,0 +1,44 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/installer'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class InstallSaucectlAction < Action
7
+ def self.run(version = nil)
8
+ version_message = version[:version].nil? ? 'Installing with latest version of saucectl' : "Installing saucectl with version #{version[:version]}"
9
+ UI.message("#{version_message} 🤖 🚀")
10
+ installer = Saucectl::Installer.new
11
+ installer.install(version)
12
+ end
13
+
14
+ def self.description
15
+ "Installs the Sauce Labs saucectl cli binary"
16
+ end
17
+
18
+ def self.details
19
+ "Optionally set the tag of the version you wish to install. If not tag is set, the latest tag will be downloaded. See: https://github.com/saucelabs/saucectl/tags "
20
+ end
21
+
22
+ def self.available_options
23
+ [
24
+ FastlaneCore::ConfigItem.new(key: :version,
25
+ description: "Set the tag of saucectl you wish to install",
26
+ optional: true,
27
+ type: String)
28
+ ]
29
+ end
30
+
31
+ def self.authors
32
+ ["Ian Hamilton"]
33
+ end
34
+
35
+ def self.category
36
+ :testing
37
+ end
38
+
39
+ def self.is_supported?(platform)
40
+ [:ios, :android].include?(platform)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -81,6 +81,14 @@ module Fastlane
81
81
  description: "Array of tests to execute",
82
82
  optional: true,
83
83
  type: Array),
84
+ FastlaneCore::ConfigItem.new(key: :size,
85
+ description: "Instructs saucectl to run only tests that are annotated with the matching size value i.e @SmallTest, @MediumTest or @LargeTest. Valid values are small, medium, or large. You may only specify one value for this property",
86
+ optional: true,
87
+ type: String),
88
+ FastlaneCore::ConfigItem.new(key: :annotation,
89
+ description: "Instructs saucectl to run only tests that match a custom annotation that you have set",
90
+ optional: true,
91
+ type: String),
84
92
  FastlaneCore::ConfigItem.new(key: :emulators,
85
93
  description: "The parent property that defines details for running this suite on virtual devices using an emulator",
86
94
  optional: true,
@@ -13,6 +13,10 @@ module Fastlane
13
13
  "Execute automated tests on sauce labs platform via saucectl binary for specified configuration"
14
14
  end
15
15
 
16
+ def self.details
17
+ "Execute automated tests on sauce labs platform via saucectl binary for specified configuration"
18
+ end
19
+
16
20
  def self.available_options
17
21
  [
18
22
  FastlaneCore::ConfigItem.new(key: :sauce_username,
@@ -5,7 +5,7 @@ require_relative "file_utils"
5
5
 
6
6
  module Fastlane
7
7
  module Saucectl
8
- # This class is responsible for creating test execution plans for ios applications and will distribute tests
8
+ # This class is responsible for creating test execution plans for android applications and will distribute tests
9
9
  # that will be be executed via the cloud provider.
10
10
  #
11
11
  class Espresso
@@ -12,11 +12,11 @@ module Fastlane
12
12
  include FileUtils
13
13
  UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
14
14
 
15
- def install
16
- timeout_in_seconds = 30
15
+ def install(version)
16
+ timeout_in_seconds = 90
17
17
  Timeout.timeout(timeout_in_seconds) do
18
18
  download_saucectl_installer
19
- execute_saucectl_installer
19
+ execute_saucectl_installer(version)
20
20
  UI.success("✅ Successfully installed saucectl runner binary 🚀")
21
21
  rescue OpenURI::HTTPError => e
22
22
  response = e.io
@@ -26,13 +26,14 @@ module Fastlane
26
26
 
27
27
  def download_saucectl_installer
28
28
  URI.open('sauce', 'wb') do |file|
29
- file << URI.open('https://saucelabs.github.io/saucectl/install').read
29
+ file << URI.open('https://saucelabs.github.io/saucectl/install', ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE).read
30
30
  end
31
31
  end
32
32
 
33
- def execute_saucectl_installer
34
- status = system('sh sauce')
35
- status == 1 ? UI.user_error!(" failed to install saucectl: #{stderr}") : status
33
+ def execute_saucectl_installer(version)
34
+ saucectl_version = version[:version].nil? ? '' : "v#{version[:version]}"
35
+ status = system("sh sauce #{saucectl_version}")
36
+ status == 1 ? UI.user_error!("❌ failed to install saucectl") : status
36
37
  executable = 'saucectl'
37
38
  FileUtils.mv("bin/#{executable}", executable) unless File.exist?(executable)
38
39
  end
@@ -40,7 +41,9 @@ module Fastlane
40
41
  def system(*cmd)
41
42
  Open3.popen2e(*cmd) do |stdin, stdout_stderr, wait_thread|
42
43
  Thread.new do
43
- stdout_stderr.each { |out| UI.message(out) }
44
+ stdout_stderr.each do |out|
45
+ UI.message(out)
46
+ end
44
47
  end
45
48
  stdin.close
46
49
  wait_thread.value
@@ -25,7 +25,9 @@ module Fastlane
25
25
  def system(*cmd)
26
26
  Open3.popen2e(*cmd) do |stdin, stdout_stderr, wait_thread|
27
27
  Thread.new do
28
- stdout_stderr.each { |out| UI.message(out) }
28
+ stdout_stderr.each do |out|
29
+ UI.message(out)
30
+ end
29
31
  end
30
32
  stdin.close
31
33
  wait_thread.value
@@ -60,16 +60,7 @@ module Fastlane
60
60
  elsif @config[:test_class]
61
61
  custom_test_classes
62
62
  else
63
- test_suites = []
64
- @config[:emulators].each do |emulator|
65
- test_distribution_array.each do |test_type|
66
- test_suites << {
67
- 'name' => suite_name(test_type).downcase,
68
- 'testOptions' => default_test_options(test_type)
69
- }.merge(virtual_device_options(emulator))
70
- end
71
- end
72
- test_suites
63
+ default_execution_suite
73
64
  end
74
65
  end
75
66
 
@@ -133,17 +124,34 @@ module Fastlane
133
124
  elsif @config[:test_class].kind_of?(Array)
134
125
  custom_test_classes
135
126
  else
136
- test_suites = []
137
- @config[:devices].each do |device|
127
+ default_execution_suite
128
+ end
129
+ end
130
+
131
+ def default_execution_suite
132
+ type = @config[:annotation] ? 'annotation' : 'size'
133
+ UI.user_error!("❌ execution by #{type} is not supported on the iOS platform!") if @config[:platform].eql?('ios') && (@config[:size] || @config[:annotation])
134
+ is_real_device = @config[:devices]
135
+ test_devices = @config[:devices] || @config[:emulators]
136
+ test_suites = []
137
+ if @config[:size] || @config[:annotation]
138
+ test_devices.each do |device|
139
+ test_suites << {
140
+ 'name' => suite_name(@config[:size] || @config[:annotation]).downcase,
141
+ 'testOptions' => default_test_options(@config[:size])
142
+ }.merge(is_real_device ? real_device_options(device) : virtual_device_options(device))
143
+ end
144
+ else
145
+ test_devices.each do |device|
138
146
  test_distribution_array.each do |test_type|
139
147
  test_suites << {
140
148
  'name' => suite_name(test_type).downcase,
141
149
  'testOptions' => default_test_options(test_type)
142
- }.merge(real_device_options(device))
150
+ }.merge(is_real_device ? real_device_options(device) : virtual_device_options(device))
143
151
  end
144
152
  end
145
- test_suites
146
153
  end
154
+ test_suites
147
155
  end
148
156
 
149
157
  def virtual_device_options(device)
@@ -182,14 +190,24 @@ module Fastlane
182
190
  end
183
191
 
184
192
  def default_test_options(test_type)
185
- test_option_type = @config[:test_distribution].eql?('package') ? 'package' : 'class'
186
193
  if @config[:platform] == 'android'
187
- { test_option_type => test_type }.merge(android_test_options)
194
+ test_option_type(test_type)
188
195
  else
189
196
  { 'class' => test_type }
190
197
  end
191
198
  end
192
199
 
200
+ def test_option_type(test_type)
201
+ if @config[:size] || @config[:annotation]
202
+ key = @config[:size] ? 'size' : 'annotation'
203
+ value = @config[:size] || @config[:annotation]
204
+ { key => value }.merge(android_test_options)
205
+ else
206
+ test_option_type = @config[:test_distribution].eql?('package') ? 'package' : 'class'
207
+ { test_option_type => test_type }.merge(android_test_options)
208
+ end
209
+ end
210
+
193
211
  def android_test_options
194
212
  {
195
213
  'clearPackageData' => @config[:clear_data],
@@ -0,0 +1,12 @@
1
+ ---
2
+ platform_error: "No platform specified, set using: platform: 'android'"
3
+ app_path_error: "No App path given, set using: app_path: 'path/to/my/testApp.apk'"
4
+ file_error: "No file path given, set using: app_path: 'path/to/my/testApp.apk'"
5
+ app_name_error: "No App name given, set using: app_name: 'testApp.apk'"
6
+ test_runner_app_error: "No Test runner application given, set using: test_runner_app: 'testRunnerApp.apk'"
7
+ region_error: "$region is an invalid region. Supported regions are 'us' and 'eu'"
8
+ sauce_username_error: "No sauce labs username provided, set using: sauce_username: 'sauce user name', or consider setting your credentials as environment variables."
9
+ sauce_api_key_error: "No sauce labs access key provided, set using: sauce_access_key: '1234' or consider setting your credentials as environment variables."
10
+ supported_regions: ['us', 'eu']
11
+ accepted_file_types: ['.apk', '.aab', '.ipa', '.zip']
12
+ missing_file_name: "Please specify the name of the app that you wish to query on sauce storage"
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Saucectl
3
- VERSION = "0.1.0-beta.2"
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
@@ -1,11 +1,9 @@
1
- require 'fastlane'
1
+ require 'fastlane/plugin/saucectl/version'
2
2
 
3
3
  module Fastlane
4
4
  module Saucectl
5
- UI = FastlaneCore::UI
6
- # Return all .rb files inside the "actions" and "helper" directory
7
5
  def self.all_classes
8
- Dir[File.expand_path('**/actions/*_action.rb', File.dirname(__FILE__))]
6
+ Dir[File.expand_path('*/{actions,helper}/*.rb', File.dirname(__FILE__))]
9
7
  end
10
8
  end
11
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-saucectl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.beta.2
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Hamilton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-23 00:00:00.000000000 Z
11
+ date: 2022-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -170,10 +170,12 @@ executables: []
170
170
  extensions: []
171
171
  extra_rdoc_files: []
172
172
  files:
173
+ - LICENSE
174
+ - README.md
173
175
  - lib/fastlane/plugin/saucectl.rb
174
176
  - lib/fastlane/plugin/saucectl/actions/delete_from_storage_action.rb
175
177
  - lib/fastlane/plugin/saucectl/actions/disabled_tests_action.rb
176
- - lib/fastlane/plugin/saucectl/actions/install_toolkit_action.rb
178
+ - lib/fastlane/plugin/saucectl/actions/install_saucectl_action.rb
177
179
  - lib/fastlane/plugin/saucectl/actions/sauce_apps_action.rb
178
180
  - lib/fastlane/plugin/saucectl/actions/sauce_config_action.rb
179
181
  - lib/fastlane/plugin/saucectl/actions/sauce_devices_action.rb
@@ -188,6 +190,7 @@ files:
188
190
  - lib/fastlane/plugin/saucectl/helper/storage.rb
189
191
  - lib/fastlane/plugin/saucectl/helper/suites.rb
190
192
  - lib/fastlane/plugin/saucectl/helper/xctest.rb
193
+ - lib/fastlane/plugin/saucectl/strings/messages.yml
191
194
  - lib/fastlane/plugin/saucectl/version.rb
192
195
  homepage: https://github.com/ianrhamilton/fastlane-plugin-saucectl
193
196
  licenses:
@@ -202,15 +205,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
205
  requirements:
203
206
  - - ">="
204
207
  - !ruby/object:Gem::Version
205
- version: '2.6'
208
+ version: '2.5'
206
209
  required_rubygems_version: !ruby/object:Gem::Requirement
207
210
  requirements:
208
- - - ">"
211
+ - - ">="
209
212
  - !ruby/object:Gem::Version
210
- version: 1.3.1
213
+ version: '0'
211
214
  requirements: []
212
- rubygems_version: 3.3.7
215
+ rubygems_version: 3.3.10
213
216
  signing_key:
214
217
  specification_version: 4
215
- summary: Test your iOS and and Android apps at scale using Sauce Labs toolkit.
218
+ summary: Simplify the set up, configuration, upload, and execution of espresso and
219
+ XCUITest on the Sauce Labs platform by utilizing fastlane which will enable you
220
+ to test your iOS and Android apps at scale.
216
221
  test_files: []
@@ -1,30 +0,0 @@
1
- require 'fastlane/action'
2
- require_relative '../helper/installer'
3
-
4
- module Fastlane
5
- module Actions
6
- class InstallToolkitAction < Action
7
- def self.run(param = '')
8
- UI.message("Installing saucectl 🤖 🚀")
9
- installer = Saucectl::Installer.new
10
- installer.install
11
- end
12
-
13
- def self.description
14
- "Installs the Sauce Labs saucectl cli binary"
15
- end
16
-
17
- def self.authors
18
- ["Ian Hamilton"]
19
- end
20
-
21
- def self.category
22
- :testing
23
- end
24
-
25
- def self.is_supported?(platform)
26
- [:ios, :android].include?(platform)
27
- end
28
- end
29
- end
30
- end