def _get_update_paths(self): from mozrelease.l10n import getPlatformLocales from mozrelease.paths import getCandidatesDir from mozrelease.platforms import ftp2infoFile from mozrelease.versions import MozillaVersion self.update_paths = {} ret = self._retry_download( "{}/1.0/{}.json".format( self.config["product_details_server"], self.config["stage_product"], ), "WARNING", ) releases = json.load(ret)["releases"] for release_name, release_info in reversed(sorted(releases.items())): product, version = release_name.split("-", 1) tag = "{}_{}_RELEASE".format(product.upper(), version.replace(".", "_")) # Product details has a "category" for releases that we can use to # determine the repo path. This will fail if any previous releases # were built from a project branch - but that's not something we do # at the time of writing. branch = None if release_info["category"] == "dev": branch = "releases/{}-beta".format(self.config['branch_prefix']) elif release_info["category"] == "esr": branch = "releases/{}-esr{}".format(self.config['branch_prefix'], version[:2]) elif release_info["category"] in ("major", "stability"): branch = "releases/{}-release".format(self.config['branch_prefix']) if not branch: raise Exception("Cannot determine branch, cannot continue!") # Exclude any releases that don't match one of our include version # regexes. This is generally to avoid including versions from other # channels. Eg: including betas when testing releases for v in self.config["include_versions"]: if re.match(v, version): break else: self.log("Skipping release whose version doesn't match any " "include_version pattern: %s" % release_name, level=INFO) continue # We also have to trim out previous releases that aren't in the same # product line, too old, etc. if self.config["stage_product"] != product: self.log("Skipping release that doesn't match product name: %s" % release_name, level=INFO) continue if MozillaVersion(version) < MozillaVersion(self.config["last_watershed"]): self.log("Skipping release that's behind the last watershed: %s" % release_name, level=INFO) continue if version == self.config["to_version"]: self.log("Skipping release that is the same as to version: %s" % release_name, level=INFO) continue if MozillaVersion(version) > MozillaVersion(self.config["to_version"]): self.log("Skipping release that's newer than to version: %s" % release_name, level=INFO) continue if version in self.update_paths: raise Exception("Found duplicate release for version: %s", version) # This is a crappy place to get buildids from, but we don't have a better one. # This will start to fail if old info files are deleted. info_file_url = "{}{}/{}_info.txt".format( self.config["previous_archive_prefix"], getCandidatesDir( self.config["stage_product"], version, release_info["build_number"], ), ftp2infoFile(self.config["platform"]) ) self.log("Retrieving buildid from info file: %s" % info_file_url, level=DEBUG) ret = self._retry_download(info_file_url, "WARNING") buildID = ret.read().split("=")[1].strip() shipped_locales_url = urljoin( self.config["hg_server"], "{}/raw-file/{}/{}/locales/shipped-locales".format( branch, tag, self.config["app_name"], ), ) ret = self._retry_download(shipped_locales_url, "WARNING") shipped_locales = ret.read().strip() app_version_url = urljoin( self.config["hg_server"], "{}/raw-file/{}/{}/config/version.txt".format( branch, tag, self.config["app_name"], ), ) app_version = self._retry_download(app_version_url, "WARNING").read().strip() self.log("Adding {} to update paths".format(version), level=INFO) self.update_paths[version] = { "appVersion": app_version, "locales": getPlatformLocales(shipped_locales, self.config["platform"]), "buildID": buildID, } for pattern, mar_channel_ids in self.config["mar_channel_id_overrides"].items(): if re.match(pattern, version): self.update_paths[version]["marChannelIds"] = mar_channel_ids
def _get_update_paths(self): from mozrelease.l10n import getPlatformLocales from mozrelease.paths import getCandidatesDir from mozrelease.platforms import ftp2infoFile from mozrelease.versions import MozillaVersion self.update_paths = {} ret = self._retry_download( "{}/1.0/{}.json".format( self.config["product_details_server"], self.config["stage_product"], ), "WARNING", ) releases = json.load(ret)["releases"] for release_name, release_info in \ reversed(sorted(releases.items(), key=lambda x: MozillaVersion(x[1]['version']))): # we need to use releases_name instead of release_info since esr # string is included in the name. later we rely on this. product, version = release_name.split('-', 1) tag = "{}_{}_RELEASE".format(product.upper(), version.replace(".", "_")) # Exclude any releases that don't match one of our include version # regexes. This is generally to avoid including versions from other # channels. Eg: including betas when testing releases for v in self.config["include_versions"]: if re.match(v, version): break else: self.log("Skipping release whose version doesn't match any " "include_version pattern: %s" % release_name, level=INFO) continue # We also have to trim out previous releases that aren't in the same # product line, too old, etc. if self.config["stage_product"] != product: self.log( "Skipping release that doesn't match product name: %s" % release_name, level=INFO) continue if MozillaVersion(version) < MozillaVersion( self.config["last_watershed"]): self.log( "Skipping release that's behind the last watershed: %s" % release_name, level=INFO) continue if version == self.config["to_version"]: self.log( "Skipping release that is the same as to version: %s" % release_name, level=INFO) continue if MozillaVersion(version) > MozillaVersion( self.config["to_version"]): self.log("Skipping release that's newer than to version: %s" % release_name, level=INFO) continue if version in self.update_paths: raise Exception("Found duplicate release for version: %s", version) # This is a crappy place to get buildids from, but we don't have a better one. # This will start to fail if old info files are deleted. info_file_url = "{}{}/{}_info.txt".format( self.config["previous_archive_prefix"], getCandidatesDir( self.config["stage_product"], version, release_info["build_number"], ), ftp2infoFile(self.config["platform"])) self.log("Retrieving buildid from info file: %s" % info_file_url, level=DEBUG) ret = self._retry_download(info_file_url, "WARNING") buildID = ret.read().split(b"=")[1].strip().decode("utf-8") branch = self._get_branch_url(self.config["branch_prefix"], version) shipped_locales_url = urljoin( self.config["hg_server"], "{}/raw-file/{}/{}/locales/shipped-locales".format( branch, tag, self.config["app_name"], ), ) ret = self._retry_download(shipped_locales_url, "WARNING") shipped_locales = ret.read().strip().decode("utf-8") app_version_url = urljoin( self.config["hg_server"], "{}/raw-file/{}/{}/config/version.txt".format( branch, tag, self.config["app_name"], ), ) app_version = self._retry_download(app_version_url, "WARNING").read() \ .strip().decode("utf-8") self.log("Adding {} to update paths".format(version), level=INFO) self.update_paths[version] = { "appVersion": app_version, "locales": getPlatformLocales(shipped_locales, self.config["platform"]), "buildID": buildID, } for pattern, mar_channel_ids in self.config[ "mar_channel_id_overrides"].items(): if re.match(pattern, version): self.update_paths[version][ "marChannelIds"] = mar_channel_ids
def test_versions_compare_greater(comparable_versions): """Test that versions properly compare in order.""" smaller_version, larger_version = comparable_versions assert MozillaVersion(larger_version) > MozillaVersion(smaller_version)
def test_versions_compare_equal(version): """Test that versions properly compare as equal through multiple passes.""" assert MozillaVersion(version) == MozillaVersion(version)
def test_versions_parseable(version): """Test that we can parse previously shipped versions. We only test 3.0 and up, since we never generate updates against versions that old.""" assert MozillaVersion(version) is not None