Skip to content

Commit

Permalink
able to using components channel
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabeef committed Jan 14, 2020
1 parent 71c5693 commit 5f0ccf6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 31 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -60,7 +60,7 @@ fastlane add_plugin firebase_test_lab_android
Using [gcloud tool](https://cloud.google.com/sdk/gcloud/), you can run.

```
gcloud beta firebase test android models list
gcloud firebase test android models list
```

to get a list of supported devices and their identifiers.
Expand All @@ -87,6 +87,8 @@ lane :test do
firebase_test_lab_android(
project_id: "cats-firebase", # Your Firebase project name.
gcloud_service_key_file: "fastlane/client-secret.json", # File path containing the gcloud auth key.
# gcloud_components_channel: "beta", # If you use gcloud component channel option (alpha/beta).
console_log_file_name: "fastlane/console_output.log",
type: "robo", # Optional: Test type (robo/instrumentation).
devices: [ # Devices
{
Expand All @@ -103,8 +105,6 @@ lane :test do
app_apk: "app-debug.apk", # The path for your android app apk.
# app_test_apk: "app-test.apk", # The path for your android instrumentation test apk.
# use_orchestrator: false, # If you use orchestrator when set instrumentation test.
# use_beta_option: false, # If you use beta option when set instrumentation test.
console_log_file_name: "fastlane/console_output.log",
timeout: "3m",
firebase_test_lab_results_bucket: "firebase_cats_test_bucket", # If you want to naming bucket of GCS
# firebase_test_lab_results_dir: "firebase_cats_test_dir", # If you want to naming results of GCS. (Maybe don't need it.)
Expand Down
32 changes: 15 additions & 17 deletions fastlane/Fastfile
@@ -1,21 +1,18 @@
before_all do
ENV["SLACK_URL"] = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX"
ENV["SLACK_URL"] = "https://hooks.slack.com/services/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"
end

lane :test do

# Get Pull Request number
pr_number = ENV["CI_PULL_REQUEST"] != nil ? ENV["CI_PULL_REQUEST"][/(?<=https:\/\/github.com\/cats-oss\/android\/pull\/)(.*)/] : nil

# Upload to Firebase Test Lab
# upload to Firebase Test Lab
firebase_test_lab_android(
project_id: "cats-firebase",
project_id: "cats-234205",
gcloud_service_key_file: "fastlane/client-secret.json",
type: "robo",
gcloud_components_channel: "alpha",
type: "instrumentation",
devices: [
{
model: "Nexus6P",
version: "23",
model: "NexusLowRes",
version: "27",
locale: "ja_JP",
orientation: "portrait"
},
Expand All @@ -24,15 +21,16 @@ lane :test do
version: "28"
}
],
app_apk: "test.apk",
console_log_file_name: "fastlane/console_output.log",
timeout: "60s",
firebase_test_lab_results_bucket: "firebase-test-lab-result-bucket",
app_apk: "~/Desktop/i-app.apk" ,
app_test_apk: "~/Desktop/i-androidTest.apk",
console_log_file_name: "log/console_output.log",
timeout: "3m",
firebase_test_lab_results_bucket: "firebase_cats_test_bucket_pr8",
slack_url: ENV["SLACK_URL"],
download_dir: ".results",
github_owner: "cats-oss",
github_repository: "fastlane-plugin-firebase_test_lab_android",
github_pr_number: pr_number,
github_api_token: ENV["DANGER_GITHUB_API_TOKEN"],
download_dir: ".results"
github_pr_number: "8",
github_api_token: "fd4e560da02c76f53e15ce26eb73a94181de54bc"
)
end
Expand Up @@ -17,7 +17,7 @@ def self.run(params)
# Activate service account
Helper.authenticate(params[:gcloud_service_key_file])
# Run Firebase Test Lab
Helper.run_tests(params[:use_beta_option] ,"--type #{params[:type]} "\
Helper.run_tests(params[:gcloud_components_channel], "--type #{params[:type]} "\
"--app #{params[:app_apk]} "\
"#{"--test #{params[:app_test_apk]} " unless params[:app_test_apk].nil?}"\
"#{"--use-orchestrator " if params[:type] == "instrumentation" && params[:use_orchestrator]}"\
Expand Down Expand Up @@ -113,7 +113,12 @@ def self.available_options
description: "Test type. Default: robo (robo/instrumentation)",
is_string: true,
optional: true,
default_value: "robo"),
default_value: "robo",
verify_block: proc do |value|
if value != "robo" && value != "instrumentation"
UI.user_error!("Unknown test type.")
end
end),
FastlaneCore::ConfigItem.new(key: :devices,
description: "Devices to test the app on",
type: Array,
Expand Down Expand Up @@ -157,16 +162,21 @@ def self.available_options
default_value: nil),
FastlaneCore::ConfigItem.new(key: :use_orchestrator,
env_name: "USE_ORCHESTRATOR",
description: "If you use orchestrator when set instrumentation test . Default: false",
description: "If you use orchestrator when set instrumentation test. Default: false",
type: Boolean,
optional: true,
default_value: false),
FastlaneCore::ConfigItem.new(key: :use_beta_option,
env_name: "USE_BETA_OPTION",
description: "If you use beta option when set instrumentation test . Default: false",
type: Boolean,
FastlaneCore::ConfigItem.new(key: :gcloud_components_channel,
env_name: "gcloud_components_channel",
description: "If you use beta or alpha components. Default: robo (alpha/beta)",
is_string: true,
optional: true,
default_value: false),
default_value: "",
verify_block: proc do |value|
if value != "" && value != "alpha" && value != "beta"
UI.user_error!("Unknown gcloud component channel.")
end
end),
FastlaneCore::ConfigItem.new(key: :console_log_file_name,
env_name: "CONSOLE_LOG_FILE_NAME",
description: "The filename to save the output results. Default: ./console_output.log",
Expand Down
Expand Up @@ -32,9 +32,9 @@ def self.authenticate(gcloud_key_file)
Action.sh("gcloud auth activate-service-account --key-file #{gcloud_key_file}")
end

def self.run_tests(use_beta_option, arguments)
def self.run_tests(gcloud_components_channel, arguments)
UI.message("Test running...")
Action.sh("set +e; gcloud #{use_beta_option ? "beta " : ""}firebase test android run #{arguments}; set -e")
Action.sh("set +e; gcloud #{gcloud_components_channel} firebase test android run #{arguments}; set -e")
end

def self.copy_from_gcs(bucket_and_path, copy_to)
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/firebase_test_lab_android/version.rb
@@ -1,5 +1,5 @@
module Fastlane
module FirebaseTestLabAndroid
VERSION = "1.0.0"
VERSION = "1.1.0"
end
end

0 comments on commit 5f0ccf6

Please sign in to comment.