Skip to content

Commit

Permalink
Improve logic of finding legacy branches to ignore manifest update (#…
Browse files Browse the repository at this point in the history
…4871)

Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon authored Jul 19, 2024
1 parent 049851d commit cbbf84a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/manifests_workflow/input_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,23 @@ def update(
with TemporaryDirectory(keep=keep, chdir=True) as work_dir:
logging.info(f"Checking out components into {work_dir.name}")

outdated_branches = ["1.0", "1.1", "1.2"]
# ignore branches that are legacy/outdated and not maintained anymore
# get possible legacy branches based on legacy manifests, then cross check with current branches from current manifests
# ex: 1.0 failed due to certain dependencies not available anymore: https://github.com/avast/gradle-docker-compose-plugin/issues/446
all_manifests = set(InputManifests.files(self.prefix))
legacy_manifests = {m for m in all_manifests if "legacy-manifests" in m}
legacy_branches = {".".join(m.split(os.sep)[-2].rsplit(".", 1)[:-1]) for m in legacy_manifests}
current_manifests = all_manifests - legacy_manifests
current_branches = {".".join(m.split(os.sep)[-2].rsplit(".", 1)[:-1]) for m in current_manifests}

# make sure only branches in legacy-manifests but not in manifests get ignored
legacy_branches -= current_branches

# check out and build #main, 1.x, etc.
# ignore branches that are outdated and not maintained anymore
# ex: 1.0 failed due to certain dependencies not available anymore: https://github.com/avast/gradle-docker-compose-plugin/issues/446
all_branches = sorted(min_klass.branches())
branches = [b for b in all_branches if not any(b.startswith(o) for o in outdated_branches)]
logging.info(f"Checking {self.name} {branches} branches")
logging.info(f"Ignoring {self.name} {sorted(set(all_branches) - set(branches))} branches as they are outdated")
branches = [b for b in all_branches if not any(b == o or b.startswith((f"{o}-", f"{o}/")) for o in legacy_branches)]
logging.info(f"Checking {self.name} {sorted(branches)} branches")
logging.info(f"Ignoring {self.name} {sorted(set(all_branches) - set(branches))} branches as they are legacy")

for branch in branches:
min_component_klass = min_klass.checkout(
Expand Down

0 comments on commit cbbf84a

Please sign in to comment.