Skip to content

Commit e033df1

Browse files
Automatically create a release branch in test-infra-definitions after the cut-off
1 parent 08a56af commit e033df1

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

tasks/libs/ciproviders/gitlab_api.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from difflib import Differ
1717
from functools import lru_cache
1818
from itertools import product
19+
from pathlib import Path
1920
from typing import Any, Literal
2021

2122
import gitlab
@@ -1300,6 +1301,18 @@ def update_test_infra_def(file_path, image_tag, is_dev_image=False, prefix_comme
13001301
yaml.dump(test_infra_def, test_infra_version_file, explicit_start=True)
13011302

13021303

1304+
def get_test_infra_def_version():
1305+
"""
1306+
Get TEST_INFRA_DEFINITIONS_BUILDIMAGES from `.gitlab/common/test_infra_version.yml` file
1307+
"""
1308+
try:
1309+
with open(Path(".gitlab/common/test_infra_version.yml")) as test_infra_version_file:
1310+
test_infra_def = yaml.safe_load(test_infra_version_file)
1311+
return test_infra_def["variables"]["TEST_INFRA_DEFINITIONS_BUILDIMAGES"]
1312+
except Exception:
1313+
return "main"
1314+
1315+
13031316
def update_gitlab_config(file_path, tag, images="", test=True, update=True, windows=False):
13041317
"""
13051318
Override variables in .gitlab-ci.yml file.

tasks/libs/releasing/json.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from invoke.exceptions import Exit
88

9+
from tasks.libs.ciproviders.gitlab_api import get_test_infra_def_version
910
from tasks.libs.common.constants import TAG_FOUND_TEMPLATE
1011
from tasks.libs.common.git import get_default_branch, is_agent6
1112
from tasks.libs.releasing.documentation import _stringify_config
@@ -35,11 +36,12 @@
3536
INTERNAL_DEPS_REPOS = ["omnibus-ruby"]
3637
DEPENDENT_REPOS = INTERNAL_DEPS_REPOS + ["integrations-core"]
3738
ALL_REPOS = DEPENDENT_REPOS + [UNFREEZE_REPO_AGENT]
38-
UNFREEZE_REPOS = INTERNAL_DEPS_REPOS + [UNFREEZE_REPO_AGENT] + ["datadog-agent-buildimages"]
39+
UNFREEZE_REPOS = INTERNAL_DEPS_REPOS + [UNFREEZE_REPO_AGENT] + ["datadog-agent-buildimages", "test-infra-definitions"]
3940
DEFAULT_BRANCHES = {
4041
"omnibus-ruby": "datadog-5.5.0",
4142
"datadog-agent": "main",
4243
"datadog-agent-buildimages": "main",
44+
"test-infra-definitions": get_test_infra_def_version(),
4345
}
4446
DEFAULT_BRANCHES_AGENT6 = {
4547
"omnibus-ruby": "6.53.x",

tasks/release.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ def _main():
761761
or ctx.run(f"git remote show {upstream} | grep \"HEAD branch\" | sed 's/.*: //'").stdout.strip()
762762
)
763763
ctx.run(f"git checkout {main_branch}")
764-
ctx.run("git pull")
764+
ctx.run("git pull", warn=True)
765765

766766
_main()
767767

@@ -816,9 +816,8 @@ def create_release_branches(
816816

817817
# Step 1 - Create release branches in all required repositories
818818

819-
base_branch = get_default_branch() if major_version == 6 else None
820-
821819
for repo in UNFREEZE_REPOS:
820+
base_branch = get_default_branch() if major_version == 6 else DEFAULT_BRANCHES[repo]
822821
create_and_update_release_branch(
823822
ctx, repo, release_branch, base_branch=base_branch, base_directory=base_directory, upstream=upstream
824823
)

0 commit comments

Comments
 (0)