diff --git a/gui/mozregui/build_runner.py b/gui/mozregui/build_runner.py index 1d9cc14e2..dbcf5935d 100644 --- a/gui/mozregui/build_runner.py +++ b/gui/mozregui/build_runner.py @@ -153,9 +153,9 @@ def init_worker(self, fetch_config, options): 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") diff --git a/gui/mozregui/wizard.py b/gui/mozregui/wizard.py index 704bd3d6e..a97ac56d0 100644 --- a/gui/mozregui/wizard.py +++ b/gui/mozregui/wizard.py @@ -148,8 +148,8 @@ def _set_fetch_config(self, index): 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) diff --git a/mozregression/cli.py b/mozregression/cli.py index 2c11216e0..070becab0 100644 --- a/mozregression/cli.py +++ b/mozregression/cli.py @@ -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 @@ def validate(self): 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) diff --git a/mozregression/fetch_configs.py b/mozregression/fetch_configs.py index f5dfe31af..7e1e50b83 100644 --- a/mozregression/fetch_configs.py +++ b/mozregression/fetch_configs.py @@ -360,6 +360,18 @@ def _get_nightly_repo(self, date): 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 @@ def build_regex(self): @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") diff --git a/tests/unit/test_fetch_configs.py b/tests/unit/test_fetch_configs.py index f13b53094..3a93b0628 100644 --- a/tests/unit/test_fetch_configs.py +++ b/tests/unit/test_fetch_configs.py @@ -13,6 +13,7 @@ TIMESTAMP_FENNEC_API_16, FirefoxConfig, FirefoxL10nConfig, + ThunderbirdL10nConfig, create_config, errors, get_build_regex, @@ -190,6 +191,44 @@ def test_nightly_repo_regex_before_2009_01_09(self): 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):