fastlane-plugin-wpmreleasetoolkit 4.1.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_preflight.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_xml_release_notes.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb +187 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/{android_hotifx_prechecks.rb → android_hotfix_prechecks.rb} +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_send_app_size_metrics.rb +279 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_release_notes.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_trigger_build_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_for_toolkit_updates_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/firebase_login.rb +44 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_list_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb +1 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/removebranchprotection_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setbranchprotection_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setfrozentag_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_apply_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_download_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_preflight.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_clear_intermediate_tags.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_completecodefreeze_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_current_branch_is_hotfix.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_final_tag.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_store_app_sizes.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/{ios_hotifx_prechecks.rb → ios_hotfix_prechecks.rb} +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb +45 -6
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_merge_strings_files.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_send_app_size_metrics.rb +170 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_release_notes.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb +6 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/app_size_metrics_helper.rb +95 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_helper.rb +7 -3
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb +4 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/user_agent.rb +5 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_account.rb +19 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb +62 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_test_lab_result.rb +36 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_test_runner.rb +104 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit.rb +2 -2
- metadata +121 -83
@@ -0,0 +1,62 @@
|
|
1
|
+
module Fastlane
|
2
|
+
class FirebaseDevice
|
3
|
+
attr_reader :model, :version, :locale, :orientation
|
4
|
+
|
5
|
+
def initialize(model:, version:, orientation:, locale: 'en')
|
6
|
+
raise 'Invalid Model' unless FirebaseDevice.valid_model_names.include? model
|
7
|
+
raise 'Invalid Version' unless FirebaseDevice.valid_version_numbers.include? version
|
8
|
+
raise 'Invalid Locale' unless FirebaseDevice.valid_locales.include? locale
|
9
|
+
raise 'Invalid Orientation' unless FirebaseDevice.valid_orientations.include? orientation
|
10
|
+
|
11
|
+
@model = model
|
12
|
+
@version = version
|
13
|
+
@locale = locale
|
14
|
+
@orientation = orientation
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"model=#{@model},version=#{@version},locale=#{@locale},orientation=#{@orientation}"
|
19
|
+
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
@locale_data = nil
|
23
|
+
@model_data = nil
|
24
|
+
@version_data = nil
|
25
|
+
|
26
|
+
def valid_model_names
|
27
|
+
JSON.parse(model_data).map { |device| device['codename'] }
|
28
|
+
end
|
29
|
+
|
30
|
+
def valid_version_numbers
|
31
|
+
JSON.parse(version_data).map { |version| version['apiLevel'].to_i }
|
32
|
+
end
|
33
|
+
|
34
|
+
def valid_locales
|
35
|
+
JSON.parse(locale_data).map { |locale| locale['id'] }
|
36
|
+
end
|
37
|
+
|
38
|
+
def valid_orientations
|
39
|
+
%w[portrait landscape]
|
40
|
+
end
|
41
|
+
|
42
|
+
def locale_data
|
43
|
+
FirebaseDevice.verify_logged_in!
|
44
|
+
@locale_data ||= Fastlane::Actions.sh('gcloud', 'firebase', 'test', 'android', 'locales', 'list', '--format="json"', log: false)
|
45
|
+
end
|
46
|
+
|
47
|
+
def model_data
|
48
|
+
FirebaseDevice.verify_logged_in!
|
49
|
+
@model_data ||= Fastlane::Actions.sh('gcloud', 'firebase', 'test', 'android', 'models', 'list', '--format="json"', log: false)
|
50
|
+
end
|
51
|
+
|
52
|
+
def version_data
|
53
|
+
FirebaseDevice.verify_logged_in!
|
54
|
+
@version_data ||= Fastlane::Actions.sh('gcloud', 'firebase', 'test', 'android', 'versions', 'list', '--format="json"', log: false)
|
55
|
+
end
|
56
|
+
|
57
|
+
def verify_logged_in!
|
58
|
+
UI.user_error!('You must call `firebase_login` before creating a FirebaseDevice object') unless FirebaseAccount.authenticated?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fastlane
|
2
|
+
class FirebaseTestLabResult
|
3
|
+
def initialize(log_file_path:)
|
4
|
+
raise "No log file found at path #{log_file_path}" unless File.file? log_file_path
|
5
|
+
|
6
|
+
@path = log_file_path
|
7
|
+
end
|
8
|
+
|
9
|
+
# Scan the log file to for indications that no test cases failed
|
10
|
+
def success?
|
11
|
+
File.readlines(@path).any? { |line| line.include?('Passed') && line.include?('test cases passed') }
|
12
|
+
end
|
13
|
+
|
14
|
+
# Parse the log for the "More details are available..." URL
|
15
|
+
def more_details_url
|
16
|
+
File.readlines(@path)
|
17
|
+
.flat_map { |line| URI.extract(line) }
|
18
|
+
.find { |url| URI(url).host == 'console.firebase.google.com' && url.include?('/matrices/') }
|
19
|
+
end
|
20
|
+
|
21
|
+
# Parse the log for the Google Cloud Storage Bucket URL
|
22
|
+
def raw_results_paths
|
23
|
+
uri = File.readlines(@path)
|
24
|
+
.flat_map { |line| URI.extract(line) }
|
25
|
+
.map { |string| URI(string) }
|
26
|
+
.find { |u| u.scheme == 'gs' }
|
27
|
+
|
28
|
+
return nil if uri.nil?
|
29
|
+
|
30
|
+
return {
|
31
|
+
bucket: uri.host,
|
32
|
+
prefix: uri.path.delete_prefix('/').chomp('/')
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'uri'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'google/cloud/storage'
|
5
|
+
|
6
|
+
module Fastlane
|
7
|
+
class FirebaseTestRunner
|
8
|
+
VALID_TEST_TYPES = %w[instrumentation robo].freeze
|
9
|
+
|
10
|
+
def self.preflight(verify_gcloud_binary: true, verify_logged_in: true)
|
11
|
+
verify_has_gcloud_binary! if verify_gcloud_binary
|
12
|
+
verify_logged_in! if verify_logged_in
|
13
|
+
end
|
14
|
+
|
15
|
+
# Run a given APK and Test Bundle on the given device type.
|
16
|
+
#
|
17
|
+
# @param [String] project_id The Google Firebase Console Project ID.
|
18
|
+
# @param [String] apk_path Path to the application APK on disk.
|
19
|
+
# @param [String] test_apk_path Path to the test runner APK on disk.
|
20
|
+
# @param [FirebaseDevice] device The virtual device to run tests on.
|
21
|
+
# @param [String] type The type of test to run.
|
22
|
+
#
|
23
|
+
def self.run_tests(project_id:, apk_path:, test_apk_path:, device:, type: 'instrumentation')
|
24
|
+
raise "Unable to find apk: #{apk_path}" unless File.file?(apk_path)
|
25
|
+
raise "Unable to find apk: #{test_apk_path}" unless File.file?(test_apk_path)
|
26
|
+
raise "Invalid Type: #{type}" unless VALID_TEST_TYPES.include?(type)
|
27
|
+
|
28
|
+
command = Shellwords.join [
|
29
|
+
'gcloud', 'firebase', 'test', 'android', 'run',
|
30
|
+
'--project', project_id,
|
31
|
+
'--type', type,
|
32
|
+
'--app', apk_path,
|
33
|
+
'--test', test_apk_path,
|
34
|
+
'--device', device.to_s,
|
35
|
+
'--verbosity', 'info',
|
36
|
+
]
|
37
|
+
|
38
|
+
log_file_path = Fastlane::Actions.lane_context[:FIREBASE_TEST_LOG_FILE_PATH]
|
39
|
+
|
40
|
+
UI.message "Streaming log output to #{log_file_path}"
|
41
|
+
Action.sh("#{command} 2>&1 | tee #{log_file_path}")
|
42
|
+
|
43
|
+
# Make the file object available to other tasks
|
44
|
+
result = FirebaseTestLabResult.new(log_file_path: log_file_path)
|
45
|
+
Fastlane::Actions.lane_context[:FIREBASE_TEST_LOG_FILE] = result
|
46
|
+
|
47
|
+
result
|
48
|
+
end
|
49
|
+
|
50
|
+
# Downloads all files associated with a Firebase Test Run to the local machine.
|
51
|
+
#
|
52
|
+
# @param [FirebaseTestLabResult] result The result bundle for a given test run.
|
53
|
+
# @param [String] destination The local directory to store all downloaded files.
|
54
|
+
# @param [String] project_id The Google Cloud Project ID – required for Google Cloud Storage access.
|
55
|
+
# @param [String] key_file_path The path to the key file – required for Google Cloud Storage access.
|
56
|
+
#
|
57
|
+
def self.download_result_files(result:, destination:, project_id:, key_file_path:)
|
58
|
+
UI.user_error! 'You must pass a `FirebaseTestLabResult` to this method' unless result.is_a? Fastlane::FirebaseTestLabResult
|
59
|
+
|
60
|
+
paths = result.raw_results_paths
|
61
|
+
UI.user_error! "Log File doesn't contain a raw results URL" if paths.nil?
|
62
|
+
|
63
|
+
FileUtils.mkdir_p(destination) unless File.directory?(destination)
|
64
|
+
|
65
|
+
storage = Google::Cloud::Storage.new(
|
66
|
+
project_id: project_id,
|
67
|
+
credentials: key_file_path
|
68
|
+
)
|
69
|
+
|
70
|
+
# Set up the download
|
71
|
+
bucket = storage.bucket(paths[:bucket])
|
72
|
+
files_to_download = bucket.files(prefix: paths[:prefix])
|
73
|
+
|
74
|
+
# Download the files
|
75
|
+
UI.header "Downloading Results Files to #{destination}"
|
76
|
+
files_to_download.each { |file| download_file(file: file, destination: destination) }
|
77
|
+
end
|
78
|
+
|
79
|
+
# Download a Google Cloud Storage file to the local machine, creating intermediate directories as needed.
|
80
|
+
#
|
81
|
+
# @param [Google::Cloud::Storage::File] file Usually provided via `bucket.files`.
|
82
|
+
# @param [String] destination The local directory to store the file. It will retain its original name.
|
83
|
+
#
|
84
|
+
def self.download_file(file:, destination:)
|
85
|
+
destination = File.join(destination, file.name)
|
86
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
87
|
+
|
88
|
+
# Print our progress
|
89
|
+
UI.message(file.name)
|
90
|
+
|
91
|
+
file.download(destination)
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.verify_has_gcloud_binary!
|
95
|
+
Action.sh('command', '-v', 'gcloud', print_command: false, print_command_output: false)
|
96
|
+
rescue StandardError
|
97
|
+
UI.user_error!("The `gcloud` binary isn't available on this machine. Unable to continue.")
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.verify_logged_in!
|
101
|
+
UI.user_error!('You are not logged into Firebase on this machine. Unable to continue.') unless FirebaseAccount.authenticated?
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -2,9 +2,9 @@ require 'fastlane/plugin/wpmreleasetoolkit/version'
|
|
2
2
|
|
3
3
|
module Fastlane
|
4
4
|
module Wpmreleasetoolkit
|
5
|
-
# Return all .rb files inside the "actions" and "
|
5
|
+
# Return all .rb files inside the "actions", "helper" and "models" directories
|
6
6
|
def self.all_classes
|
7
|
-
Dir[File.expand_path('**/{actions,helper}/**/*.rb', File.dirname(__FILE__))]
|
7
|
+
Dir[File.expand_path('**/{actions,helper,models}/**/*.rb', File.dirname(__FILE__))]
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|