in mozregression/cli.py [0:0]
def validate(self):
"""
Validate the options, define the `action` and `fetch_config` that
should be used to run the application.
"""
options = self.options
arch_options = {
"firefox": [
"aarch64",
"x86",
"x86_64",
],
"firefox-l10n": [
"aarch64",
"x86",
"x86_64",
],
"gve": [
"aarch64",
"arm",
"x86_64",
],
"fenix": [
"arm64-v8a",
"armeabi-v7a",
"x86",
"x86_64",
],
"focus": [
"arm64-v8a",
"armeabi-v7a",
"x86",
"x86_64",
],
}
user_defined_bits = options.bits is not None
options.bits = parse_bits(options.bits or mozinfo.bits)
if options.arch is not None:
if user_defined_bits:
self.logger.warning(
"--arch and --bits are passed together. --arch will be preferred."
)
if options.app not in arch_options:
self.logger.warning(f"--arch ignored for {options.app}.")
options.arch = None
elif options.app in ("firefox", "firefox-l10n") and mozinfo.os == "mac":
self.logger.warning(
"--arch ignored for Firefox for macOS as it uses unified binary."
)
options.arch = None
elif options.arch not in arch_options[options.app]:
raise MozRegressionError(
f"Invalid arch ({options.arch}) specified for app ({options.app}). "
f"Valid options are: {', '.join(arch_options[options.app])}."
)
elif options.app in ("fenix", "focus"):
raise MozRegressionError(
f"`--arch` required for specified app ({options.app}). "
f"Please specify one of {', '.join(arch_options[options.app])}."
)
fetch_config = create_config(
options.app, mozinfo.os, options.bits, mozinfo.processor, options.arch
)
if options.lang:
if options.app not in ("firefox-l10n", "thunderbird-l10n"):
raise MozRegressionError(
"--lang is only valid with --app=firefox-l10n|thunderbird-l10n"
)
fetch_config.set_lang(options.lang)
elif options.app in ("firefox-l10n", "thunderbird-l10n"):
raise MozRegressionError(f"app {options.app} requires a --lang argument")
if options.build_type:
try:
fetch_config.set_build_type(options.build_type)
except MozRegressionError as msg:
self.logger.warning("%s (Defaulting to %r)" % (msg, fetch_config.build_type))
self.fetch_config = fetch_config
fetch_config.set_repo(options.repo)
fetch_config.set_base_url(options.archive_base_url)
if (
not user_defined_bits
and options.bits == 64
and mozinfo.os == "win"
and 32 in fetch_config.available_bits()
):
# inform users on windows that we are using 64 bit builds.
self.logger.info("bits option not specified, using 64-bit builds.")
if options.bits == 32 and mozinfo.os == "mac":
self.logger.info("only 64-bit builds available for mac, using 64-bit builds.")
if fetch_config.is_integration() and fetch_config.tk_needs_auth():
creds = tc_authenticate(self.logger)
fetch_config.set_tk_credentials(creds)
# set action for just use changset or data to bisect
if options.launch:
options.launch = self._convert_to_bisect_arg(options.launch)
self.action = "launch_integration"
if is_date_or_datetime(options.launch) and fetch_config.should_use_archive():
self.action = "launch_nightlies"
else:
# define good/bad default values if required
default_good_date, default_bad_date = get_default_date_range(fetch_config)
if options.find_fix:
default_bad_date, default_good_date = (
default_good_date,
default_bad_date,
)
if not options.bad:
options.bad = default_bad_date
self.logger.info("No 'bad' option specified, using %s" % options.bad)
else:
options.bad = self._convert_to_bisect_arg(options.bad)
if not options.good:
options.good = default_good_date
self.logger.info("No 'good' option specified, using %s" % options.good)
else:
options.good = self._convert_to_bisect_arg(options.good)
self.action = "bisect_integration"
if is_date_or_datetime(options.good) and is_date_or_datetime(options.bad):
if not options.find_fix and to_datetime(options.good) > to_datetime(options.bad):
raise MozRegressionError(
(
"Good date %s is later than bad date %s."
" Maybe you wanted to use the --find-fix"
" flag?"
)
% (options.good, options.bad)
)
elif options.find_fix and to_datetime(options.good) < to_datetime(options.bad):
raise MozRegressionError(
(
"Bad date %s is later than good date %s."
" You should not use the --find-fix flag"
" in this case..."
)
% (options.bad, options.good)
)
if fetch_config.should_use_archive():
self.action = "bisect_nightlies"
if (
self.action in ("launch_integration", "bisect_integration")
and not fetch_config.is_integration()
):
raise MozRegressionError(
"Unable to bisect integration for `%s`" % fetch_config.app_name
)
options.preferences = preferences(options.prefs_files, options.prefs, self.logger)
# convert GiB to bytes.
options.persist_size_limit = int(abs(float(options.persist_size_limit)) * 1073741824)