fastlane-plugin-perfecto 0.1.1 → 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: 82f5d7b6f7e5ea27af278d49c664729a69cf215783ec58cf384a741cd402ebe3
4
- data.tar.gz: dae80b7419c950252f8eb2402e92b1a24001ba522711e02c0a34a1304d603687
3
+ metadata.gz: 5af10b5acb0a274b115a1579efdce4f53759428d387ce3bd89aee501bb24d9aa
4
+ data.tar.gz: f722fe09bb1cc5c187642ca59bef142f82e75eb2da6b3a0156a569fe38fab0bd
5
5
  SHA512:
6
- metadata.gz: c1d5dcf6c5f002d5e9a85e7808a5cf9ab000d2b7a96e1ee0ac445ef8635c5cc238332da943ccd8f900ce67fe0a37a303573136a9152a77b2e57ad8ca8aa3343c
7
- data.tar.gz: efba9f2a9c5ea6763d006ca40317f851d172bf15bf76cd40bfd91c167e769562bfd7b38cb51c332a457b1040cca0d8af833f751f379c01e6fa79c15ae283aa0a
6
+ metadata.gz: 458d2df44edf7fd7355552b50640fb6bfc2206085ab512d53c38697116e4dac5d1dea93e154b38e1df3787f5a55f79bcf5fc9fd0dcedf29ac72ddb8ce4f43043
7
+ data.tar.gz: ebc76b750839a84986cfaff6bdeca39a5258595eaa56d1d1c20ca5a3432a95a7713b341bc0f6b4cab0e196d6d1aaf0c97fca4283dec5d796e7fa116f17b5de1d
data/README.md CHANGED
@@ -11,10 +11,13 @@ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To
11
11
  fastlane add_plugin perfecto
12
12
  ```
13
13
 
14
- ## About perfecto
14
+ ## About plugin
15
15
 
16
16
  This plugin allows you to automatically upload ipa/apk files to Perfecto for manual/automation testing
17
17
 
18
+ ## Updates
19
+ This plugin uses latest v1 upload media API under the hood and supports all file types.
20
+
18
21
 
19
22
  ## Example
20
23
 
@@ -33,13 +36,37 @@ lane :test do
33
36
  )
34
37
  end
35
38
  ```
39
+
40
+ Optional parameters:
41
+
42
+ ```
43
+ artifactType: ENV["artifactType"],
44
+ artifactName: ENV["artifactName"],
45
+ ```
46
+
36
47
  ### Note: <br>
37
48
  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>
49
+ &nbsp; * PERFECTO_CLOUDURL [your perfecto cloud url. E.g.: demo.perfectomobile.com]<br>
50
+ &nbsp; * PERFECTO_TOKEN [your perfecto [`security token`](https://developers.perfectomobile.com/display/PD/Generate+security+tokens)]<br>
51
+ &nbsp; * PERFECTO_MEDIA_LOCATION [mention the Perfecto media repository location to upload the file mentioned in file_path. E.g. PUBLIC:Samples/sample.ipa]<br>
52
+ &nbsp; * file_path [location of your preferred ipa/apk file which needs to be uploaded to perfecto media repository.]<br>
53
+ &nbsp; * artifactType [Optional: Defines the artifact types, options: GENERAL, IOS, SIMULATOR, ANDROID, IMAGE, AUDIO, VIDEO, SCRIPT]<br>
54
+ &nbsp; * artifactName [Optional: Used for the representation of the artifact when downloaded.]<br>
55
+
56
+ ## Run tests for this plugin
57
+
58
+ To run both the tests, and code style validation, run
59
+
60
+ ```
61
+ rake
62
+ ```
63
+
64
+ To automatically fix many of the styling issues, use
65
+ ```
66
+ rubocop -a
67
+ ```
68
+
69
+ ## Sample project: <br>
43
70
 
44
71
  Here's a [`sample project`](https://github.com/PerfectoMobileSA/FastlaneEspressoCircleCISlackSample) which demonstrates the usage of this plugin.
45
72
 
@@ -73,20 +100,6 @@ fastlane android slack_report
73
100
  ```
74
101
  Report perfecto url to slack
75
102
 
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
103
  ## Issues and Feedback
91
104
 
92
105
  For any other issues and feedback about this plugin, please submit it to this repository.
@@ -1,37 +1,38 @@
1
- require 'fastlane/action'
2
- require_relative '../helper/perfecto_helper'
3
- require 'json'
1
+ require "fastlane/action"
2
+ require_relative "../helper/perfecto_helper"
3
+ require "json"
4
4
 
5
5
  module Fastlane
6
6
  module Actions
7
7
  module SharedValues
8
8
  PERFECTO_MEDIA_FULLPATH ||= :PERFECTO_MEDIA_FULLPATH
9
9
  end
10
- class PerfectoAction < Action
11
- SUPPORTED_FILE_EXTENSIONS = ["ipa", "apk"]
12
10
 
11
+ class PerfectoAction < Action
13
12
  def self.run(params)
14
13
  # Mandatory parameters
15
14
  perfecto_cloudurl = params[:perfecto_cloudurl]
16
15
  perfecto_token = params[:perfecto_token]
17
16
  filepath = params[:file_path].to_s
18
17
  perfecto_media_fullpath = params[:perfecto_media_location]
18
+ artifact_type = params[:artifactType] || ""
19
+ artifact_nme = params[:artifactName] || ""
19
20
 
20
21
  # validates the filepath and perfecto media location file
21
22
  UI.message("validating filepath")
22
23
  validate_filepath(filepath)
23
- UI.message("validating media location")
24
- validate_repopath(perfecto_media_fullpath)
24
+ UI.message("validating media location")
25
25
 
26
26
  # uploads the ipa/apk to perfecto media repository
27
27
  UI.message("Attempting to upload: " + filepath + " to Perfecto!")
28
- Helper::PerfectoHelper.upload_file(perfecto_cloudurl, perfecto_token, filepath, perfecto_media_fullpath)
28
+ # Helper::PerfectoHelper.upload_file(perfecto_cloudurl, perfecto_token, filepath, perfecto_media_fullpath)
29
+ Helper::PerfectoHelper.upload_v1(perfecto_cloudurl, perfecto_token, filepath, perfecto_media_fullpath, artifact_type, artifact_nme)
29
30
  UI.success("The File in: " + filepath + " is successfully uploaded to Perfecto media location : " + perfecto_media_fullpath)
30
31
 
31
32
  # 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'])
33
+ ENV["PERFECTO_MEDIA_FULLPATH"] = nil
34
+ ENV["PERFECTO_MEDIA_FULLPATH"] = perfecto_media_fullpath
35
+ UI.success("Setting Environment variable PERFECTO_MEDIA_FULLPATH = " + ENV["PERFECTO_MEDIA_FULLPATH"])
35
36
 
36
37
  # Setting the media fullpath in shared values post successful upload in order to be used by other fastlane actions.
37
38
  Actions.lane_context[SharedValues::PERFECTO_MEDIA_FULLPATH] = perfecto_media_fullpath
@@ -57,26 +58,11 @@ module Fastlane
57
58
  # Validate filepath.
58
59
  def self.validate_filepath(filepath)
59
60
  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
61
  end
76
62
 
77
63
  def self.output
78
64
  [
79
- ['perfecto_media_fullpath', 'Perfecto media repo location']
65
+ ["perfecto_media_fullpath", "Perfecto media repo location"]
80
66
  ]
81
67
  end
82
68
 
@@ -108,12 +94,22 @@ module Fastlane
108
94
  UI.user_error!("No perfecto_token given.") if value.to_s.empty?
109
95
  end),
110
96
  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),
97
+ description: "Path to Perfecto media location",
98
+ optional: false,
99
+ is_string: true,
100
+ verify_block: proc do |value|
101
+ UI.user_error!("No perfecto_media_location given.") if value.to_s.empty?
102
+ end),
103
+ FastlaneCore::ConfigItem.new(key: :artifactType,
104
+ description: "Optional, Artifact types: GENERAL, IOS, SIMULATOR, ANDROID, IMAGE, AUDIO, VIDEO, SCRIPT",
105
+ optional: true,
106
+ default_value: "",
107
+ is_string: true),
108
+ FastlaneCore::ConfigItem.new(key: :artifactName,
109
+ description: "Optional, Used for the representation of the artifact when downloaded",
110
+ optional: true,
111
+ default_value: "",
112
+ is_string: true),
117
113
  FastlaneCore::ConfigItem.new(key: :file_path,
118
114
  description: "Path to the app file",
119
115
  optional: true,
@@ -128,12 +124,14 @@ module Fastlane
128
124
 
129
125
  def self.example_code
130
126
  [
131
- 'perfecto',
127
+ "perfecto",
132
128
  'perfecto(
133
129
  perfecto_cloudurl: ENV["PERFECTO_CLOUDURL"],
134
130
  perfecto_token: ENV["PERFECTO_TOKEN"],
135
131
  perfecto_media_location: ENV["PERFECTO_MEDIA_LOCATION"],
136
- file_path: "path_to_apk_or_ipa_file"
132
+ file_path: "path_to_apk_or_ipa_file",
133
+ artifactType: ENV["artifactType"],
134
+ artifactName: ENV["artifactName"]
137
135
  )'
138
136
  ]
139
137
  end
@@ -1,7 +1,8 @@
1
- require 'rest-client'
2
- require 'uri'
3
- require 'fastlane_core/ui/ui'
4
- require 'json'
1
+ require "rest-client"
2
+ require "uri"
3
+ require "fastlane_core/ui/ui"
4
+ require "json"
5
+ require "net/http"
5
6
 
6
7
  module Fastlane
7
8
  UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
@@ -14,17 +15,18 @@ module Fastlane
14
15
  # +perfecto_token+:: Perfecto's security token.
15
16
  # +file_path+:: Path to the file to be uploaded.
16
17
  # +perfecto_media_fullpath+:: Path to the perfecto media location
18
+ # DEPRECATED
17
19
  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
+ unless ENV["http_proxy"]
21
+ RestClient.proxy = ENV["http_proxy"]
20
22
  end
21
23
  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"),
24
+ url: "https://" + perfecto_cloudurl + "/services/repositories/media/" + perfecto_media_fullpath + "?operation=upload&overwrite=true&securityToken=" + URI.encode(perfecto_token, "UTF-8"),
23
25
  method: :post,
24
26
  headers: {
25
- 'Accept' => 'application/json',
26
- 'Content-Type' => 'application/octet-stream',
27
- 'Expect' => '100-continue'
27
+ "Accept" => "application/json",
28
+ "Content-Type" => "application/octet-stream",
29
+ "Expect" => "100-continue"
28
30
  },
29
31
  payload: File.open(file_path, "rb")
30
32
  )
@@ -40,6 +42,49 @@ module Fastlane
40
42
  rescue StandardError => error
41
43
  UI.user_error!("App upload failed!!! Reason : #{error.message}")
42
44
  end
45
+
46
+ def self.parameters(request_part, key, value)
47
+ unless value.to_s.strip.empty?
48
+ return request_part.merge!(key => value)
49
+ end
50
+ end
51
+
52
+ # Uploads file to Perfecto using new V1 upload API
53
+ # Params :
54
+ # +perfecto_cloudurl+:: Perfecto's cloud name.
55
+ # +perfecto_token+:: Perfecto's security token.
56
+ # +file_path+:: Path to the file to be uploaded.
57
+ # +perfecto_media_fullpath+:: Path to the perfecto media location
58
+ # +artifact_type+:: Artifact Type
59
+ # +artifact_name+:: Artifact Name
60
+ def self.upload_v1(perfecto_cloudurl, perfecto_token, file_path, perfecto_media_fullpath, artifact_type, artifact_name)
61
+ # prepare cloud url
62
+ if perfecto_cloudurl.include?(".perfectomobile.com")
63
+ perfecto_cloudurl = perfecto_cloudurl.split(".perfectomobile.com")[0]
64
+ if perfecto_cloudurl.include?(".app")
65
+ perfecto_cloudurl = perfecto_cloudurl.split(".app")[0]
66
+ end
67
+ end
68
+
69
+ url = URI("https://" + perfecto_cloudurl + ".app.perfectomobile.com/repository/api/v1/artifacts")
70
+ https = Net::HTTP.new(url.host, url.port)
71
+ https.use_ssl = true
72
+ request = Net::HTTP::Post.new(url)
73
+ request["Perfecto-Authorization"] = perfecto_token
74
+ request_part = { "artifactLocator" => perfecto_media_fullpath, "override" => true }
75
+ parameters(request_part, "artifactType", artifact_type)
76
+ parameters(request_part, "artifactName", artifact_name)
77
+ request_part = request_part.to_json.to_s.gsub("=>", ":")
78
+ # Debug: puts request_part
79
+ form_data = [["requestPart", request_part], ["inputStream", File.open(file_path, "rb")]]
80
+ request.set_form(form_data, "multipart/form-data")
81
+ response = https.request(request)
82
+ UI.message(response.inspect)
83
+ if response.code != "200"
84
+ # Give error if upload failed.
85
+ UI.user_error!("App upload failed!!! Reason : #{response}")
86
+ end
87
+ end
43
88
  end
44
89
  end
45
90
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Perfecto
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-perfecto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perfecto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-14 00:00:00.000000000 Z
11
+ date: 2021-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -156,7 +156,7 @@ dependencies:
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
158
  version: 2.0.2
159
- description:
159
+ description:
160
160
  email: support@perfectomobile.com
161
161
  executables: []
162
162
  extensions: []
@@ -172,7 +172,7 @@ homepage: https://github.com/PerfectoMobileSA/fastlane-plugin-perfecto
172
172
  licenses:
173
173
  - MIT
174
174
  metadata: {}
175
- post_install_message:
175
+ post_install_message:
176
176
  rdoc_options: []
177
177
  require_paths:
178
178
  - lib
@@ -187,8 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
189
  requirements: []
190
- rubygems_version: 3.0.4
191
- signing_key:
190
+ rubygems_version: 3.1.6
191
+ signing_key:
192
192
  specification_version: 4
193
193
  summary: This plugin allows you to automatically upload ipa/apk files to Perfecto
194
194
  for manual/automation testing