fastlane-plugin-saucectl 0.1.3.pre → 0.1.3

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: cfe7383a6621d0f63d8b47202f757eff6873b3eb2fdd9b2482de329fe4aa81f1
4
- data.tar.gz: faa221723b72ad9b14583c0bbcef9b0a547cdf8158f9947b8be4c420b96a249f
3
+ metadata.gz: 6ab968db699553cb2d744fe26a66dcd3e02b56e796935092b408d04ec2b5566b
4
+ data.tar.gz: c5c3cbf2f72e159be64c0a47f025e11136c24285260488a12699322f88892caf
5
5
  SHA512:
6
- metadata.gz: 385e2b1b519e2c90e2b9fd70dc25912040e5ac9c913dc0992111d17266beab22647dc6808532dc191b85f10ccdb3f877b400880a62a05d08a70ff68c77816257
7
- data.tar.gz: 182fb2ec4023e3d6a2dac3623a0b34ebf19cec8ba9e40d55867ceb29063439fcbb215033dcd1a04f6dafe16fe9b236a31943672e340b06151bd8c558d89acb34
6
+ metadata.gz: c26a558fa620c0c8f6cc20f9739b6ad7e8dc5382b1a82b88a2439b10f9621fae7d45a92b54c085c2d19a2b249f2d75155ef96d67d0051ef223b4d36cdffa3497
7
+ data.tar.gz: cc8dfb29b8d3576dffba855245a140e43a3809ea337c0ddf5c8a1d14844b5f31f9a89d254c159127e70647c5f6593a1659f4d9a5d2724c6bde2f8cb2562de559
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)
@@ -0,0 +1,96 @@
1
+ require 'fastlane/action'
2
+ require 'json'
3
+ require 'yaml'
4
+ require_relative '../helper/api'
5
+ require_relative '../helper/storage'
6
+
7
+ module Fastlane
8
+ module Actions
9
+ class DeleteFromStorageAction < Action
10
+ @messages = YAML.load_file("#{__dir__}/../strings/messages.yml")
11
+
12
+ def self.run(params)
13
+ if params[:group_id].nil?
14
+ Fastlane::Saucectl::Storage.new(params).delete_app_with_file_id
15
+ else
16
+ Fastlane::Saucectl::Storage.new(params).delete_all_apps_for_group_id
17
+ end
18
+ end
19
+
20
+ def self.description
21
+ "Delete test artifacts from sauce labs storage"
22
+ end
23
+
24
+ def self.details
25
+ "Delete test artifacts from sauce labs storage by storage id or group id"
26
+ end
27
+
28
+ def self.available_options
29
+ [
30
+ FastlaneCore::ConfigItem.new(key: :region,
31
+ description: "Data Center region (us or eu), set using: region: 'eu'",
32
+ optional: false,
33
+ is_string: true,
34
+ verify_block: proc do |value|
35
+ UI.user_error!(@messages['region_error'].gsub!('$region', value)) if value.empty? || !@messages['supported_regions'].include?(value)
36
+ end),
37
+ FastlaneCore::ConfigItem.new(key: :sauce_username,
38
+ env_name: "SAUCE_USERNAME",
39
+ description: "Your sauce labs username in order to authenticate delete file from app storage",
40
+ default_value: Actions.lane_context[SharedValues::SAUCE_USERNAME],
41
+ optional: false,
42
+ is_string: true,
43
+ verify_block: proc do |value|
44
+ UI.user_error!(@messages['sauce_username_error']) if value.empty?
45
+ end),
46
+ FastlaneCore::ConfigItem.new(key: :sauce_access_key,
47
+ env_name: "SAUCE_ACCESS_KEY",
48
+ description: "Your sauce labs access key in order to authenticate delete file from app storage",
49
+ default_value: Actions.lane_context[SharedValues::SAUCE_ACCESS_KEY],
50
+ optional: false,
51
+ is_string: true,
52
+ verify_block: proc do |value|
53
+ UI.user_error!(@messages['sauce_api_key_error']) if value.empty?
54
+ end),
55
+ FastlaneCore::ConfigItem.new(key: :app_id,
56
+ description: "The application id from sauce labs storage",
57
+ optional: true,
58
+ is_string: true),
59
+ FastlaneCore::ConfigItem.new(key: :group_id,
60
+ description: "The group id for sauce labs storage",
61
+ optional: true,
62
+ is_string: true)
63
+ ]
64
+ end
65
+
66
+ def self.authors
67
+ ["Ian Hamilton"]
68
+ end
69
+
70
+ def self.category
71
+ :testing
72
+ end
73
+
74
+ def self.is_supported?(platform)
75
+ [:ios, :android].include?(platform)
76
+ end
77
+
78
+ def self.example_code
79
+ [
80
+ "delete_from_storage(
81
+ region: 'eu',
82
+ sauce_username: 'sauce username',
83
+ sauce_access_key: 'sauce api name',
84
+ app_id: '1234-1234-1234-1234'
85
+ )",
86
+ "delete_from_storage(
87
+ region: 'eu',
88
+ sauce_username: 'sauce username',
89
+ sauce_access_key: 'sauce api name',
90
+ group_id: '123456789'
91
+ )"
92
+ ]
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,90 @@
1
+ require 'fastlane/action'
2
+ require 'json'
3
+ require 'yaml'
4
+ require_relative '../helper/espresso'
5
+ require_relative '../helper/xctest'
6
+
7
+ module Fastlane
8
+ module Actions
9
+ class DisabledTestsAction < Action
10
+ @messages = YAML.load_file("#{__dir__}/../strings/messages.yml")
11
+
12
+ def self.run(params)
13
+ verify_config(params)
14
+ if params[:platform].eql?('android')
15
+ params[:path_to_tests] ? params[:path_to_tests] : params[:path_to_tests] = "app/src/androidTest"
16
+ Fastlane::Saucectl::Espresso.new(params).fetch_disabled_tests(params[:path_to_tests])
17
+ else
18
+ Fastlane::Saucectl::XCTest.new(params).fetch_disabled_tests
19
+ end
20
+ end
21
+
22
+ def self.verify_config(params)
23
+ if params[:platform].eql?('ios') && params[:test_plan].nil?
24
+ UI.user_error!('Cannot get skipped tests for an ios project without a known test_plan')
25
+ end
26
+ if params[:platform].eql?('android') && !params[:test_plan].nil?
27
+ UI.user_error!('test_plan option is reserved for ios projects only')
28
+ end
29
+ end
30
+
31
+ def self.description
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
+ end
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
+
39
+ def self.available_options
40
+ [
41
+ FastlaneCore::ConfigItem.new(key: :platform,
42
+ description: "application under test platform (ios or android)",
43
+ optional: false,
44
+ is_string: true,
45
+ verify_block: proc do |value|
46
+ UI.user_error!(@messages['platform_error']) if value.to_s.empty?
47
+ end),
48
+ FastlaneCore::ConfigItem.new(key: :path_to_tests,
49
+ description: "Android only, path to espresso tests. Default to app/src/androidTest",
50
+ optional: true,
51
+ is_string: true),
52
+ FastlaneCore::ConfigItem.new(key: :test_plan,
53
+ description: "Name of xcode test plan",
54
+ optional: true,
55
+ is_string: true),
56
+ FastlaneCore::ConfigItem.new(key: :test_target,
57
+ description: "Name of xcode test target",
58
+ optional: true,
59
+ is_string: true)
60
+ ]
61
+ end
62
+
63
+ def self.authors
64
+ ["Ian Hamilton"]
65
+ end
66
+
67
+ def self.category
68
+ :testing
69
+ end
70
+
71
+ def self.is_supported?(platform)
72
+ [:ios, :android].include?(platform)
73
+ end
74
+
75
+ def self.example_code
76
+ [
77
+ "disabled_tests({ platform: 'android',
78
+ path_to_tests: 'my-demo-app-android/app/src/androidTest'
79
+ })",
80
+ "disabled_tests({ platform: 'ios',
81
+ test_plan: 'UITests'
82
+ })",
83
+ "disabled_tests({ platform: 'ios',
84
+ test_plan: 'UITests'
85
+ })"
86
+ ]
87
+ end
88
+ end
89
+ end
90
+ end
@@ -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
@@ -0,0 +1,96 @@
1
+ require 'fastlane/action'
2
+ require 'json'
3
+ require 'yaml'
4
+ require_relative '../helper/api'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ class SauceAppsAction < Action
9
+ @messages = YAML.load_file("#{__dir__}/../strings/messages.yml")
10
+ def self.run(params)
11
+ Fastlane::Saucectl::Api.new(params).retrieve_all_apps
12
+ end
13
+
14
+ def self.description
15
+ "Returns the set of files by specific app id that have been uploaded to Sauce Storage by the requester"
16
+ end
17
+
18
+ def self.details
19
+ "Returns the set of files by specific app id that have been uploaded to Sauce Storage by the requester"
20
+ end
21
+
22
+ def self.available_options
23
+ [
24
+ FastlaneCore::ConfigItem.new(key: :platform,
25
+ description: "application under test platform (ios or android)",
26
+ optional: false,
27
+ type: String,
28
+ verify_block: proc do |value|
29
+ UI.user_error!(@messages['platform_error']) if value.to_s.empty?
30
+ end),
31
+ FastlaneCore::ConfigItem.new(key: :query,
32
+ description: "Any search term (such as build number or file name) by which you want to filter results",
33
+ optional: false,
34
+ type: String,
35
+ verify_block: proc do |value|
36
+ UI.user_error!(@messages['missing_file_name']) if value.to_s.empty?
37
+ end),
38
+ FastlaneCore::ConfigItem.new(key: :region,
39
+ description: "Data Center region (us or eu), set using: region: 'eu'",
40
+ optional: false,
41
+ type: String,
42
+ verify_block: proc do |value|
43
+ UI.user_error!(@messages['region_error'].gsub!('$region', value)) unless @messages['supported_regions'].include?(value)
44
+ end),
45
+ FastlaneCore::ConfigItem.new(key: :sauce_username,
46
+ env_name: "SAUCE_USERNAME",
47
+ description: "Your sauce labs username in order to authenticate upload requests",
48
+ default_value: Actions.lane_context[SharedValues::SAUCE_USERNAME],
49
+ optional: false,
50
+ type: String,
51
+ verify_block: proc do |value|
52
+ UI.user_error!(@messages['sauce_username_error']) unless value && !value.empty?
53
+ end),
54
+ FastlaneCore::ConfigItem.new(key: :sauce_access_key,
55
+ env_name: "SAUCE_ACCESS_KEY",
56
+ description: "Your sauce labs access key in order to authenticate upload requests",
57
+ default_value: Actions.lane_context[SharedValues::SAUCE_ACCESS_KEY],
58
+ optional: false,
59
+ type: String,
60
+ verify_block: proc do |value|
61
+ UI.user_error!(@messages['sauce_api_key_error']) unless value && !value.empty?
62
+ end)
63
+ ]
64
+ end
65
+
66
+ def self.authors
67
+ ["Ian Hamilton"]
68
+ end
69
+
70
+ def self.category
71
+ :testing
72
+ end
73
+
74
+ def self.is_supported?(platform)
75
+ [:ios, :android].include?(platform)
76
+ end
77
+
78
+ def self.example_code
79
+ [
80
+ "sauce_apps({platform: 'android',
81
+ query: 'test.apk',
82
+ region: 'eu',
83
+ sauce_username: 'foo',
84
+ sauce_access_key: 'bar123',
85
+ })",
86
+ "sauce_apps({platform: 'ios',
87
+ query: 'test.app',
88
+ region: 'eu',
89
+ sauce_username: 'foo',
90
+ sauce_access_key: 'bar123',
91
+ })"
92
+ ]
93
+ end
94
+ end
95
+ end
96
+ end