fastlane-plugin-saucectl 0.1.3.pre → 0.1.4.pre

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: 024240ff63318f8b16a171d979f78e248056944b7d101fcc65fd624052109931
4
+ data.tar.gz: 8658779f3666c3763d3bee9653a1615948cfaa5d86a29ae467bec7bd312bf446
5
5
  SHA512:
6
- metadata.gz: 385e2b1b519e2c90e2b9fd70dc25912040e5ac9c913dc0992111d17266beab22647dc6808532dc191b85f10ccdb3f877b400880a62a05d08a70ff68c77816257
7
- data.tar.gz: 182fb2ec4023e3d6a2dac3623a0b34ebf19cec8ba9e40d55867ceb29063439fcbb215033dcd1a04f6dafe16fe9b236a31943672e340b06151bd8c558d89acb34
6
+ metadata.gz: 52a09bb69e87375bc95c2859926f7f67d4d95e46c7dab759273579c736148b21490ac098d9f3d88fc624d6be9a86e0126d313d54b1b6a36b5832787c9809323b
7
+ data.tar.gz: 0e227865084afc04b8b6677229db631bc9385a6550fe44f74450517b9ddfecd6787675b773bfd78ff90624d235bf28dc802634b2ca5667711231479f68983e86
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,80 @@
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
+ [![codecov](https://codecov.io/gh/ianrhamilton/fastlane-plugin-rsaucectl/branch/main/graph/badge.svg?token=NSVhqgYFYv)](https://codecov.io/gh/ianrhamilton/fastlane-plugin-saucectl)
5
+
6
+ ## Getting Started
7
+
8
+ 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:
9
+
10
+ ```bash
11
+ fastlane add_plugin saucectl
12
+ ```
13
+
14
+ ## About fastlane-plugin-saucectl
15
+
16
+ The purpose of this plugin is to simplify the set up, configuration, upload, and execution of espresso and xcuitests via the [Sauce Labs](https://saucelabs.com/) platform by utilizing fastlane which will enable you to test your iOS and and Android apps at scale using [Sauce Labs CLI](https://docs.saucelabs.com/dev/cli/saucectl/).
17
+
18
+ **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.
19
+
20
+ Failure to do this will result in missing test classes and test cases from your test run.
21
+
22
+ **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)**.
23
+
24
+ | Available Actions | Description |
25
+ |---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
26
+ | install_saucectl | Downloads the Sauce Labs saucectl cli binary for test execution |
27
+ | sauce_upload | Upload test artifacts to sauce labs storage |
28
+ | sauce_config | Create SauceLabs configuration file for test execution based on given parameters |
29
+ | sauce_runner | Execute automated tests on sauce labs platform via saucectl binary for specified configuration |
30
+ | delete_from_storage | Delete test artifacts from sauce labs storage by storage id or group id |
31
+ | sauce_apps | Returns the set of files by specific app id that have been uploaded to Sauce Storage by the requester |
32
+ | sauce_devices | Returns a list of Device IDs for all devices in the data center that are currently free for testing. |
33
+ | 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 |
34
+
35
+ An order of which you may utilize the above actions in your continuous integration platform could be:
36
+ 1. Install the saucectl binary via `install_saucectl`
37
+ 2. Upload your test artifacts to Sauce Labs storage (for example app apk, and test runner apk)
38
+ 3. Create config.yml for given parameters via `sauce_config`
39
+ 4. Execute test based on specified config via `sauce_runner`
40
+ 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)
41
+
42
+ ## Example
43
+
44
+ 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`.
45
+
46
+ **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)
47
+
48
+ ## Run tests for this plugin
49
+
50
+ To run both the tests, and code style validation, run
51
+
52
+ ```
53
+ rake
54
+ ```
55
+
56
+ To automatically fix many of the styling issues, use
57
+ ```
58
+ rubocop -a
59
+ ```
60
+
61
+ ## Issues and Feedback
62
+
63
+ For any other issues and feedback about this plugin, please submit it to this repository.
64
+
65
+ ## Troubleshooting
66
+
67
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
68
+
69
+ ## Using _fastlane_ Plugins
70
+
71
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
72
+
73
+ ## About _fastlane_
74
+
75
+ _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).
76
+
77
+ ## Buy me a coffee
78
+ If you're enjoying this plugin, feel free to **optionally** buy me a coffee :)
79
+
80
+ [!["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,34 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/installer'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class InstallSaucectlAction < 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.details
18
+ "Installs the Sauce Labs saucectl cli binary"
19
+ end
20
+
21
+ def self.authors
22
+ ["Ian Hamilton"]
23
+ end
24
+
25
+ def self.category
26
+ :testing
27
+ end
28
+
29
+ def self.is_supported?(platform)
30
+ [:ios, :android].include?(platform)
31
+ end
32
+ end
33
+ end
34
+ 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