fetch_configs, launchers: add thunderbird-l10n support (bug 1760826) (#1458)
- add support for thunderbird-l10n - limit date range to when builds became available - add tests - move common functionality to `L10nMixin`
This commit is contained in:
Родитель
3193ec655c
Коммит
e9c693cbdc
|
@ -153,9 +153,9 @@ class AbstractBuildRunner(QObject):
|
|||
if options.get("url") and fetch_config.app_name != "thunderbird":
|
||||
launcher_kwargs["cmdargs"] += [options["url"]]
|
||||
|
||||
# Lang only works for firefox-l10n
|
||||
# Lang only works for firefox-l10n and thunderbird-l10n.
|
||||
if options.get("lang"):
|
||||
if options["application"] == "firefox-l10n":
|
||||
if options["application"] in ("firefox-l10n", "thunderbird-l10n"):
|
||||
fetch_config.set_lang(options["lang"])
|
||||
else:
|
||||
raise MozRegressionError("Invalid lang argument")
|
||||
|
|
|
@ -148,8 +148,8 @@ class IntroPage(WizardPage):
|
|||
self.ui.url.setEnabled(True)
|
||||
self.ui.url_label.setEnabled(True)
|
||||
|
||||
# lang only makes sense for firefox-l10n, and repo doesn't
|
||||
if app_name == "firefox-l10n":
|
||||
# lang only makes sense for firefox-l10n and thunderbird-l10n, and repo doesn't
|
||||
if app_name in ("firefox-l10n", "thunderbird-l10n"):
|
||||
self.ui.lang.setEnabled(True)
|
||||
self.ui.lang_label.setEnabled(True)
|
||||
self.ui.repository.setDisabled(True)
|
||||
|
|
|
@ -253,7 +253,7 @@ def create_parser(defaults):
|
|||
parser.add_argument(
|
||||
"--lang",
|
||||
metavar="[ar|es-ES|he|ja|zh-CN|...]",
|
||||
help=("build language. Only valid when app is firefox-l10n."),
|
||||
help=("build language. Only valid when app is firefox-l10n or thunderbird-l10n."),
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
|
@ -597,11 +597,13 @@ class Configuration(object):
|
|||
options.app, mozinfo.os, options.bits, mozinfo.processor, options.arch
|
||||
)
|
||||
if options.lang:
|
||||
if options.app != "firefox-l10n":
|
||||
raise MozRegressionError("--lang is only valid with --app=firefox-l10n")
|
||||
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 == "firefox-l10n":
|
||||
raise MozRegressionError("app 'firefox-l10n' requires a --lang argument")
|
||||
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)
|
||||
|
|
|
@ -360,6 +360,18 @@ class ThunderbirdNightlyConfigMixin(NightlyConfigMixin):
|
|||
return "comm-central"
|
||||
|
||||
|
||||
class ThunderbirdL10nNightlyConfigMixin(ThunderbirdNightlyConfigMixin):
|
||||
has_build_info = False
|
||||
oldest_builds = datetime.date(2015, 10, 8)
|
||||
|
||||
def _get_nightly_repo(self, date):
|
||||
if date < self.oldest_builds:
|
||||
raise errors.MozRegressionError(
|
||||
"thunderbird-l10n builds not available before {}".format(self.oldest_builds)
|
||||
)
|
||||
return "comm-central-l10n"
|
||||
|
||||
|
||||
class FennecNightlyConfigMixin(NightlyConfigMixin):
|
||||
nightly_base_repo_name = "mobile"
|
||||
|
||||
|
@ -551,6 +563,24 @@ def create_config(name, os, bits, processor, arch=None):
|
|||
return REGISTRY.get(name)(os, bits, processor, arch)
|
||||
|
||||
|
||||
class L10nMixin:
|
||||
def set_lang(self, lang):
|
||||
LOG.info("setting lang to {}".format(lang))
|
||||
self.lang = lang
|
||||
|
||||
def build_regex(self):
|
||||
return (
|
||||
get_build_regex(
|
||||
self.app_name,
|
||||
self.os,
|
||||
self.bits,
|
||||
self.processor,
|
||||
platprefix=r".*\." + self.lang + r"\.",
|
||||
)
|
||||
+ "$"
|
||||
)
|
||||
|
||||
|
||||
@REGISTRY.register("firefox")
|
||||
class FirefoxConfig(CommonConfig, FirefoxNightlyConfigMixin, FirefoxIntegrationConfigMixin):
|
||||
BUILD_TYPES = (
|
||||
|
@ -584,22 +614,8 @@ class FirefoxConfig(CommonConfig, FirefoxNightlyConfigMixin, FirefoxIntegrationC
|
|||
|
||||
|
||||
@REGISTRY.register("firefox-l10n", attr_value="firefox")
|
||||
class FirefoxL10nConfig(CommonConfig, FirefoxL10nNightlyConfigMixin):
|
||||
def set_lang(self, lang):
|
||||
LOG.info("setting lang to {}".format(lang))
|
||||
self.lang = lang
|
||||
|
||||
def build_regex(self):
|
||||
return (
|
||||
get_build_regex(
|
||||
self.app_name,
|
||||
self.os,
|
||||
self.bits,
|
||||
self.processor,
|
||||
platprefix=r".*\." + self.lang + r"\.",
|
||||
)
|
||||
+ "$"
|
||||
)
|
||||
class FirefoxL10nConfig(CommonConfig, FirefoxL10nNightlyConfigMixin, L10nMixin):
|
||||
pass
|
||||
|
||||
|
||||
@REGISTRY.register("thunderbird")
|
||||
|
@ -609,6 +625,11 @@ class ThunderbirdConfig(
|
|||
pass
|
||||
|
||||
|
||||
@REGISTRY.register("thunderbird-l10n", attr_value="thunderbird")
|
||||
class ThunderbirdL10nConfig(L10nMixin, CommonConfig, ThunderbirdL10nNightlyConfigMixin):
|
||||
pass
|
||||
|
||||
|
||||
@REGISTRY.register("fennec")
|
||||
class FennecConfig(CommonConfig, FennecNightlyConfigMixin, FennecIntegrationConfigMixin):
|
||||
BUILD_TYPES = ("shippable", "opt", "pgo", "debug")
|
||||
|
|
|
@ -13,6 +13,7 @@ from mozregression.fetch_configs import (
|
|||
TIMESTAMP_FENNEC_API_16,
|
||||
FirefoxConfig,
|
||||
FirefoxL10nConfig,
|
||||
ThunderbirdL10nConfig,
|
||||
create_config,
|
||||
errors,
|
||||
get_build_regex,
|
||||
|
@ -190,6 +191,44 @@ class TestThunderbirdConfigWin(TestThunderbirdConfig):
|
|||
TestThunderbirdConfig.test_nightly_repo_regex_before_2009_01_09(self)
|
||||
|
||||
|
||||
class TestThunderbirdl10nConfig(unittest.TestCase):
|
||||
app_name = "thunderbird-l10n"
|
||||
os = "linux"
|
||||
bits = 64
|
||||
processor = "x86_64"
|
||||
lang = "ar"
|
||||
|
||||
instance_type = ThunderbirdL10nConfig
|
||||
|
||||
build_examples = ["thunderbird-110.0a1.ar.linux-x86_64.tar.bz2"]
|
||||
build_info_examples = ["thunderbird-110.0a1.en-US.linux-x86_64.txt"]
|
||||
|
||||
def setUp(self):
|
||||
self.conf = create_config(self.app_name, self.os, self.bits, self.processor)
|
||||
self.conf.set_lang(self.lang)
|
||||
|
||||
def test_instance(self):
|
||||
self.assertIsInstance(self.conf, self.instance_type)
|
||||
|
||||
def test_build_regex(self):
|
||||
for example in self.build_examples:
|
||||
res = re.match(self.conf.build_regex(), example)
|
||||
self.assertIsNotNone(res)
|
||||
|
||||
def test_build_info_regex(self):
|
||||
for example in self.build_info_examples:
|
||||
res = re.match(self.conf.build_info_regex(), example)
|
||||
self.assertIsNotNone(res)
|
||||
|
||||
def test_nightly_repo_regex(self):
|
||||
repo_regex = self.conf.get_nightly_repo_regex(datetime.date(2023, 1, 1))
|
||||
self.assertEqual(repo_regex, "/2023-01-01-[\\d-]+comm-central-l10n/$")
|
||||
|
||||
def test_nightly_repo_regex_before_2015_10_08(self):
|
||||
with self.assertRaises(errors.MozRegressionError):
|
||||
self.conf.get_nightly_repo_regex(datetime.date(2015, 1, 1))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("app_name", ["fennec", "fenix", "focus"])
|
||||
class TestExtendedAndroidConfig:
|
||||
def test_get_nightly_repo_regex(self, app_name):
|
||||
|
|
Загрузка…
Ссылка в новой задаче