Skip to content

Commit e8eb4fb

Browse files
committed
koji: Add supported git branches (eg: [8.3, master] for v8.3-* tags)
make `koji_build` accept builds for v8.3 and from both `master` and `8.3` Preparation for switch `master` to be "next" aka v9 To my understanding, the motivation of change is part of a bigger plan, to prepare a smooth transition to enable bleeding edge development on master branch. Of course maintenance will remain in v8.x branches. Once the master branch needs to be stabilized then a new 9.0 branch can be open (this mean declared in PROTECTED_TARGETS, and also move the `master` branch from `8.3` target to `9.0` for a future cycle) Meanwhile the development on master is still open and might become the base for the next cycle (TBD 9.1 or 10). Note that `8.3` git branches are not created yet in repos, it would make sense to open them soon or later, ideally when master branches need to receive feature from next release. Coincidentaly thoses 8.3 branches will be used for maintenance of the LTS release and then developers/RE might consider back-porting fixes from master to 8.3. What is unclear to me in the plan is when the new koji target/tag v9 will be defined, or if an `unstable` target will be added before, probably this will have to be coordinated with CI. Signed-off-by: Philippe Coval <philippe.coval@vates.tech>
1 parent 3ed14a3 commit e8eb4fb

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

scripts/koji/koji_build.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
TIME_FORMAT = '%Y-%m-%d-%H-%M-%S'
1818

19-
# target -> required branch
19+
# target -> supported branch(es)
2020
PROTECTED_TARGETS = {
21-
"v8.2-ci": "8.2",
22-
"v8.2-fasttrack": "8.2",
23-
"v8.2-incoming": "8.2",
24-
"v8.3-ci": "master",
25-
"v8.3-fasttrack": "master",
26-
"v8.3-incoming": "master",
21+
"v8.2-ci": ["8.2"],
22+
"v8.2-fasttrack": ["8.2"],
23+
"v8.2-incoming": ["8.2"],
24+
"v8.3-ci": ["master", "8.3"],
25+
"v8.3-fasttrack": ["master", "8.3"],
26+
"v8.3-incoming": [ "master", "8.3"]
2727
}
2828

2929
@contextmanager
@@ -53,13 +53,17 @@ def check_commit_is_available_remotely(dirpath, hash, target, warn):
5353
if target is not None and re.match(r'v\d+\.\d+-u-.+', target):
5454
raise Exception("Building with a user target requires using --pre-build or --test-build.\n")
5555
try:
56-
expected_branch = PROTECTED_TARGETS.get(target)
57-
if (
58-
expected_branch is not None
59-
and not is_remote_branch_commit(dirpath, hash, expected_branch)
60-
):
61-
raise Exception(f"The current commit is not the last commit in the remote branch {expected_branch}.\n"
62-
f"This is required when using the protected target {target}.\n")
56+
available = False
57+
supported_branches = PROTECTED_TARGETS.get(target)
58+
if supported_branches:
59+
for branch in supported_branches:
60+
available = is_remote_branch_commit(dirpath, hash, branch)
61+
if available:
62+
logging.info(f"commit {hash} is on top of branch {branch} (target: {target})")
63+
break
64+
if not available:
65+
raise Exception(f"The current commit is not the last commit of any remote branches {supported_branches}.\n"
66+
f"This is required when using the protected target {target}.\n")
6367
except Exception as e:
6468
if warn:
6569
print(f"warning: {e}", flush=True)
@@ -153,9 +157,8 @@ def push_bumped_release(git_repo, target, test_build_id, pre_build_id):
153157

154158
def is_remote_branch_commit(git_repo, sha, branch):
155159
with cd(git_repo):
156-
remote_sha = (
157-
subprocess.check_output(['git', 'ls-remote', 'origin', f'refs/heads/{branch}']).decode().strip().split()[0]
158-
)
160+
list = subprocess.check_output(['git', 'ls-remote', 'origin', f'refs/heads/{branch}']).decode().strip().split()
161+
remote_sha = list[0] if list else None
159162
return sha == remote_sha
160163

161164
def build_id_of(name, candidate):

0 commit comments

Comments
 (0)