fastlane-plugin-run_tests_firebase_testlab 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 18a59923efe2a8fd8f60fb14bc84738914c176b2
4
+ data.tar.gz: cdc8410dc9a9d2a14005aefd500f0dbc0cd900cd
5
+ SHA512:
6
+ metadata.gz: a164455b68cf929e313fb692c06b400d841988f3dd1868a6dbee6238ea689aeae014ba27cb2066ba94848e9e33cafba68285a8a855ddeec252bd0abf889ce9a8
7
+ data.tar.gz: 489780097f63d24dfdc2124ea16461750f5bb23c35c87a79728222c5debec3b74d317e6abab5711612704299156a9e998acd8c855b8ee08a76d8c2f8817c95a8
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Pink Room
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,172 @@
1
+ # run_tests_firebase_testlab plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-run_tests_firebase_testlab)
4
+ [![Build
5
+ Status](https://travis-ci.org/pink-room/fastlane-plugin-run_tests_firebase_testlab.svg?branch=master)](https://travis-ci.org/pink-room/fastlane-plugin-run_tests_firebase_testlab)
6
+
7
+ ## Getting Started
8
+
9
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-run_tests_firebase_testlab`, add it to your project by running:
10
+
11
+ ```bash
12
+ fastlane add_plugin run_tests_firebase_testlab
13
+ ```
14
+
15
+ ## About run_tests_firebase_testlab
16
+
17
+ * Authenticates with Google Cloud.
18
+
19
+ * Runs Android tests in Firebase Test Lab.
20
+
21
+ * Fetches the results to a local directory.
22
+
23
+ * Deletes the results from firebase bucket if wanted.
24
+
25
+ ## Example
26
+
27
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin.
28
+
29
+ ### Simple usage
30
+
31
+ ```
32
+ run_tests_firebase_testlab(
33
+ project_id: "your-firebase-project-id",
34
+ model: "Nexus6P",
35
+ version: "27")
36
+ ```
37
+
38
+ ### Parameters
39
+
40
+ <table>
41
+ <thead>
42
+ <tr>
43
+ <th>Parameter</th>
44
+ <th>Description</th>
45
+ <th>Optional</th>
46
+ <th>Default</th>
47
+ </tr>
48
+ </thead>
49
+ <tbody>
50
+
51
+ <tr>
52
+ <td><b>project_id</b></td>
53
+ <td>Your Firebase project id</td>
54
+ <td>No</td>
55
+ <td>-</td>
56
+ </tr>
57
+
58
+ <tr>
59
+ <td><b>model</b></td>
60
+ <td>The device's model on which the tests will be run</td>
61
+ <td>No</td>
62
+ <td>-</td>
63
+ </tr>
64
+
65
+ <tr>
66
+ <td><b>version</b></td>
67
+ <td>The Android api version of the device</td>
68
+ <td>No</td>
69
+ <td>-</td>
70
+ </tr>
71
+
72
+ <tr>
73
+ <td>app_apk</td>
74
+ <td>The path for your app apk</td>
75
+ <td>Yes</td>
76
+ <td>app/build/outputs/apk/debug/<br>app-debug.apk</td>
77
+ </tr>
78
+
79
+ <tr>
80
+ <td>android_test_apk</td>
81
+ <td>The path for your android test apk</td>
82
+ <td>Yes</td>
83
+ <td>app/build/outputs/apk/androidTest/<br>debug/app-debug-androidTest.apk</td>
84
+ </tr>
85
+
86
+ <tr>
87
+ <td>locale</td>
88
+ <td>The locale to test against</td>
89
+ <td>Yes</td>
90
+ <td>en_US</td>
91
+ </tr>
92
+
93
+ <tr>
94
+ <td>orientation</td>
95
+ <td>The orientation of the device</td>
96
+ <td>Yes</td>
97
+ <td>portrait</td>
98
+ </tr>
99
+
100
+ <tr>
101
+ <td>timeout</td>
102
+ <td>The max time this test execution can run before it is cancelled</td>
103
+ <td>Yes</td>
104
+ <td>30m</td>
105
+ </tr>
106
+
107
+ <tr>
108
+ <td>output_dir</td>
109
+ <td>The directory to save the output results</td>
110
+ <td>Yes</td>
111
+ <td>firebase</td>
112
+ </tr>
113
+
114
+ <tr>
115
+ <td>bucket_url</td>
116
+ <td>The bucket url where the test results were stored</td>
117
+ <td>Yes</td>
118
+ <td>Parsed automatically from tests output</td>
119
+ </tr>
120
+
121
+ <tr>
122
+ <td>delete_firebase_files</td>
123
+ <td>A flag to control if the firebase files should be deleted from the bucket or not</td>
124
+ <td>Yes</td>
125
+ <td>false</td>
126
+ </tr>
127
+
128
+ <tr>
129
+ <td>extra_options</td>
130
+ <td>Extra options that you need to pass to the gcloud command</td>
131
+ <td>Yes</td>
132
+ <td>empty string</td>
133
+ </tr>
134
+
135
+ <tr>
136
+ <td>gcloud_service_key_file</td>
137
+ <td>File path containing the gcloud auth key</td>
138
+ <td>Yes</td>
139
+ <td>Created from GCLOUD_SERVICE_KEY environment variable</td>
140
+ </tr>
141
+
142
+ </tbody>
143
+ </table>
144
+
145
+ ## Run tests for this plugin
146
+
147
+ To run both the tests, and code style validation, run
148
+
149
+ ```
150
+ rake
151
+ ```
152
+
153
+ To automatically fix many of the styling issues, use
154
+ ```
155
+ rubocop -a
156
+ ```
157
+
158
+ ## Issues and Feedback
159
+
160
+ For any other issues and feedback about this plugin, please submit it to this repository.
161
+
162
+ ## Troubleshooting
163
+
164
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
165
+
166
+ ## Using _fastlane_ Plugins
167
+
168
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
169
+
170
+ ## About _fastlane_
171
+
172
+ _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).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/run_tests_firebase_testlab/version'
2
+
3
+ module Fastlane
4
+ module RunTestsFirebaseTestlab
5
+ # Return all .rb files inside the "actions" and "commands" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,commands}/*.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::RunTestsFirebaseTestlab.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,196 @@
1
+ module Fastlane
2
+ module Actions
3
+ class RunTestsFirebaseTestlabAction < Action
4
+ @client_secret_file = "client-secret.json"
5
+ @test_console_output_file = "instrumentation_output.txt"
6
+
7
+ class << self
8
+ attr_reader :client_secret_file, :test_console_output_file
9
+ end
10
+
11
+ def self.run(params)
12
+ UI.message("Starting run_tests_firebase_testlab plugin...")
13
+
14
+ if params[:gcloud_service_key_file].nil?
15
+ UI.message("Save Google Cloud credentials.")
16
+ File.open(@client_secret_file, 'w') do |file|
17
+ file.write(ENV["GCLOUD_SERVICE_KEY"])
18
+ end
19
+ else
20
+ @client_secret_file = params[:gcloud_service_key_file]
21
+ end
22
+
23
+ UI.message("Set Google Cloud target project.")
24
+ Action.sh("#{Commands.config} #{params[:project_id]}")
25
+
26
+ UI.message("Authenticate with Google Cloud.")
27
+ Action.sh("#{Commands.auth} --key-file #{@client_secret_file}")
28
+
29
+ UI.message("Running instrumentation tests in Firebase Test Lab...")
30
+ Action.sh("#{Commands.run_tests} "\
31
+ "--type instrumentation "\
32
+ "--app #{params[:app_apk]} "\
33
+ "--test #{params[:android_test_apk]} "\
34
+ "--device model=#{params[:model]},version=#{params[:version]},locale=#{params[:locale]},orientation=#{params[:orientation]} "\
35
+ "--timeout #{params[:timeout]} "\
36
+ "#{params[:extra_options]} "\
37
+ "2>&1 | tee #{@test_console_output_file}")
38
+
39
+ UI.message("Create firebase directory (if not exists) to store test results.")
40
+ FileUtils.mkdir_p(params[:output_dir])
41
+
42
+ if params[:bucket_url].nil?
43
+ UI.message("Parse firebase bucket url.")
44
+ params[:bucket_url] = scrape_bucket_url
45
+ UI.message("bucket: #{params[:bucket_url]}")
46
+ end
47
+
48
+ UI.message("Downloading instrumentation test results from Firebase Test Lab...")
49
+ Action.sh("#{Commands.download_results} #{params[:bucket_url]} #{params[:output_dir]}/")
50
+
51
+ if params[:delete_firebase_files]
52
+ UI.message("Deleting files from firebase storage...")
53
+ Action.sh("#{Commands.delete_resuls} #{params[:bucket_url]}")
54
+ end
55
+ end
56
+
57
+ def self.description
58
+ "Runs Android tests in Firebase Test Lab."
59
+ end
60
+
61
+ def self.authors
62
+ ["bffcorreia"]
63
+ end
64
+
65
+ def self.details
66
+ [
67
+ "Authenticates with Google Cloud.",
68
+ "Runs tests in Firebase Test Lab.",
69
+ "Fetches the results to a local directory.",
70
+ "Deletes the results from firebase bucket if wanted."
71
+ ].join("\n")
72
+ end
73
+
74
+ def self.output
75
+ [
76
+ ['bugreport.txt', 'A bugreport of the app.'],
77
+ ['instrumentation.results', 'The results of the instrumentation tests.'],
78
+ ['logcat', 'Logs from logcat.'],
79
+ ['test_result_0.xml', 'A xml file that contains all the tests.'],
80
+ ['video.mp4', 'A video of the tests.']
81
+ ]
82
+ end
83
+
84
+ def self.available_options
85
+ [
86
+ FastlaneCore::ConfigItem.new(key: :project_id,
87
+ env_name: "PROJECT_ID",
88
+ description: "Your Firebase project id",
89
+ is_string: true,
90
+ optional: false),
91
+ FastlaneCore::ConfigItem.new(key: :model,
92
+ env_name: "MODEL",
93
+ description: "The device's model on which the tests will be run",
94
+ is_string: true,
95
+ optional: false),
96
+ FastlaneCore::ConfigItem.new(key: :version,
97
+ env_name: "VERSION",
98
+ description: "The Android api version of the device",
99
+ is_string: true,
100
+ optional: false),
101
+ FastlaneCore::ConfigItem.new(key: :app_apk,
102
+ env_name: "APP_APK",
103
+ description: "The path for your app apk. Default: app/build/outputs/apk/debug/app-debug.apk",
104
+ is_string: true,
105
+ optional: true,
106
+ default_value: "app/build/outputs/apk/debug/app-debug.apk"),
107
+ FastlaneCore::ConfigItem.new(key: :android_test_apk,
108
+ env_name: "ANDROID_TEST_APK",
109
+ description: "The path for your android test apk. Default: app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",
110
+ is_string: true,
111
+ optional: true,
112
+ default_value: "app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk"),
113
+ FastlaneCore::ConfigItem.new(key: :locale,
114
+ env_name: "LOCALE",
115
+ description: "The locale to test against. Default: en_US",
116
+ is_string: true,
117
+ optional: true,
118
+ default_value: "en_US"),
119
+ FastlaneCore::ConfigItem.new(key: :orientation,
120
+ env_name: "ORIENTATION",
121
+ description: "The orientation of the device. Default: portrait",
122
+ is_string: true,
123
+ optional: true,
124
+ default_value: "portrait"),
125
+ FastlaneCore::ConfigItem.new(key: :timeout,
126
+ env_name: "TIMEOUT",
127
+ description: "The max time this test execution can run before it is cancelled. Default: 30m",
128
+ is_string: true,
129
+ optional: true,
130
+ default_value: "30m"),
131
+ FastlaneCore::ConfigItem.new(key: :output_dir,
132
+ env_name: "OUTPUT_DIR",
133
+ description: "The directory to save the output results. Default: firebase",
134
+ is_string: true,
135
+ optional: true,
136
+ default_value: "firebase"),
137
+ FastlaneCore::ConfigItem.new(key: :bucket_url,
138
+ env_name: "BUCKET_URL",
139
+ description: "The bucket url where the test results were stored. Default: Parsed automatically from tests output",
140
+ is_string: true,
141
+ optional: true,
142
+ default_value: nil),
143
+ FastlaneCore::ConfigItem.new(key: :delete_firebase_files,
144
+ env_name: "DELETE_FIREBASE_FILES",
145
+ description: "A flag to controll if the firebase files should be deleted from the bucket or not. Default: false",
146
+ is_string: false,
147
+ optional: true,
148
+ default_value: false),
149
+ FastlaneCore::ConfigItem.new(key: :extra_options,
150
+ env_name: "EXTRA_OPTIONS",
151
+ description: "Extra options that you need to pass to the gcloud command. Default: empty string",
152
+ is_string: true,
153
+ optional: true,
154
+ default_value: ""),
155
+ FastlaneCore::ConfigItem.new(key: :gcloud_service_key_file,
156
+ env_name: "GCLOUD_SERVICE_KEY_FILE",
157
+ description: "File path containing the gcloud auth key. Default: Created from GCLOUD_SERVICE_KEY environment variable",
158
+ is_string: true,
159
+ optional: true,
160
+ default_value: nil)
161
+ ]
162
+ end
163
+
164
+ def self.is_supported?(platform)
165
+ platform == :android
166
+ end
167
+
168
+ def self.example_code
169
+ [
170
+ 'run_tests_firebase_testlab(
171
+ project_id: "your-firebase-project-id",
172
+ model: "Nexus6P",
173
+ version: "27",
174
+ delete_firebase_files: true
175
+ )'
176
+ ]
177
+ end
178
+
179
+ def self.category
180
+ :testing
181
+ end
182
+
183
+ def self.scrape_bucket_url
184
+ File.open(@test_console_output_file).each do |line|
185
+ url = line.scan(/\[(.*)\]/).last&.first
186
+ next unless !url.nil? and (!url.empty? and url.include?("test-lab-"))
187
+ splitted_url = url.split("/")
188
+ length = splitted_url.length
189
+ return "gs://#{splitted_url[length - 2]}/#{splitted_url[length - 1]}"
190
+ end
191
+ end
192
+
193
+ private_class_method :scrape_bucket_url
194
+ end
195
+ end
196
+ end
@@ -0,0 +1,23 @@
1
+ module Fastlane
2
+ module Commands
3
+ def self.config
4
+ "gcloud config set project"
5
+ end
6
+
7
+ def self.auth
8
+ "gcloud auth activate-service-account"
9
+ end
10
+
11
+ def self.run_tests
12
+ "gcloud firebase test android run"
13
+ end
14
+
15
+ def self.download_results
16
+ "gsutil -m cp -r"
17
+ end
18
+
19
+ def self.delete_resuls
20
+ "gsutil rm -r"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module RunTestsFirebaseTestlab
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-run_tests_firebase_testlab
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bruno Correia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-06 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.79.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.79.0
139
+ description:
140
+ email: bruno@pinkroom.co
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/run_tests_firebase_testlab.rb
148
+ - lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb
149
+ - lib/fastlane/plugin/run_tests_firebase_testlab/commands/commands.rb
150
+ - lib/fastlane/plugin/run_tests_firebase_testlab/version.rb
151
+ homepage: https://github.com/pink-room/fastlane-plugin-run_tests_firebase_testlab
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.4.8
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Runs Android tests in Firebase Test Lab.
175
+ test_files: []