fastlane-plugin-firebase_test_lab_android 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8703f0c3e4487ecd05516d8e1104a7d341068f87
4
+ data.tar.gz: 2337373ee1df4b4aa368372769e1583489c74c57
5
+ SHA512:
6
+ metadata.gz: ff4d07eacfec1045c78398479c1f4cdd90359d92191a481a27fc41fb00d873457e7d1698d6a14ef6f5be25d1e35fc81c74ad00bf70386beec3f868dbf9be63c9
7
+ data.tar.gz: d8841242fa07b00aef2e2a5417c5e4a8ec9dc80fd6475c8b51e4f99d6e48e68003d2f0b71cdf7ce9a52c2787623a4dd2db16660bc7b3efe3e40604a769849b9f
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,102 @@
1
+ # Firebase Test Lab plugin for fastlane
2
+
3
+ <p align="center">
4
+ <img src="./art/firebase-test-lab.jpg" width="600" />
5
+ </p>
6
+
7
+ Inspired by [Firebase test lab plugin for ios](https://github.com/fastlane/fastlane-plugin-firebase_test_lab)
8
+
9
+
10
+ ## Getting Started
11
+
12
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-firebase_test_lab_android`, add it to your project by running:
13
+
14
+ ```bash
15
+ (not yet)
16
+ fastlane add_plugin firebase_test_lab_android
17
+ ```
18
+
19
+ ### If you are not current user of Firebase
20
+
21
+ You need to set up Firebase first. These only needs to be done once for an organization.
22
+
23
+ - If you have not used Google Cloud before, you need to [create a new Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#Creating%20a%20Project) first.
24
+ - Go to the [Firebase Console](https://console.firebase.google.com/). Add Firebase into your Google Cloud project by clicking on "Add project" and then choose your just-created project.
25
+
26
+ ### Configure Google credentials through service accounts
27
+
28
+ To authenticate, Google Cloud credentials will need to be set for any machine where _fastlane_ and this plugin runs on.
29
+
30
+ If you are running this plugin on Google Cloud [Compute Engine](https://cloud.google.com/compute), [Kubernetes Engine](https://cloud.google.com/kubernetes-engine) or [App Engine flexible environment](https://cloud.google.com/appengine/docs/flexible/), a default service account is automatically provisioned. You will not need to create a service account. See [this](https://cloud.google.com/compute/docs/access/service-accounts#compute_engine_default_service_account) for more details.
31
+
32
+ In all other cases, you need to configure the service account manually. You can follow [this guide](https://cloud.google.com/docs/authentication/getting-started) on how to create a new service account and create a key for it. You will need to set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable pointing to the service account key file according to the document.
33
+
34
+ No matter if you are a using an automatically provisioned service account or a manually created one, the service account must be configured to have the project editor role.
35
+
36
+ ### Enable relevant Google APIs
37
+
38
+ - You need to enable the following APIs on your [Google Cloud API library](https://console.cloud.google.com/apis/library) (see [this](https://support.google.com/cloud/answer/6158841) for instructions how):
39
+ 1. Cloud Testing API
40
+ 2. Cloud Tool Results API
41
+
42
+ ### Find the devices you want to test on
43
+
44
+ If you have [gcloud tool](https://cloud.google.com/sdk/gcloud/), you can run
45
+
46
+ ```no-highlight
47
+ gcloud beta firebase test android models list
48
+ ```
49
+
50
+ to get a list of supported devices and their identifiers.
51
+
52
+ Alternatively all available devices can also be seen [here](https://firebase.google.com/docs/test-lab/ios/available-testing-devices).
53
+
54
+
55
+ ## Actions
56
+
57
+ Test your app with Firebase Test Lab with ease using fastlane.
58
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin.
59
+
60
+ ```ruby
61
+ before_all do
62
+ ENV["SLACK_URL"] = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX"
63
+ end
64
+
65
+ firebase_test_lab_android(
66
+ project_id: "cats-firebase",
67
+ gcloud_service_key_file: "fastlane/client-secret.json",
68
+ type: "robo",
69
+ devices: [
70
+ {
71
+ model: "hammerhead",
72
+ version: "21",
73
+ locale: "ja_JP",
74
+ orientation: "portrait"
75
+ },
76
+ {
77
+ model: "Pixel2",
78
+ version: "28"
79
+ }
80
+ ],
81
+ app_apk: "test.apk",
82
+ console_log_file_name: "fastlane/console_output.log",
83
+ timeout: "1m",
84
+ notify_to_slack: true
85
+ )
86
+ ```
87
+
88
+ ## Issues and Feedback
89
+
90
+ For any other issues and feedback about this plugin, please submit it to this repository.
91
+
92
+ ## Troubleshooting
93
+
94
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
95
+
96
+ ## Using _fastlane_ Plugins
97
+
98
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
99
+
100
+ ## About _fastlane_
101
+
102
+ _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,15 @@
1
+ require 'fastlane/plugin/firebase_test_lab_android/version'
2
+
3
+ module Fastlane
4
+ module FirebaseTestLabAndroid
5
+ def self.all_classes
6
+ Dir[File.expand_path('**/{actions}/*.rb', File.dirname(__FILE__))]
7
+ end
8
+ end
9
+ end
10
+
11
+ # By default we want to import all available actions
12
+ # A plugin can contain any number of actions and plugins
13
+ Fastlane::FirebaseTestLabAndroid.all_classes.each do |current|
14
+ require current
15
+ end
@@ -0,0 +1,197 @@
1
+ require 'fastlane/action'
2
+
3
+ module Fastlane
4
+ module Commands
5
+ def self.config
6
+ "gcloud config set project"
7
+ end
8
+
9
+ def self.auth
10
+ "gcloud auth activate-service-account"
11
+ end
12
+
13
+ def self.run_tests
14
+ "gcloud firebase test android run"
15
+ end
16
+ end
17
+
18
+ module Actions
19
+ class FirebaseTestLabAndroidAction < Action
20
+ PIPE = "testlab-pipe"
21
+
22
+ def self.run(params)
23
+ UI.message("Starting...")
24
+
25
+ UI.message("Set Google Cloud target project.")
26
+ Action.sh("#{Commands.config} #{params[:project_id]}")
27
+
28
+ UI.message("Authenticate with Google Cloud.")
29
+ Action.sh("#{Commands.auth} --key-file #{params[:gcloud_service_key_file]}")
30
+
31
+ UI.message("Running...")
32
+ Action.sh("rm #{PIPE}") if File.exist?(PIPE)
33
+ Action.sh("mkfifo #{PIPE}")
34
+ Action.sh("set +e;"\
35
+ "tee #{params[:console_log_file_name]} < #{PIPE} & "\
36
+ "#{Commands.run_tests} "\
37
+ "--type #{params[:type]} "\
38
+ "--app #{params[:app_apk]} "\
39
+ "#{"--test #{params[:app_test_apk]} " unless params[:app_test_apk].nil?}"\
40
+ "#{params[:devices].map { |d| "--device model=#{d[:model]},version=#{d[:version]},locale=#{d[:locale]},orientation=#{d[:orientation]} " }.join}"\
41
+ "--timeout #{params[:timeout]} "\
42
+ "#{params[:extra_options]} "\
43
+ "> #{PIPE} 2>&1;"\
44
+ "set -e")
45
+ Action.sh("rm #{PIPE}") if File.exist?(PIPE)
46
+
47
+ if params[:notify_to_slack]
48
+ output = File.read(params[:console_log_file_name])
49
+ failed = output.include?("Failed") || output.include?("Inconclusive")
50
+ other_action.slack(message: output,
51
+ success: !failed,
52
+ use_webhook_configured_username_and_icon: true,
53
+ default_payloads: [:git_branch, :git_author, :last_git_commit])
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
+ ["Wasabeef"]
63
+ end
64
+
65
+ def self.return_value
66
+ ["Authenticates with Google Cloud.",
67
+ "Runs tests in Firebase Test Lab.",
68
+ "Fetches the results to a local directory."].join("\n")
69
+ end
70
+
71
+ def self.details
72
+ # Optional:
73
+ "Test your app with Firebase Test Lab with ease using fastlane"
74
+ end
75
+
76
+ def self.available_options
77
+ [FastlaneCore::ConfigItem.new(key: :project_id,
78
+ env_name: "PROJECT_ID",
79
+ description: "Your Firebase project id",
80
+ is_string: true,
81
+ optional: false),
82
+ FastlaneCore::ConfigItem.new(key: :gcloud_service_key_file,
83
+ env_name: "GCLOUD_SERVICE_KEY_FILE",
84
+ description: "File path containing the gcloud auth key. Default: Created from GCLOUD_SERVICE_KEY environment variable",
85
+ is_string: true,
86
+ optional: false),
87
+ FastlaneCore::ConfigItem.new(key: :type,
88
+ env_name: "TYPE",
89
+ description: "Test type. Default: robo (robo/instrumentation)",
90
+ is_string: true,
91
+ optional: true,
92
+ default_value: "robo"),
93
+ FastlaneCore::ConfigItem.new(key: :devices,
94
+ description: "Devices to test the app on",
95
+ type: Array,
96
+ default_value: [{
97
+ model: "Nexus6",
98
+ version: "21",
99
+ locale: "en_US",
100
+ orientation: "portrait"
101
+ }],
102
+ verify_block: proc do |value|
103
+ if value.empty?
104
+ UI.user_error!("Devices cannot be empty")
105
+ end
106
+ value.each do |current|
107
+ if current.class != Hash
108
+ UI.user_error!("Each device must be represented by a Hash object, " \
109
+ "#{current.class} found")
110
+ end
111
+ check_has_property(current, :model)
112
+ check_has_property(current, :version)
113
+ set_default_property(current, :locale, "en_US")
114
+ set_default_property(current, :orientation, "portrait")
115
+ end
116
+ end),
117
+ FastlaneCore::ConfigItem.new(key: :timeout,
118
+ env_name: "TIMEOUT",
119
+ description: "The max time this test execution can run before it is cancelled. Default: 5m (this value must be greater than or equal to 1m)",
120
+ is_string: true,
121
+ optional: true,
122
+ default_value: "5m"),
123
+ FastlaneCore::ConfigItem.new(key: :app_apk,
124
+ env_name: "APP_APK",
125
+ description: "The path for your android app apk",
126
+ is_string: true,
127
+ optional: false),
128
+ FastlaneCore::ConfigItem.new(key: :app_test_apk,
129
+ env_name: "APP_TEST_APK",
130
+ description: "The path for your android test apk. Default: empty string",
131
+ is_string: true,
132
+ optional: true,
133
+ default_value: nil),
134
+ FastlaneCore::ConfigItem.new(key: :console_log_file_name,
135
+ env_name: "CONSOLE_LOG_FILE_NAME",
136
+ description: "The filename to save the output results. Default: ./console_output.log",
137
+ is_string: true,
138
+ optional: true,
139
+ default_value: "./console_output.log"),
140
+ FastlaneCore::ConfigItem.new(key: :extra_options,
141
+ env_name: "EXTRA_OPTIONS",
142
+ description: "Extra options that you need to pass to the gcloud command. Default: empty string",
143
+ is_string: true,
144
+ optional: true,
145
+ default_value: ""),
146
+ FastlaneCore::ConfigItem.new(key: :notify_to_slack,
147
+ env_name: "NOTIFY_TO_SLACK",
148
+ description: "Notify to Slack after finishing of the test. Default: false",
149
+ is_string: false,
150
+ optional: true,
151
+ default_value: false)]
152
+ end
153
+
154
+ def self.check_has_property(hash_obj, property)
155
+ UI.user_error!("Each device must have #{property} property") unless hash_obj.key?(property)
156
+ end
157
+
158
+ def self.set_default_property(hash_obj, property, default)
159
+ unless hash_obj.key?(property)
160
+ hash_obj[property] = default
161
+ end
162
+ end
163
+
164
+ def self.is_supported?(platform)
165
+ platform == :android
166
+ end
167
+
168
+ def self.output
169
+ [['console_output.log', 'A console log when running Firebase Test Lab with gcloud']]
170
+ end
171
+
172
+ def self.example_code
173
+ ['firebase_test_lab_android(
174
+ project_id: "winticket-firebase",
175
+ gcloud_service_key_file: "fastlane/client-secret.json",
176
+ type: "robo",
177
+ devices: [
178
+ {
179
+ model: "hammerhead",
180
+ version: "21",
181
+ locale: "ja_JP",
182
+ orientation: "portrait"
183
+ },
184
+ {
185
+ model: "Pixel2",
186
+ version: "28"
187
+ }
188
+ ],
189
+ app_apk: "test.apk",
190
+ console_log_file_name: "fastlane/console_output.log",
191
+ timeout: "3m",
192
+ notify_to_slack: true
193
+ )']
194
+ end
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module FirebaseTestLabAndroid
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-firebase_test_lab_android
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - wasabeef
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-01 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.116.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.116.0
139
+ description:
140
+ email: dadadada.chop@gmail.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/firebase_test_lab_android.rb
148
+ - lib/fastlane/plugin/firebase_test_lab_android/actions/firebase_test_lab_android_action.rb
149
+ - lib/fastlane/plugin/firebase_test_lab_android/version.rb
150
+ homepage: https://github.com/cats-oss/fastlane-plugin-firebase_test_lab_android
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.5.2.3
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Test your app with Firebase Test Lab with ease using fastlane
174
+ test_files: []