Skip to content

Commit b89c008

Browse files
author
Alexandre Lissy
committed
Bug 1763188 - Add Snap support using TC builds
1 parent bf5a7c2 commit b89c008

File tree

10 files changed

+481
-20
lines changed

10 files changed

+481
-20
lines changed

mozregression/bisector.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def finished(self):
145145
def user_exit(self, mid):
146146
pass
147147

148+
def record_build_info(self, repo, changeset, cron_changeset):
149+
pass
150+
148151

149152
class NightlyHandler(BisectorHandler):
150153
create_range = staticmethod(get_nightly_range)
@@ -351,6 +354,21 @@ def handle_merge(self):
351354
return result
352355

353356

357+
"""
358+
We are just using this to make it clear we have no merge to take care of
359+
We are running an Integration because builds are triggered from cron jobs
360+
on mozilla-central for all Snap package branches
361+
"""
362+
363+
364+
class SnapHandler(IntegrationHandler):
365+
def __init__(self, **kwargs):
366+
super(IntegrationHandler, self).__init__(**kwargs)
367+
368+
def handle_merge(self):
369+
return None
370+
371+
354372
class IndexPromise(object):
355373
"""
356374
A promise to get a build index.

mozregression/branches.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ def create_branches():
7878
):
7979
for alias in aliases:
8080
branches.set_alias(alias, name)
81+
82+
branches.set_branch("snap-nightly", "mozilla-central")
83+
branches.set_branch("snap-beta", "mozilla-central")
84+
branches.set_branch("snap-stable", "mozilla-central")
85+
branches.set_branch("snap-esr", "mozilla-central")
86+
8187
return branches
8288

8389

mozregression/cli.py

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,21 @@ def create_parser(defaults):
417417
help="Helps to write the configuration file.",
418418
)
419419

420+
parser.add_argument(
421+
"--allow-sudo",
422+
action="store_true",
423+
help=(
424+
"[Snap] Allow the use of sudo for Snap install/remove operations (otherwise,"
425+
" you will be prompted on each)"
426+
),
427+
)
428+
429+
parser.add_argument(
430+
"--disable-snap-connect",
431+
action="store_true",
432+
help="[Snap] Do not automatically perform 'snap connect'",
433+
)
434+
420435
parser.add_argument("--debug", "-d", action="store_true", help="Show the debug output.")
421436

422437
return parser
@@ -579,14 +594,19 @@ def validate(self):
579594
"x86",
580595
"x86_64",
581596
],
597+
"firefox-snap": [
598+
"aarch64", # will be morphed into arm64
599+
"arm", # will be morphed into armf
600+
"x86_64", # will be morphed into amd64
601+
],
582602
}
583603

584604
user_defined_bits = options.bits is not None
585605
options.bits = parse_bits(options.bits or mozinfo.bits)
586606

587607
if options.arch is not None:
588-
if options.app not in ("gve", "fenix", "focus"):
589-
self.logger.warning("--arch ignored for non Android apps.")
608+
if options.app not in ("gve", "fenix", "focus", "firefox-snap"):
609+
self.logger.warning("--arch ignored for non Android apps or Snap package.")
590610
options.arch = None
591611
elif options.arch not in arch_options[options.app]:
592612
raise MozRegressionError(
@@ -598,6 +618,29 @@ def validate(self):
598618
f"`--arch` required for specified app ({options.app}). "
599619
f"Please specify one of {', '.join(arch_options[options.app])}."
600620
)
621+
elif options.app == "firefox-snap" and options.allow_sudo is False:
622+
self.logger.warning(
623+
"Bisection on Snap package without --allow-sudo, you will be prompted for"
624+
" credential on each 'snap' command."
625+
)
626+
elif options.allow_sudo is True and options.app != "firefox-snap":
627+
raise MozRegressionError(
628+
f"--allow-sudo specified for app ({options.app}), but only valid for "
629+
f"firefox-snap. Please verify your config."
630+
)
631+
elif options.disable_snap_connect is True and options.app != "firefox-snap":
632+
raise MozRegressionError(
633+
f"--disable-snap-conncet specified for app ({options.app}), but only valid for "
634+
f"firefox-snap. Please verify your config."
635+
)
636+
637+
if options.app == "firefox-snap" and (
638+
options.repo is None or not options.repo.startswith("snap-")
639+
):
640+
raise MozRegressionError(
641+
f"--repo not specified for app ({options.app}), or not starting with snap-. "
642+
f"Please use correct repo for bisecting Snap package."
643+
)
601644

602645
fetch_config = create_config(
603646
options.app, mozinfo.os, options.bits, mozinfo.processor, options.arch

mozregression/fetch_configs.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,3 +752,99 @@ def build_regex(self):
752752
part = "mac"
753753
psuffix = "-asan" if "asan" in self.build_type else ""
754754
return r"jsshell-%s%s\.zip$" % (part, psuffix)
755+
756+
757+
TIMESTAMP_SNAP_UPSTREAM_BUILD = to_utc_timestamp(datetime.datetime(2023, 7, 26, 9, 39, 21))
758+
TIMESTAMP_SNAP_INDEX_RENAME = to_utc_timestamp(datetime.datetime(2023, 11, 17, 21, 46, 39))
759+
# This needs to be updated when we land cross-compilation on treeherder
760+
TIMESTAMP_SNAP_CROSS_COMPILATION = to_utc_timestamp(datetime.datetime(2023, 11, 21, 15, 15, 00))
761+
762+
763+
class FirefoxSnapNightlyConfigMixin(NightlyConfigMixin):
764+
def _get_nightly_repo(self, date):
765+
return "mozilla-central"
766+
767+
768+
class FirefoxSnapIntegrationConfigMixin(IntegrationConfigMixin):
769+
def _idx_key(self, date):
770+
branch_name = ""
771+
772+
if self.integration_branch == "snap-nightly":
773+
branch_name = "nightly"
774+
elif self.integration_branch == "snap-beta":
775+
branch_name = "beta"
776+
elif self.integration_branch == "snap-stable":
777+
branch_name = "stable"
778+
elif self.integration_branch == "snap-esr":
779+
branch_name = "esr"
780+
else:
781+
raise errors.MozRegressionError(
782+
"No such branch available, valid are nightly/beta/stable/esr"
783+
" (prefix with snap- for --repo)"
784+
)
785+
786+
if date < TIMESTAMP_SNAP_UPSTREAM_BUILD:
787+
raise errors.MozRegressionError("No build before this date")
788+
elif date >= TIMESTAMP_SNAP_UPSTREAM_BUILD and date < TIMESTAMP_SNAP_INDEX_RENAME:
789+
index_base = ""
790+
elif date >= TIMESTAMP_SNAP_INDEX_RENAME:
791+
index_base = "{}-".format(self.arch)
792+
793+
if self.arch != "amd64" and date < TIMESTAMP_SNAP_CROSS_COMPILATION:
794+
raise errors.MozRegressionError(f"No support for build other than amd64 ({self.arch})")
795+
796+
return "{}{}".format(index_base, branch_name)
797+
798+
def tk_routes(self, push):
799+
for build_type in self.build_types:
800+
name = "gecko.v2.mozilla-central.revision.{}.firefox.{}{}".format(
801+
push.changeset,
802+
self._idx_key(push.timestamp),
803+
"-{}".format(build_type)
804+
if build_type != "opt" and build_type != "shippable"
805+
else "",
806+
)
807+
yield name
808+
self._inc_used_build()
809+
return
810+
811+
812+
class SnapCommonConfig(CommonConfig):
813+
def should_use_archive(self):
814+
"""
815+
We only want to use TaskCluster builds
816+
"""
817+
return False
818+
819+
def build_regex(self):
820+
return r"(firefox_.*)\.snap"
821+
822+
823+
@REGISTRY.register("firefox-snap")
824+
class FirefoxSnapConfig(
825+
SnapCommonConfig, FirefoxSnapIntegrationConfigMixin, FirefoxSnapNightlyConfigMixin
826+
):
827+
BUILD_TYPES = ("shippable", "opt", "debug")
828+
BUILD_TYPE_FALLBACKS = {
829+
"shippable": ("opt",),
830+
"opt": ("shippable",),
831+
}
832+
833+
def __init__(self, os, bits, processor, arch):
834+
super(FirefoxSnapConfig, self).__init__(os, bits, processor, arch)
835+
self.set_build_type("shippable")
836+
837+
def available_archs(self):
838+
return [
839+
"aarch64",
840+
"arm",
841+
"x86_64",
842+
]
843+
844+
def set_arch(self, arch):
845+
mapping = {
846+
"aarch64": "arm64",
847+
"arm": "armhf",
848+
"x86_64": "amd64",
849+
}
850+
self.arch = mapping.get(arch, "amd64")

0 commit comments

Comments
 (0)