fastlane-plugin-saucectl 0.1.2.pre → 0.1.2

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: 2bb0bc0c918e497c8c4ec0d560635d0a059bed8d5456c6df34f33a5aa626d9ba
4
- data.tar.gz: 9f4626de2b041b65e8fd0882726f29ef1053ed8054499a704b13ca96773300fc
3
+ metadata.gz: 427bbd155ddacd6f5403288d4bbbcb44f227d6292ba1b934921ae14b01324048
4
+ data.tar.gz: d01a9ed4b740497310c0529cbd43014eb7ce4727fbdd16f505e2f5bee17bc506
5
5
  SHA512:
6
- metadata.gz: 14a4fdcd1d5ce125a1d08af53d51f5c82fcc44cdd4dbab14e315cd6b417daedd41d7c7be6c3a8d420211b6697bf340e40fb1749331f6aff34db9c930f4365967
7
- data.tar.gz: c07918fee9b5067146ea9b840d11c495218bb21229cf22221ed217a25574beacfba97902fffb4fc24484d13d1a89a267dcc4d1524d2946e1db7a026166e96380
6
+ metadata.gz: 802216e5bfac8a194a9545363966ef5ce7b336edfe0e59864cf59e09e8e4322b6831b0b943b531b9cb93e7f09e33a1e27c478fd8fa2560f356dd54dbaf025932
7
+ data.tar.gz: 7901c5beb12b28dc0d8cb40f2d1491f05ae746918bd61aa9309c0190514b4b9711c572ee5c3aef9e869b675637b7f40908192c112653d2adb361e2df03efaf89
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)
@@ -4,10 +4,11 @@ require_relative '../helper/installer'
4
4
  module Fastlane
5
5
  module Actions
6
6
  class InstallSaucectlAction < Action
7
- def self.run(param = '')
8
- UI.message("Installing saucectl 🤖 🚀")
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} 🤖 🚀")
9
10
  installer = Saucectl::Installer.new
10
- installer.install
11
+ installer.install(version)
11
12
  end
12
13
 
13
14
  def self.description
@@ -15,7 +16,16 @@ module Fastlane
15
16
  end
16
17
 
17
18
  def self.details
18
- "Installs the Sauce Labs saucectl cli binary"
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
+ ]
19
29
  end
20
30
 
21
31
  def self.authors
@@ -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,
@@ -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,10 @@ 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
+ message = out.gsub(/(?:\[[^\]].*\])|(?:\(\d{4}\))/, '')
30
+ puts(message)
31
+ end
29
32
  end
30
33
  stdin.close
31
34
  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.2.pre"
3
+ VERSION = '0.1.2'.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.2.pre
4
+ version: 0.1.2
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-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -170,6 +170,8 @@ 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
@@ -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.0.3
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: []