Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ run_tests_firebase_testlab(
<td>true</td>
</tr>

<tr>
<td>download_file_list</td>
<td>A list of files that should be downloaded from the bucket or not, seperated by space. This is a additional parameter for 'download_results_from_firebase'</td>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo: "a additional parameter" to "an additional parameter"

<td>Yes</td>
<td>empty string</td>
</tr>

</tbody>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class RunTestsFirebaseTestlabAction < Action
PIPE = "testlab-pipe"
@client_secret_file = "client-secret.json"
@test_console_output_file = "instrumentation_output.txt"
@test_console_folderlist_output_file = "folderlist.txt"

class << self
attr_reader :client_secret_file, :test_console_output_file
Expand Down Expand Up @@ -32,6 +33,7 @@ def self.run(params)
UI.message("Running instrumentation tests in Firebase Test Lab...")
remove_pipe_if_exists
Action.sh("mkfifo #{PIPE}")

begin
Action.sh("tee #{@test_console_output_file} < #{PIPE} & "\
"#{Commands.run_tests} "\
Expand All @@ -54,8 +56,35 @@ def self.run(params)
end

if params[:download_results_from_firebase]
UI.message("Downloading instrumentation test results from Firebase Test Lab...")
Action.sh("#{Commands.download_results} #{params[:bucket_url]} #{params[:output_dir]}")
if params[:download_file_list] && !params[:download_file_list].empty?
UI.message("Get files at bucket...")

params[:download_results_from_firebase] = false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?


Action.sh("#{Commands.list_object} "\
"#{params[:bucket_url]} "\
"| grep -e '/$' > #{@test_console_folderlist_output_file}")

bucket_path = params[:bucket_url].delete_prefix("gs://")

device_folders = []
File.open(@test_console_folderlist_output_file).each do |line|
folder = line.match(%r{#{bucket_path}/(.*)/$}).captures.first
device_folders.push(folder)
end

defined_download_files = params[:download_file_list].split(" ")

device_folders.each do |devicefolder|
defined_download_files.each do |filename|
UI.message("Download file '#{filename}' from '#{devicefolder}' to '#{params[:output_dir]}/#{devicefolder}/#{filename}'...")
Action.sh("#{Commands.download_single_file} #{params[:bucket_url]}/#{devicefolder}/#{filename} #{params[:output_dir]}/#{devicefolder}/#{filename}")
end
end
else
UI.message("Downloading instrumentation test results from Firebase Test Lab...")
Action.sh("#{Commands.download_results} #{params[:bucket_url]} #{params[:output_dir]}")
end
end

if params[:delete_firebase_files]
Expand Down Expand Up @@ -190,7 +219,13 @@ def self.available_options
description: "A flag to control if the firebase files should be downloaded from the bucket or not. Default: true",
is_string: false,
optional: true,
default_value: true)
default_value: true),
FastlaneCore::ConfigItem.new(key: :download_file_list,
env_name: "DOWNLOAD_FILE_LIST",
description: "A list of files that should be downloaded from the bucket or not, seperated by space. This is a additional parameter for 'download_results_from_firebase'. Default: empty string",
is_string: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to be a string? If this parameter is a list, it is probably better to use an Array. Can we change this?

optional: true,
default_value: "")
]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ def self.download_results
"gsutil -m cp -r"
end

def self.download_single_file
"gsutil -m cp"
end

def self.list_object
"gsutil ls"
end

def self.delete_resuls
"gsutil rm -r"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/run_tests_firebase_testlab/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module RunTestsFirebaseTestlab
VERSION = "0.3.1"
VERSION = "0.4.0"
end
end