From 82883b13945b3fdbcbc82c723451785778ac666a Mon Sep 17 00:00:00 2001 From: Stephen Coady Date: Aug 12 2020 14:42:31 +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 cef5dcd..c215ea1 100644 --- a/monitor_gating_multi_builds.py +++ b/monitor_gating_multi_builds.py @@ -81,12 +81,23 @@ def main(args): # 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 ) 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 c5dcea1..790563c 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/utils.py b/utils.py index 265b2e2..78a495a 100644 --- a/utils.py +++ b/utils.py @@ -11,6 +11,7 @@ import logging import os import subprocess import time +import re import requests @@ -116,14 +117,18 @@ class MonitoringUtils: except MonitoringException: 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.print_user(info_log, success=False) @@ -687,7 +692,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"] @@ -703,7 +708,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 @@ -712,6 +721,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