-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f392387
commit fb0c103
Showing
3 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
from time import sleep | ||
|
||
from gitlab import GitlabError | ||
from invoke import task | ||
from invoke import Failure, task | ||
from invoke.exceptions import Exit | ||
|
||
from tasks.libs.ciproviders.github_api import GithubAPI, create_release_pr | ||
|
@@ -66,6 +66,7 @@ | |
) | ||
from tasks.libs.releasing.notes import _add_dca_prelude, _add_prelude | ||
from tasks.libs.releasing.version import ( | ||
FINAL_VERSION_RE, | ||
MINOR_RC_VERSION_RE, | ||
RC_VERSION_RE, | ||
VERSION_RE, | ||
|
@@ -86,6 +87,7 @@ | |
|
||
BACKPORT_LABEL_COLOR = "5319e7" | ||
TAG_BATCH_SIZE = 3 | ||
QUALIFICATION_TAG = "qualification" | ||
|
||
|
||
@task | ||
|
@@ -149,10 +151,11 @@ def __get_force_option(force: bool) -> str: | |
return force_option | ||
|
||
|
||
def __tag_single_module(ctx, module, agent_version, commit, force_option, devel): | ||
def __tag_single_module(ctx, module, tag_name, commit, force_option, devel): | ||
"""Tag a given module.""" | ||
tags = [] | ||
for tag in module.tag(agent_version): | ||
tags_to_commit = module.tag(tag_name) if VERSION_RE.match(tag_name) else [tag_name] | ||
for tag in tags_to_commit: | ||
if devel: | ||
tag += "-devel" | ||
|
||
|
@@ -211,7 +214,15 @@ def tag_modules( | |
|
||
@task | ||
def tag_version( | ||
ctx, release_branch=None, commit="HEAD", push=True, force=False, devel=False, version=None, trust=False | ||
ctx, | ||
release_branch=None, | ||
commit="HEAD", | ||
push=True, | ||
force=False, | ||
devel=False, | ||
version=None, | ||
trust=False, | ||
start_qual=False, | ||
): | ||
"""Create tags for a given Datadog Agent version. | ||
|
@@ -221,6 +232,7 @@ def tag_version( | |
push: Will push the tags to the origin remote (on by default). | ||
force: Will allow the task to overwrite existing tags. Needed to move existing tags (off by default). | ||
devel: Will create -devel tags (used after creation of the release branch) | ||
start_qual: Will start the qualification phase for agent 6 release candidate by adding a qualification tag | ||
Examples: | ||
$ inv -e release.tag-version 7.27.x # Create tags and push them to origin | ||
|
@@ -237,6 +249,16 @@ def tag_version( | |
with agent_context(ctx, release_branch, skip_checkout=release_branch is None): | ||
tags = __tag_single_module(ctx, get_default_modules()["."], agent_version, commit, force_option, devel) | ||
|
||
# create or update the qualification tag using the force option (points tag to next RC) | ||
if is_agent6(ctx) and (start_qual or is_qualification(ctx)): | ||
if FINAL_VERSION_RE.match(agent_version): | ||
ctx.run(f"git push --delete origin {QUALIFICATION_TAG}") | ||
else: | ||
force_option = __get_force_option(not start_qual) | ||
tags += __tag_single_module( | ||
ctx, get_default_modules()["."], QUALIFICATION_TAG, commit, force_option, False | ||
) | ||
|
||
if push: | ||
tags_list = ' '.join(tags) | ||
ctx.run(f"git push origin {tags_list}{force_option}") | ||
|
@@ -490,7 +512,20 @@ def create_rc(ctx, release_branch, patch_version=False, upstream="origin", slack | |
|
||
|
||
@task | ||
def build_rc(ctx, release_branch, patch_version=False, k8s_deployments=False): | ||
def is_qualification(ctx, output=False): | ||
try: | ||
ctx.run(f"git tag | grep {QUALIFICATION_TAG}", hide=True) | ||
if output: | ||
print('true') | ||
return True | ||
except Failure: | ||
if output: | ||
print("false") | ||
return False | ||
|
||
|
||
@task | ||
def build_rc(ctx, release_branch, patch_version=False, k8s_deployments=False, start_qual=False): | ||
"""To be done after the PR created by release.create-rc is merged, with the same options | ||
as release.create-rc. | ||
|
@@ -499,6 +534,7 @@ def build_rc(ctx, release_branch, patch_version=False, k8s_deployments=False): | |
Args: | ||
k8s_deployments: When set to True the child pipeline deploying to subset of k8s staging clusters will be triggered. | ||
start_qual: Start the qualification phase for agent 6 release candidates. | ||
""" | ||
|
||
major_version = get_version_major(release_branch) | ||
|
@@ -548,7 +584,7 @@ def build_rc(ctx, release_branch, patch_version=False, k8s_deployments=False): | |
# tag_version only takes the highest version (Agent 7 currently), and creates | ||
# the tags for all supported versions | ||
# TODO: make it possible to do Agent 6-only or Agent 7-only tags? | ||
tag_version(ctx, version=str(new_version), force=False) | ||
tag_version(ctx, version=str(new_version), force=False, start_qual=start_qual) | ||
tag_modules(ctx, version=str(new_version), force=False) | ||
|
||
print(color_message(f"Waiting until the {new_version} tag appears in Gitlab", "bold")) | ||
|
@@ -564,10 +600,31 @@ def build_rc(ctx, release_branch, patch_version=False, k8s_deployments=False): | |
print(color_message("Creating RC pipeline", "bold")) | ||
|
||
# Step 2: Run the RC pipeline | ||
run_rc_pipeline(release_branch, gitlab_tag.name, k8s_deployments) | ||
|
||
|
||
@task | ||
def run_rc_pipeline(ctx, release_branch, gitlab_tag=None, k8s_deployments=False): | ||
with agent_context(ctx, release_branch): | ||
if not gitlab_tag: | ||
err_msg = "Error: Expected exactly one release candidate tag associated with the qualification tag commit. Tags found:" | ||
try: | ||
res = ctx.run(f"git tag --points-at $(git rev-list -n 1 {QUALIFICATION_TAG}) | grep 6.53") | ||
except Failure as err: | ||
raise Exit(message=f"{err_msg} []", code=1) from err | ||
|
||
tags = [tag for tag in res.stdout.split("\n") if tag.strip()] | ||
if len(tags) > 1: | ||
raise Exit(message=f"{err_msg} {tags}", code=1) | ||
if not RC_VERSION_RE.match(tags[0]): | ||
raise Exit( | ||
message=f"Error: The tag '{tags[0]}' does not match expected release candidate pattern", code=1 | ||
) | ||
gitlab_tag = tags[0] | ||
|
||
run( | ||
ctx, | ||
git_ref=gitlab_tag.name, | ||
git_ref=gitlab_tag, | ||
use_release_entries=True, | ||
repo_branch="beta", | ||
deploy=True, | ||
|
@@ -1294,7 +1351,7 @@ def check_previous_agent6_rc(ctx): | |
err_msg += agent6_prs | ||
|
||
response = get_ci_pipeline_events( | ||
'ci_level:pipeline @ci.pipeline.name:"DataDog/datadog-agent" @git.tag:6.53.* [email protected]:true', | ||
'ci_level:pipeline @ci.pipeline.name:"DataDog/datadog-agent" @git.tag:6.53.* [email protected]:true [email protected]_pipeline:retry', | ||
7, | ||
) | ||
if not response.data: | ||
|