Skip to content

Commit

Permalink
WIP Early Firefox Snap Usptream builds on TC usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Lissy committed Sep 11, 2023
1 parent 53e4eaa commit b03c395
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
61 changes: 61 additions & 0 deletions mozregression/fetch_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,3 +674,64 @@ def build_regex(self):
part = "mac"
psuffix = "-asan" if "asan" in self.build_type else ""
return r"jsshell-%s%s\.zip$" % (part, psuffix)


"""
archive.mozilla.org only?
"""
class FirefoxSnapNightlyConfigMixin(NightlyConfigMixin):
nightly_base_repo_name = "mobile"

def _get_nightly_repo(self, date):
return "mozilla-central"

def get_nightly_repo_regex(self, date):
repo = self.get_nightly_repo(date)
if repo in ("mozilla-central",):
if date < datetime.date(2014, 12, 6):
repo += "-android"
elif date < datetime.date(2014, 12, 13):
repo += "-android-api-10"
elif date < datetime.date(2016, 1, 29):
repo += "-android-api-11"
elif date < datetime.date(2017, 8, 30):
repo += "-android-api-15"
else:
repo += "-android-api-16"
return self._get_nightly_repo_regex(date, repo)


class FirefoxSnapIntegrationConfigMixin(IntegrationConfigMixin):
def tk_routes(self, push):
for build_type in self.build_types:
yield "gecko.v2.{}.revision.{}.firefox.{}".format(
self.integration_branch,
push.changeset,
"nightly",
"opt" if build_type == "shippable" else build_type,
)
self._inc_used_build()
return


class SnapCommonConfig(CommonConfig):
def should_use_archive(self):
"""
We only want to use TaskCluster builds
"""
return False

def build_regex(self):
return r"(firefox_.*)\.snap"

@REGISTRY.register("firefox-snap")
class FirefoxSnapConfig(SnapCommonConfig, FirefoxSnapNightlyConfigMixin, FirefoxSnapIntegrationConfigMixin):
BUILD_TYPES = ("shippable", "opt", "debug")
BUILD_TYPE_FALLBACKS = {
"shippable": ("opt",),
"opt": ("shippable",),
}

def __init__(self, os, bits, processor, arch):
super(FirefoxSnapConfig, self).__init__(os, bits, processor, arch)
self.set_build_type("shippable")
56 changes: 56 additions & 0 deletions mozregression/launchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import os
import stat
import subprocess
import sys
import time
import zipfile
Expand Down Expand Up @@ -560,3 +561,58 @@ def cleanup(self):
# always remove tempdir
if self.tempdir is not None:
remove(self.tempdir)


@REGISTRY.register("firefox-snap")
class FirefoxSnapLauncher(MozRunnerLauncher):
profile_class = FirefoxRegressionProfile
_id = None

def _install(self, dest):
# somehow, an id length above 10 triggers magic and fails with:
# error: invalid instance key: "bb7f7e75755a"
self._id = os.path.basename(dest)[0:9]
subprocess.run(["snap", "install", "--name", "firefox_{}".format(self._id), "--dangerous", "{}".format(dest)], check=True)

# self.binarydir = os.path.dirname(self.binary)
# self.appdir = os.path.normpath(os.path.join(self.binarydir, "..", ".."))

# self._disableUpdateByPolicy()

def _disableUpdateByPolicy(self):
updatePolicy = {"policies": {"DisableAppUpdate": True}}
installdir = os.path.dirname(self.binary)
os.makedirs(os.path.join(installdir, "distribution"))
policyFile = os.path.join(installdir, "distribution", "policies.json")
with open(policyFile, "w") as fp:
json.dump(updatePolicy, fp, indent=2)

def _start(
self,
profile=None,
addons=(),
cmdargs=(),
preferences=None,
adb_profile_dir=None,
):
profile = self._create_profile(profile=profile, addons=addons, preferences=preferences)

LOG.info("Launching %s" % self.binary)
# self.runner = Runner(binary=self.binary, cmdargs=cmdargs, profile=profile)
subprocess.run(["snap", "run", "firefox_{}".format(self._id)])

def _wait(self):
return True # self.runner.wait()

def _stop(self):
pass
# self.runner.stop()
# release the runner since it holds a profile reference
# del self.runner

def cleanup(self):
try:
Launcher.cleanup(self)
finally:
subprocess.run(["snap", "remove", "firefox_{}".format(self._id)])

0 comments on commit b03c395

Please sign in to comment.