Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch_configs, launchers: add thunderbird-l10n support (bug 1760826) #1458

Merged
merged 1 commit into from
Sep 27, 2023
Merged
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
4 changes: 2 additions & 2 deletions gui/mozregui/build_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions gui/mozregui/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions mozregression/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
53 changes: 37 additions & 16 deletions mozregression/fetch_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
39 changes: 39 additions & 0 deletions tests/unit/test_fetch_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
TIMESTAMP_FENNEC_API_16,
FirefoxConfig,
FirefoxL10nConfig,
ThunderbirdL10nConfig,
create_config,
errors,
get_build_regex,
Expand Down Expand Up @@ -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):
Expand Down