checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c6191326b8ce69aa135bd857ff457c42a13e64b9890b9b5b5936920e97c80cf3
4
+ data.tar.gz: de603d2ad50663dd84a0f04e16c1afa8a9267bb4ca2d6ef68eb90654f65cbf7f
5
+ SHA512:
6
+ metadata.gz: 24ff1060fe3449be6212ef42c2e637c56a0f250bb35f2d26f8e5bb2f99da45a61cd493725d3f56ab4f9dd48153d5efffe2ab555bc4af86403576dc00da10e6e4
7
+ data.tar.gz: 79a4c8b8fbb84487eb637ac82bba41d90d409c7e518de3f0fc8e24208b4ab42a45d37cfb0f65c123ca16c1f7d20a3b48d364da465047cf350b9dc663bf5ea8ee
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 genesisthomas <genesist@perfectomobile.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,100 @@
1
+ # perfecto plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-perfecto)
4
+ [![CircleCI](https://circleci.com/gh/PerfectoMobileSA/fastlane-plugin-perfecto/tree/master.svg?style=svg)](https://circleci.com/gh/PerfectoMobileSA/fastlane-plugin-perfecto/tree/master)
5
+
6
+ ## Getting Started
7
+
8
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-perfecto`, add it to your project by running:
9
+
10
+ ```bash
11
+ fastlane add_plugin perfecto
12
+ ```
13
+
14
+ ## About perfecto
15
+
16
+ This plugin allows you to automatically upload ipa/apk files to Perfecto for manual/automation testing
17
+
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
+ You can easily upload your ipa/apk file using perfecto fastlane Plugin and execute your test on perfecto cloud.
23
+
24
+ Add the below action in your fastfile to utilize this plugin.
25
+
26
+ ```
27
+ lane :test do
28
+ perfecto(
29
+ perfecto_cloudurl: ENV["PERFECTO_CLOUDURL"],
30
+ perfecto_token: ENV["PERFECTO_TOKEN"],
31
+ perfecto_media_location: ENV["PERFECTO_MEDIA_LOCATION"],
32
+ file_path: ENV['GRADLE_APK_OUTPUT_PATH']
33
+ )
34
+ end
35
+ ```
36
+ ### Note: <br>
37
+ Pass the below variable values as environment variables:<br>
38
+ PERFECTO_CLOUDURL [your perfecto cloud url. E.g.: demo.perfectomobile.com]<br>
39
+ PERFECTO_TOKEN [your perfecto [`security token`](https://developers.perfectomobile.com/display/PD/Generate+security+tokens)]<br>
40
+ PERFECTO_MEDIA_LOCATION [mention the Perfecto media repository location to upload the file mentioned in file_path. E.g. PUBLIC:Samples/sample.ipa]<br>
41
+ file_path [location of your preferred ipa/apk file which needs to be uploaded to perfecto media repository.]<br>
42
+ slack_webhook [Slack incoming webhook for slack integration. more info: [`here`](https://docs.fastlane.tools/actions/slack/)]<br>
43
+
44
+ Here's a [`sample project`](https://github.com/PerfectoMobileSA/FastlaneEspressoCircleCISlackSample) which demonstrates the usage of this plugin.
45
+
46
+ The following actions are possible with the [`sample project`](https://github.com/PerfectoMobileSA/FastlaneEspressoCircleCISlackSample):
47
+
48
+ ## Available Actions:
49
+ ## Android
50
+ ### android test
51
+ ```
52
+ fastlane android test
53
+ ```
54
+ build, upload and run on perfecto
55
+ ### android apk
56
+ ```
57
+ fastlane android apk
58
+ ```
59
+ Build debug APK and upload to perfecto
60
+ ### android test_apk
61
+ ```
62
+ fastlane android test_apk
63
+ ```
64
+ Build debug test APK and upload to perfecto
65
+ ### android run_perfecto
66
+ ```
67
+ fastlane android run_perfecto
68
+ ```
69
+ Run on perfecto
70
+ ### android slack_report
71
+ ```
72
+ fastlane android slack_report
73
+ ```
74
+ Report perfecto url to slack
75
+
76
+
77
+ ## Run tests for this plugin
78
+
79
+ To run both the tests, and code style validation, run
80
+
81
+ ```
82
+ rake
83
+ ```
84
+
85
+ To automatically fix many of the styling issues, use
86
+ ```
87
+ rubocop -a
88
+ ```
89
+
90
+ ## Issues and Feedback
91
+
92
+ For any other issues and feedback about this plugin, please submit it to this repository.
93
+
94
+ ## Troubleshooting
95
+
96
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
97
+
98
+ ## About _fastlane_
99
+
100
+ _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).
data/lib/fastlane/plugin/perfecto.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/perfecto/version'
2
+
3
+ module Fastlane
4
+ module Perfecto
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::Perfecto.all_classes.each do |current|
15
+ require current
16
+ end
data/lib/fastlane/plugin/perfecto/actions/perfecto_action.rb ADDED
@@ -0,0 +1,142 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/perfecto_helper'
3
+ require 'json'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ module SharedValues
8
+ PERFECTO_MEDIA_FULLPATH ||= :PERFECTO_MEDIA_FULLPATH
9
+ end
10
+ class PerfectoAction < Action
11
+ SUPPORTED_FILE_EXTENSIONS = ["ipa", "apk"]
12
+
13
+ def self.run(params)
14
+ # Mandatory parameters
15
+ perfecto_cloudurl = params[:perfecto_cloudurl]
16
+ perfecto_token = params[:perfecto_token]
17
+ filepath = params[:file_path].to_s
18
+ perfecto_media_fullpath = params[:perfecto_media_location]
19
+
20
+ # validates the filepath and perfecto media location file
21
+ UI.message("validating filepath")
22
+ validate_filepath(filepath)
23
+ UI.message("validating media location")
24
+ validate_repopath(perfecto_media_fullpath)
25
+
26
+ # uploads the ipa/apk to perfecto media repository
27
+ UI.message("Attempting to upload: " + filepath + " to Perfecto!")
28
+ Helper::PerfectoHelper.upload_file(perfecto_cloudurl, perfecto_token, filepath, perfecto_media_fullpath)
29
+ UI.success("The File in: " + filepath + " is successfully uploaded to Perfecto media location : " + perfecto_media_fullpath)
30
+
31
+ # Setting the environment variable: PERFECTO_MEDIA_FULLPATH with the perfecto media repository location.
32
+ ENV['PERFECTO_MEDIA_FULLPATH'] = nil
33
+ ENV['PERFECTO_MEDIA_FULLPATH'] = perfecto_media_fullpath
34
+ UI.success("Setting Environment variable PERFECTO_MEDIA_FULLPATH = " + ENV['PERFECTO_MEDIA_FULLPATH'])
35
+
36
+ # Setting the media fullpath in shared values post successful upload in order to be used by other fastlane actions.
37
+ Actions.lane_context[SharedValues::PERFECTO_MEDIA_FULLPATH] = perfecto_media_fullpath
38
+ end
39
+
40
+ def self.description
41
+ "This plugin allows you to automatically upload ipa/apk files to Perfecto for manual/automation testing"
42
+ end
43
+
44
+ def self.authors
45
+ ["genesisthomas"]
46
+ end
47
+
48
+ def self.return_value
49
+ # If your method provides a return value, you can describe here what it does
50
+ end
51
+
52
+ def self.details
53
+ # Optional:
54
+ "A fastlane plugin which aids in automated deployment of ipa/apk files to Perfecto iOS/Android devices"
55
+ end
56
+
57
+ # Validate filepath.
58
+ def self.validate_filepath(filepath)
59
+ UI.user_error!("No file found at filepath parameter location.") unless File.exist?(filepath)
60
+
61
+ # Validate file extension.
62
+ filepath_parts = filepath.split(".")
63
+ unless filepath_parts.length > 1 && SUPPORTED_FILE_EXTENSIONS.include?(filepath_parts.last)
64
+ UI.user_error!("filepath is invalid, only files with extensions with .ipa or .apk are allowed to be uploaded.")
65
+ end
66
+ end
67
+
68
+ # Validate media repo path.
69
+ def self.validate_repopath(perfecto_media_fullpath)
70
+ # Validate file extension.
71
+ filepath_parts = perfecto_media_fullpath.split(".")
72
+ unless filepath_parts.length > 1 && SUPPORTED_FILE_EXTENSIONS.include?(filepath_parts.last)
73
+ UI.user_error!("perfecto_media_location is invalid, only files with extensions with .ipa or .apk are allowed to be uploaded.")
74
+ end
75
+ end
76
+
77
+ def self.output
78
+ [
79
+ ['perfecto_media_fullpath', 'Perfecto media repo location']
80
+ ]
81
+ end
82
+
83
+ def self.default_file_path
84
+ platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
85
+ if platform == :ios
86
+ # Shared value for ipa path if it was generated by gym https://docs.fastlane.tools/actions/gym/.
87
+ return Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH]
88
+ else
89
+ # Shared value for apk if it was generated by gradle.
90
+ return Actions.lane_context[Actions::SharedValues::GRADLE_APK_OUTPUT_PATH]
91
+ end
92
+ end
93
+
94
+ def self.available_options
95
+ [
96
+ FastlaneCore::ConfigItem.new(key: :perfecto_cloudurl,
97
+ description: "Perfecto's cloud url",
98
+ optional: false,
99
+ is_string: true,
100
+ verify_block: proc do |value|
101
+ UI.user_error!("No perfecto_cloudurl given.") if value.to_s.empty?
102
+ end),
103
+ FastlaneCore::ConfigItem.new(key: :perfecto_token,
104
+ description: "Perfecto's security token",
105
+ optional: false,
106
+ is_string: true,
107
+ verify_block: proc do |value|
108
+ UI.user_error!("No perfecto_token given.") if value.to_s.empty?
109
+ end),
110
+ FastlaneCore::ConfigItem.new(key: :perfecto_media_location,
111
+ description: "Path to Perfecto media location",
112
+ optional: false,
113
+ is_string: true,
114
+ verify_block: proc do |value|
115
+ UI.user_error!("No perfecto_media_location given.") if value.to_s.empty?
116
+ end),
117
+ FastlaneCore::ConfigItem.new(key: :file_path,
118
+ description: "Path to the app file",
119
+ optional: true,
120
+ is_string: true,
121
+ default_value: default_file_path)
122
+ ]
123
+ end
124
+
125
+ def self.is_supported?(platform)
126
+ [:ios, :android].include?(platform)
127
+ end
128
+
129
+ def self.example_code
130
+ [
131
+ 'perfecto',
132
+ 'perfecto(
133
+ perfecto_cloudurl: ENV["PERFECTO_CLOUDURL"],
134
+ perfecto_token: ENV["PERFECTO_TOKEN"],
135
+ perfecto_media_location: ENV["PERFECTO_MEDIA_LOCATION"],
136
+ file_path: "path_to_apk_or_ipa_file"
137
+ )'
138
+ ]
139
+ end
140
+ end
141
+ end
142
+ end
data/lib/fastlane/plugin/perfecto/helper/perfecto_helper.rb ADDED
@@ -0,0 +1,45 @@
1
+ require 'rest-client'
2
+ require 'uri'
3
+ require 'fastlane_core/ui/ui'
4
+ require 'json'
5
+
6
+ module Fastlane
7
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
8
+
9
+ module Helper
10
+ class PerfectoHelper
11
+ # Uploads file to Perfecto
12
+ # Params :
13
+ # +perfecto_cloudurl+:: Perfecto's cloud name.
14
+ # +perfecto_token+:: Perfecto's security token.
15
+ # +file_path+:: Path to the file to be uploaded.
16
+ # +perfecto_media_fullpath+:: Path to the perfecto media location
17
+ def self.upload_file(perfecto_cloudurl, perfecto_token, file_path, perfecto_media_fullpath)
18
+ unless ENV['http_proxy']
19
+ RestClient.proxy = ENV['http_proxy']
20
+ end
21
+ response = RestClient::Request.execute(
22
+ url: 'https://' + perfecto_cloudurl + '/services/repositories/media/' + perfecto_media_fullpath + '?operation=upload&overwrite=true&securityToken=' + URI.encode(perfecto_token, "UTF-8"),
23
+ method: :post,
24
+ headers: {
25
+ 'Accept' => 'application/json',
26
+ 'Content-Type' => 'application/octet-stream',
27
+ 'Expect' => '100-continue'
28
+ },
29
+ payload: File.open(file_path, "rb")
30
+ )
31
+ UI.message(response.inspect)
32
+ rescue RestClient::ExceptionWithResponse => err
33
+ begin
34
+ error_response = err.response.to_s
35
+ rescue
36
+ error_response = "Internal server error"
37
+ end
38
+ # Give error if upload failed.
39
+ UI.user_error!("App upload failed!!! Reason : #{error_response}")
40
+ rescue StandardError => error
41
+ UI.user_error!("App upload failed!!! Reason : #{error.message}")
42
+ end
43
+ end
44
+ end
45
+ end
data/lib/fastlane/plugin/perfecto/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Perfecto
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-perfecto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Perfecto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-14 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: rspec_junit_formatter
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: rake
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: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.49.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.49.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-require_tools
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: fastlane
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.139.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.139.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rest-client
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.0'
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: 2.0.2
149
+ type: :runtime
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: '2.0'
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: 2.0.2
159
+ description:
160
+ email: support@perfectomobile.com
161
+ executables: []
162
+ extensions: []
163
+ extra_rdoc_files: []
164
+ files:
165
+ - LICENSE
166
+ - README.md
167
+ - lib/fastlane/plugin/perfecto.rb
168
+ - lib/fastlane/plugin/perfecto/actions/perfecto_action.rb
169
+ - lib/fastlane/plugin/perfecto/helper/perfecto_helper.rb
170
+ - lib/fastlane/plugin/perfecto/version.rb
171
+ homepage: https://github.com/PerfectoMobileSA/fastlane-plugin-perfecto
172
+ licenses:
173
+ - MIT
174
+ metadata: {}
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubygems_version: 3.0.4
191
+ signing_key:
192
+ specification_version: 4
193
+ summary: This plugin allows you to automatically upload ipa/apk files to Perfecto
194
+ for manual/automation testing
195
+ test_files: []