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 Fenix nightlies support (bug 1556042) #1451

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 4 additions & 0 deletions docs/_data/mozregression_supported_apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
- name: fennec
url: https://wiki.mozilla.org/Mobile/Fennec
description: Firefox for Android

- name: fenix
url: https://github.com/mozilla-mobile/firefox-android/blob/main/fenix/README.md
description: Firefox for Android
35 changes: 31 additions & 4 deletions mozregression/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,16 @@ def create_parser(defaults):

parser.add_argument(
"--arch",
choices=("arm", "x86_64", "aarch64"),
choices=(
"aarch64",
"arm",
"arm64-v8a",
"armeabi-v7a",
"x86",
"x86_64",
),
default=None,
help=("Force alternate build (only applies to GVE app). Default: arm"),
help=("Force alternate build (applies to GVE and Fenix)."),
)

parser.add_argument(
Expand Down Expand Up @@ -554,12 +561,32 @@ def validate(self):
"""
options = self.options

arch_options = {
"gve": [
"aarch64",
"arm",
"x86_64",
],
"fenix": [
"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 options.app != "gve":
self.logger.warning("--arch ignored for non-GVE app.")
if options.app not in ("gve", "fenix"):
self.logger.warning("--arch ignored for non Android apps.")
options.arch = None
else:
if 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])}."
)
zzzeid marked this conversation as resolved.
Show resolved Hide resolved

fetch_config = create_config(
options.app, mozinfo.os, options.bits, mozinfo.processor, options.arch
Expand Down
43 changes: 43 additions & 0 deletions mozregression/fetch_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,19 @@ def get_nightly_repo_regex(self, date):
return self._get_nightly_repo_regex(date, repo)


class FenixNightlyConfigMixin(NightlyConfigMixin):
nightly_base_repo_name = "fenix"
arch_regex_bits = ""

def _get_nightly_repo(self, date):
return "fenix"

def get_nightly_repo_regex(self, date):
repo = self.get_nightly_repo(date)
repo += self.arch_regex_bits # e.g., ".*arm64.*".
return self._get_nightly_repo_regex(date, repo)


class IntegrationConfigMixin(metaclass=ABCMeta):
"""
Define the integration-related required configuration.
Expand Down Expand Up @@ -607,6 +620,36 @@ def available_bits(self):
return ()


@REGISTRY.register("fenix")
class FenixConfig(CommonConfig, FenixNightlyConfigMixin):
def build_regex(self):
return r"fenix-.*\.apk"

def available_bits(self):
return ()

def available_archs(self):
return [
"arm64-v8a",
"armeabi-v7a",
"x86",
"x86_64",
]

def set_arch(self, arch):
CommonConfig.set_arch(self, arch)
mapping = {
zzzeid marked this conversation as resolved.
Show resolved Hide resolved
"arm64-v8a": "-.+-android-arm64-v8a",
"armeabi-v7a": "-.+-android-armeabi-v7a",
"x86": "-.+-android-x86",
"x86_64": "-.+-android-x86_64",
}
self.arch_regex_bits = mapping.get(self.arch, "")

def should_use_archive(self):
return True


@REGISTRY.register("gve")
class GeckoViewExampleConfig(CommonConfig, FennecNightlyConfigMixin, FennecIntegrationConfigMixin):
BUILD_TYPES = ("shippable", "opt", "debug")
Expand Down
37 changes: 36 additions & 1 deletion mozregression/launchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,31 @@ def _stop(self):
if self.adb.exists(self.remote_profile):
self.adb.rm(self.remote_profile, recursive=True)

def launch_browser(
self,
app_name,
activity,
intent="android.intent.action.VIEW",
moz_env=None,
url=None,
wait=True,
fail_if_running=True,
timeout=None,
):
extras = {}
extras["args"] = f"-profile {self.remote_profile}"

self.adb.launch_application(
app_name,
activity,
intent,
url=url,
extras=extras,
wait=wait,
fail_if_running=fail_if_running,
timeout=timeout,
)

def get_app_info(self):
return self.app_info

Expand All @@ -504,7 +529,17 @@ def _get_package_name(self):

def _launch(self):
LOG.debug("Launching fennec")
self.adb.launch_fennec(self.package_name, extra_args=["-profile", self.remote_profile])
self.launch_browser(self.package_name, "org.mozilla.gecko.BrowserApp")


@REGISTRY.register("fenix")
class FenixLauncher(AndroidLauncher):
def _get_package_name(self):
return "org.mozilla.fenix"

def _launch(self):
LOG.debug("Launching fenix")
self.launch_browser(self.package_name, ".IntentReceiverActivity")


@REGISTRY.register("gve")
Expand Down
60 changes: 35 additions & 25 deletions tests/unit/test_fetch_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,31 +190,41 @@ def test_nightly_repo_regex_before_2009_01_09(self):
TestThunderbirdConfig.test_nightly_repo_regex_before_2009_01_09(self)


class TestFennecConfig(unittest.TestCase):
def setUp(self):
self.conf = create_config("fennec", "linux", 64, None)

def test_get_nightly_repo_regex(self):
regex = self.conf.get_nightly_repo_regex(datetime.date(2014, 12, 5))
self.assertIn("mozilla-central-android", regex)
regex = self.conf.get_nightly_repo_regex(datetime.date(2014, 12, 10))
self.assertIn("mozilla-central-android-api-10", regex)
regex = self.conf.get_nightly_repo_regex(datetime.date(2015, 1, 1))
self.assertIn("mozilla-central-android-api-11", regex)
regex = self.conf.get_nightly_repo_regex(datetime.date(2016, 1, 28))
self.assertIn("mozilla-central-android-api-11", regex)
regex = self.conf.get_nightly_repo_regex(datetime.date(2016, 1, 29))
self.assertIn("mozilla-central-android-api-15", regex)
regex = self.conf.get_nightly_repo_regex(datetime.date(2017, 8, 30))
self.assertIn("mozilla-central-android-api-16", regex)

def test_build_regex(self):
regex = re.compile(self.conf.build_regex())
self.assertTrue(regex.match("fennec-36.0a1.multi.android-arm.apk"))

def test_build_info_regex(self):
regex = re.compile(self.conf.build_info_regex())
self.assertTrue(regex.match("fennec-36.0a1.multi.android-arm.txt"))
@pytest.mark.parametrize("app_name", ["fennec", "fenix"])
class TestExtendedAndroidConfig:
def test_get_nightly_repo_regex(self, app_name):
if app_name == "fennec":
conf = create_config("fennec", "linux", 64, None)
regex = conf.get_nightly_repo_regex(datetime.date(2014, 12, 5))
assert "mozilla-central-android" in regex
regex = conf.get_nightly_repo_regex(datetime.date(2014, 12, 10))
assert "mozilla-central-android-api-10" in regex
regex = conf.get_nightly_repo_regex(datetime.date(2015, 1, 1))
assert "mozilla-central-android-api-11" in regex
regex = conf.get_nightly_repo_regex(datetime.date(2016, 1, 28))
assert "mozilla-central-android-api-11" in regex
regex = conf.get_nightly_repo_regex(datetime.date(2016, 1, 29))
assert "mozilla-central-android-api-15" in regex
regex = conf.get_nightly_repo_regex(datetime.date(2017, 8, 30))
assert "mozilla-central-android-api-16" in regex
else:
conf = create_config(app_name, "linux", 64, None)
date = datetime.date(2023, 1, 1)
regex = conf.get_nightly_repo_regex(date)
assert regex == f"/{date.isoformat()}-[\\d-]+{app_name}/$"

def test_build_regex(self, app_name):
conf = create_config(app_name, "linux", 64, None)
regex = re.compile(conf.build_regex())
assert bool(regex.match(f"{app_name}-110.0b1.multi.android-arm64-v8a.apk")) is True
zzzeid marked this conversation as resolved.
Show resolved Hide resolved

def test_build_info_regex(self, app_name):
if app_name != "fennec":
# This test is currently only applicable to Fennec.
return
conf = create_config(app_name, "linux", 64, None)
regex = re.compile(conf.build_info_regex())
assert bool(regex.match(f"{app_name}-36.0a1.multi.android-arm.txt")) is True


class TestGVEConfig(unittest.TestCase):
Expand Down
Loading
Loading