Skip to content

Commit

Permalink
fix(build_rc): Enable compatibility with agent6 (#32100)
Browse files Browse the repository at this point in the history
  • Loading branch information
chouetz authored Dec 16, 2024
1 parent 53eec23 commit 5b903ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 41 deletions.
7 changes: 6 additions & 1 deletion tasks/libs/common/gomodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,13 @@ def tag(self, agent_version):
>>> [mod.tag("7.27.0") for mod in mods]
[["7.27.0"], ["pkg/util/log/v0.27.0"]]
"""
from invoke import Context

from tasks.libs.common.git import is_agent6

major = "6" if is_agent6(Context()) else "7"
if self.path == ".":
return ["7" + agent_version[1:]]
return [major + agent_version[1:]]

return [f"{self.path}/{self.__version(agent_version)}"]

Expand Down
43 changes: 3 additions & 40 deletions tasks/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
# Tasks to trigger pipelines


def check_deploy_pipeline(repo: Project, git_ref: str, release_version_6, release_version_7, repo_branch):
def check_deploy_pipeline(repo_branch):
"""
Run checks to verify a deploy pipeline is valid:
- it targets a valid repo branch
- it has matching Agent 6 and Agent 7 tags (depending on release_version_* values)
Run checks to verify a deploy pipeline is valid (it targets a valid repo branch)
"""

# Check that the target repo branch is valid
Expand All @@ -57,41 +55,6 @@ def check_deploy_pipeline(repo: Project, git_ref: str, release_version_6, releas
)
raise Exit(code=1)

#
# If git_ref matches v7 pattern and release_version_6 is not empty, make sure Gitlab has v6 tag.
# If git_ref matches v6 pattern and release_version_7 is not empty, make sure Gitlab has v7 tag.
# v7 version pattern should be able to match 7.12.24-rc2 and 7.12.34
#
v7_pattern = r'^7\.(\d+\.\d+)(-.+|)$'
v6_pattern = r'^6\.(\d+\.\d+)(-.+|)$'

match = re.match(v7_pattern, git_ref)

# TODO(@spencergilbert): remove cross reference check when all references to a6 are removed
if release_version_6 and match:
# release_version_6 is not empty and git_ref matches v7 pattern, construct v6 tag and check.
tag_name = "6." + "".join(match.groups())
try:
repo.tags.get(tag_name)
except GitlabError:
print(f"Cannot find GitLab v6 tag {tag_name} while trying to build git ref {git_ref}")
print("v6 tags are no longer created, this check will be removed in a later commit")

print(f"Successfully cross checked v6 tag {tag_name} and git ref {git_ref}")
else:
match = re.match(v6_pattern, git_ref)

if release_version_7 and match:
# release_version_7 is not empty and git_ref matches v6 pattern, construct v7 tag and check.
tag_name = "7." + "".join(match.groups())
try:
repo.tags.get(tag_name)
except GitlabError as e:
print(f"Cannot find GitLab v7 tag {tag_name} while trying to build git ref {git_ref}")
raise Exit(code=1) from e

print(f"Successfully cross checked v7 tag {tag_name} and git ref {git_ref}")


@task
def clean_running_pipelines(ctx, git_ref=None, here=False, use_latest_sha=False, sha=None):
Expand Down Expand Up @@ -292,7 +255,7 @@ def run(

if deploy or deploy_installer:
# Check the validity of the deploy pipeline
check_deploy_pipeline(repo, git_ref, release_version_6, release_version_7, repo_branch)
check_deploy_pipeline(repo_branch)
# Force all builds and e2e tests to be run
if not all_builds:
print(
Expand Down

0 comments on commit 5b903ef

Please sign in to comment.