From d76d35c730dee174919403edba47a3648eac4cf1 Mon Sep 17 00:00:00 2001 From: Stephen Coady Date: Aug 18 2020 11:56:05 +0000 Subject: add the ability to sync the nevr of both packages. the logic is: if the releases are not in sync then we use rpmdev-bumpspec to increase the version of both packages. this is the easiest way to make sure they both end up with the same release as the default behaviour when a release is bumped is to set version to 1. Signed-off-by: Stephen Coady --- diff --git a/monitor_gating/multi_builds.py b/monitor_gating/multi_builds.py index 9cbe830..bb1e306 100644 --- a/monitor_gating/multi_builds.py +++ b/monitor_gating/multi_builds.py @@ -82,15 +82,26 @@ def main(args, utils=None): # Bump the release on both packages: nevrs, side_tag_name = utils.clone_and_bump( - folder, nevrs, conf, conf["name_multi_1"], new_side_tag=True + folder, nevrs, conf, conf["name_multi_1"], version=0, new_side_tag=True ) # Store the side_tag_name so we can use it in the runner utils.side_tag_name = side_tag_name nevrs, _ = utils.clone_and_bump( - folder, nevrs, conf, conf["name_multi_2"], target=side_tag_name + folder, nevrs, conf, conf["name_multi_2"], version=0, target=side_tag_name ) + version, synced = utils.nevrs_synced(nevrs, conf) + + if not synced: + nevrs, side_tag_name = utils.clone_and_bump( + folder, nevrs, conf, conf["name_multi_1"], version=version, new_side_tag=True + ) + + nevrs, _ = utils.clone_and_bump( + folder, nevrs, conf, conf["name_multi_2"], version=version, target=side_tag_name + ) + # Chain-build the packages utils.chain_build_packages( conf["fedpkg"], diff --git a/monitor_gating/single_build.py b/monitor_gating/single_build.py index 94f3dbc..e7665d2 100644 --- a/monitor_gating/single_build.py +++ b/monitor_gating/single_build.py @@ -102,7 +102,7 @@ def main(args): ) gitfolder = os.path.join(folder, name) utils.switch_branch(conf["fedpkg"], branch, folder=gitfolder) - utils.bump_release(name, folder=gitfolder) + utils.bump_release(name, version=0, folder=gitfolder) utils.commit_changes("Bump release", folder=gitfolder) nevr = utils.get_nevr(conf["fedpkg"], folder=gitfolder) print(f" Upcoming build : {nevr}") diff --git a/monitor_gating/utils.py b/monitor_gating/utils.py index 68f6332..a02fe3c 100644 --- a/monitor_gating/utils.py +++ b/monitor_gating/utils.py @@ -11,6 +11,7 @@ import logging import os import subprocess import time +import re import requests @@ -159,14 +160,18 @@ class MonitoringUtils: self.failed.append("fedpkg") self.print_user(info_log, success=False) - def bump_release(self, name, folder): + def bump_release(self, name, version, folder): """ Bump the release of the spec file the specified git repo. """ info_log = f"Bumping release of: {name}.spec" self.print_user(info_log) try: - run_command(["rpmdev-bumpspec", f"{name}.spec"], cwd=folder) - self.print_user(info_log, success=True) + if version: + run_command(["rpmdev-bumpspec", f"{name}.spec", "-n", f"{version}"], cwd=folder) + self.print_user(info_log, success=True) + else: + run_command(["rpmdev-bumpspec", f"{name}.spec"], cwd=folder) + self.print_user(info_log, success=True) except MonitoringException: self.failed.append("rpmdev-bumspec") self.print_user(info_log, success=False) @@ -750,7 +755,7 @@ class MonitoringUtils: return side_tag_name def clone_and_bump( - self, folder, nevrs, conf, name, target=None, new_side_tag=False + self, folder, nevrs, conf, name, version, target=None, new_side_tag=False ): """Clone the repo, bump the release, commit and push.""" namespace = conf["namespace"] @@ -766,7 +771,11 @@ class MonitoringUtils: if new_side_tag: side_tag_name = self.create_side_tag(conf["fedpkg"], folder=gitfolder) target = side_tag_name - self.bump_release(name, folder=gitfolder) + if version: + version += version + self.bump_release(name, version, folder=gitfolder) + else: + self.bump_release(name, version=0, folder=gitfolder) self.commit_changes("Bump release", folder=gitfolder) nevr = self.get_nevr(conf["fedpkg"], folder=gitfolder) nevrs[name] = nevr @@ -775,6 +784,25 @@ class MonitoringUtils: print(f" Upcoming build : {nevr}") return (nevrs, target) + def nevrs_synced(self, nevrs, conf): + package_one = conf["name_multi_1"] + package_two = conf["name_multi_2"] + + nevr_one = nevrs[package_one] + nevr_two = nevrs[package_two] + + if nevr_one.startswith(package_one): + release_one = nevr_one[len(package_one):] + version = int(re.search(r'\d+', nevr_one).group()) + + if nevr_two.startswith(package_two): + release_two = nevr_one[len(package_two):] + + if release_one != release_two: + return version, False + + return version, True + def run_command(command, cwd=None): """ Run the specified command in a specific working directory if one