Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACIX-453] Agent 6 release tasks support #30062

Merged
merged 112 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 102 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
3eb28f0
[a6-releasing] Added agent context context manager
CelianR Oct 11, 2024
8868731
[a6-releasing] Doc
CelianR Oct 11, 2024
f6797e7
[a6-releasing] Default modules
CelianR Oct 11, 2024
3ee5297
[a6-releasing] Dynamic default module loading magic + test [skip ci]
CelianR Oct 11, 2024
4ae2b29
[a6-releasing] Cleaned agent context code
CelianR Oct 14, 2024
c4afe7a
[a6-releasing] Agent6 set context
CelianR Oct 14, 2024
7b5331a
[a6-releasing] Update modules
CelianR Oct 14, 2024
a3a647e
[a6-releasing] Updated message
CelianR Oct 14, 2024
c616dbc
[a6-releasing] Updated tag_* [skip ci]
CelianR Oct 14, 2024
ebf1512
[a6-releasing] Formatted doc
CelianR Oct 14, 2024
be93145
[a6-releasing] notes: Updated changelog notes
CelianR Oct 14, 2024
9f00afb
[a6-releasing] Updated finish
CelianR Oct 14, 2024
cd73e2c
[a6-releasing] Updated backport branch name [skip ci]
CelianR Oct 14, 2024
82e7f1f
[a6-releasing] Updated agent_context to clean code
CelianR Oct 14, 2024
7abffde
[skip ci] Fixed info message
CelianR Oct 14, 2024
c6fd47e
[a6-releasing] Fixed agent context defaults
CelianR Oct 14, 2024
d62e017
[a6-releasing] tmp
CelianR Oct 14, 2024
a4e8c72
[a6-releasing] Fixed defaults
CelianR Oct 14, 2024
18ddc15
[a6-releasing] tmp
CelianR Oct 14, 2024
7c781e2
[a6-releasing] Removed tests
CelianR Oct 14, 2024
7e11dc2
[a6-releasing] tmp
CelianR Oct 14, 2024
28aa4f8
[a6-releasing] tmp
CelianR Oct 14, 2024
89e9a57
[a6-releasing] tmp
CelianR Oct 14, 2024
8e6bf10
[a6-releasing] tmp
CelianR Oct 14, 2024
87ace4c
[a6-releasing] tmp
CelianR Oct 14, 2024
20a169e
[a6-releasing] [skip ci] Updated info message + removed tests
CelianR Oct 14, 2024
f3367e3
[a6-releasing] build rc
CelianR Oct 15, 2024
71e9bc9
[a6-releasing] set_release_json
CelianR Oct 15, 2024
3c66315
[a6-releasing] create_and_update_release_branch
CelianR Oct 15, 2024
19684d6
[a6-releasing] create-release-branches
CelianR Oct 15, 2024
9f50007
[a6-releasing] Removed tests [skip ci]
CelianR Oct 15, 2024
05a763d
[a6-releasing] tmp
CelianR Oct 15, 2024
ff48d49
[a6-releasing] tmp
CelianR Oct 15, 2024
6de2e9b
[a6-releasing] cleanup
CelianR Oct 15, 2024
1ea794f
[a6-releasing] updated doc [skip ci]
CelianR Oct 15, 2024
445fb11
[a6-releasing] get active release branch
CelianR Oct 15, 2024
f92274f
[a6-releasing] Last task changes
CelianR Oct 16, 2024
8403032
[a6-releasing] Cleaned
CelianR Oct 16, 2024
c53358c
[a6-releasing] ruff
CelianR Oct 16, 2024
fe17f2e
Update tasks/libs/releasing/version.py
CelianR Oct 17, 2024
151096c
Update tasks/release.py [skip ci]
CelianR Oct 17, 2024
b3caf66
[a6-releasing] Infer version
CelianR Oct 17, 2024
f8a72f2
[a6-releasing] Updated check_version agent6 arg
CelianR Oct 17, 2024
03eea78
[a6-releasing] Removed useless assert
CelianR Oct 17, 2024
3b9a271
[a6-releasing] git switch
CelianR Oct 17, 2024
ef3bf81
[a6-releasing] tmp
CelianR Oct 17, 2024
2ab1e75
[a6-releasing] Updated agent context args (exactly one of version / m…
CelianR Oct 17, 2024
5e81855
[rfc-update-tasks-a6-a7] tmp
CelianR Nov 15, 2024
88d022c
[rfc-update-tasks-a6-a7] tmp
CelianR Nov 15, 2024
b36cef8
[rfc-update-tasks-a6-a7] Implemented context + agent 6 switch for mod…
CelianR Nov 18, 2024
7cc0f50
[rfc-update-tasks-a6-a7] tmp
CelianR Nov 18, 2024
1f8ed02
[rfc-update-tasks-a6-a7] Fixed refactoring [skip ci]
CelianR Nov 18, 2024
e50350e
[rfc-update-tasks-a6-a7] modules: Updated cache
CelianR Nov 18, 2024
728a0c0
[rfc-update-tasks-a6-a7] Added agent6.invoke
CelianR Nov 18, 2024
aa21a8e
[rfc-update-tasks-a6-a7] Updated all "main"
CelianR Nov 18, 2024
d90e347
[rfc-update-tasks-a6-a7] Fixes, cleaning
CelianR Nov 18, 2024
f195804
[rfc-update-tasks-a6-a7] Added tests
CelianR Nov 18, 2024
6376156
[rfc-update-tasks-a6-a7] unit-tests: Added agent 6 tests
CelianR Nov 18, 2024
1905845
[rfc-update-tasks-a6-a7] Applied suggestions, moved functions, remove…
CelianR Nov 19, 2024
5c37de7
[rfc-update-tasks-a6-a7] Removed system probe branch
CelianR Nov 19, 2024
76a6bd1
[rfc-update-tasks-a6-a7] agent6: Add remove env
CelianR Nov 20, 2024
6c12470
[rfc-update-tasks-a6-a7] agent 6 -> worktree
CelianR Nov 21, 2024
3e68cb5
[rfc-update-tasks-a6-a7] Fixed modules (removed lru cache), renamed a…
CelianR Nov 21, 2024
96daa32
[rfc-update-tasks-a6-a7] Added no switch option
CelianR Nov 21, 2024
210e96c
[rfc-update-tasks-a6-a7] switch -> checkout
CelianR Nov 21, 2024
7e61258
[rfc-update-tasks-a6-a7] switch -> checkout
CelianR Nov 21, 2024
c0b62e1
[rfc-update-tasks-a6-a7] remove: Fixed
CelianR Nov 21, 2024
bd9dd21
[rfc-update-tasks-a6-a7] Added notes
CelianR Nov 21, 2024
2466d27
[rfc-update-tasks-a6-a7] Fix error note
CelianR Nov 21, 2024
61706e3
Merge branch 'main' into celian/rfc-update-tasks-a6-a7-acix-453
CelianR Nov 22, 2024
1b76b45
[a6-releasing] [merge main]
CelianR Nov 22, 2024
29ca9d1
Merge branch 'main' into celian/rfc-update-tasks-a6-a7-acix-453
CelianR Nov 22, 2024
0a00e5f
[a6-releasing] Removed exit
CelianR Nov 22, 2024
fc9a862
[a6-releasing] infer version
CelianR Nov 22, 2024
09badf7
[a6-releasing] Applied suggestions
CelianR Nov 22, 2024
a1290b5
Apply suggestions from code review [skip ci]
CelianR Nov 25, 2024
1869b01
[rfc-update-tasks-a6-a7] Applied Sabrina's suggestions
CelianR Nov 25, 2024
c127193
[rfc-update-tasks-a6-a7] skip_checkout: Verified that the branch is a…
CelianR Nov 25, 2024
0ffb4d4
Update tasks/libs/common/worktree.py
CelianR Nov 25, 2024
1e57702
[rfc-update-tasks-a6-a7] default_modules: Refactored since it is not …
CelianR Nov 25, 2024
7daf382
[rfc-update-tasks-a6-a7] Fixed missing arg
CelianR Nov 25, 2024
14ad3d7
[rfc-update-tasks-a6-a7] Added various git commands to worktree and s…
CelianR Nov 25, 2024
3d2e68b
[rfc-update-tasks-a6-a7] Updated error message
CelianR Nov 25, 2024
3a2147e
[rfc-update-tasks-a6-a7] agent_context: If branch is None, then it wo…
CelianR Nov 25, 2024
12e54cc
[a6-releasing] Merge + added new agent_context with worktree
CelianR Nov 26, 2024
74155c3
[rfc-update-tasks-a6-a7] invoke: Added warning
CelianR Nov 26, 2024
bc87c2d
Apply suggestions from code review
CelianR Nov 26, 2024
63008c2
[a6-releasing] [merge] rfc
CelianR Nov 26, 2024
365931f
Merge branch 'main' into celian/a6-releasing
CelianR Nov 26, 2024
f4937b2
[a6-releasing] finish: Verified
CelianR Nov 26, 2024
75b2acb
[a6-releasing] create_rc: Verified
CelianR Nov 26, 2024
fd01dbf
[a6-releasing] build_rc: Verified
CelianR Nov 26, 2024
a666976
[a6-releasing] get / set release json: Verified [skip ci]
CelianR Nov 26, 2024
d5ce3e0
[a6-releasing] create_release_branches: Verified
CelianR Nov 26, 2024
74d15ba
[a6-releasing] check_for_changes: Verified
CelianR Nov 26, 2024
33dbe68
[a6-releasing] create_github_release: Verified
CelianR Nov 26, 2024
a907f0e
[a6-releasing] Removed tests [skip ci]
CelianR Nov 26, 2024
04e0522
[a6-releasing] Fixed tests [skip ci]
CelianR Nov 26, 2024
22ad713
[a6-releasing] active branches: Added release branch [skip ci]
CelianR Nov 27, 2024
79e63b1
[a6-releasing] [merge]
CelianR Nov 27, 2024
42102ea
[a6-releasing] Small fixes
CelianR Nov 27, 2024
13f5380
[a6-releasing] release: Added --no-worktree to get / set json
CelianR Nov 27, 2024
b73255e
[a6-releasing] Disabled worktree / added task argument for release ta…
CelianR Nov 27, 2024
a885616
[a6-releasing] [merge]
CelianR Nov 27, 2024
67e3173
[a6-releasing] do-not-merge: Fixed
CelianR Nov 27, 2024
25a2aa6
[a6-releasing] suggestions: startswith 6.53
CelianR Dec 5, 2024
d70e2d7
[a6-releasing] suggestions: yes -> trust
CelianR Dec 5, 2024
5f437ff
[a6-releasing] suggestions: Removed "agent 7 version"
CelianR Dec 5, 2024
bcf2aa0
[a6-releasing] suggestions: Removed "agent 7 version"
CelianR Dec 5, 2024
67fe4e7
[a6-releasing] [merge]
CelianR Dec 5, 2024
798a92c
[a6-releasing] Fixed regex
CelianR Dec 5, 2024
abb177c
[a6-releasing] [merge]
CelianR Dec 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitlab/e2e_install_packages/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- !reference [.new_e2e_template, before_script]
script:
# LAST_STABLE_VERSION is used for upgrade test
- export LAST_STABLE_VERSION=$(invoke release.get-release-json-value "last_stable::7")
- export LAST_STABLE_VERSION=$(invoke release.get-release-json-value "last_stable::7" --no-worktree)
- !reference [.new_e2e_template, script]

.new-e2e_windows_domain_test:
Expand All @@ -28,7 +28,7 @@
- !reference [.new_e2e_template, before_script]
script:
# LAST_STABLE_VERSION is used for upgrade test
- export LAST_STABLE_VERSION=$(invoke release.get-release-json-value "last_stable::7")
- export LAST_STABLE_VERSION=$(invoke release.get-release-json-value "last_stable::7" --no-worktree)
- !reference [.new_e2e_template, script]

.new-e2e_windows_installer_v7_tests:
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/functional_test/regression_detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ single-machine-performance-regression_detector:
- mkdir outputs # Also needed for smp job sync step
# Compute merge base of current commit and `main`
- git fetch origin
- SMP_BASE_BRANCH=$(inv release.get-release-json-value base_branch)
- SMP_BASE_BRANCH=$(inv release.get-release-json-value base_branch --no-worktree)
- echo "Looking for merge base for branch ${SMP_BASE_BRANCH}"
- SMP_MERGE_BASE=$(git merge-base ${CI_COMMIT_SHA} origin/${SMP_BASE_BRANCH})
- echo "Merge base is ${SMP_MERGE_BASE}"
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/kitchen_testing/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

.kitchen_test_upgrade7:
script:
- export LAST_STABLE_VERSION=$(cd ../.. && invoke release.get-release-json-value "last_stable::7")
- export LAST_STABLE_VERSION=$(cd ../.. && invoke release.get-release-json-value "last_stable::7" --no-worktree)
- tasks/run-test-kitchen.sh upgrade7-test 7

# Kitchen: Agent flavor
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/pkg_metrics/pkg_metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ send_pkg_size:
- if [[ "${ARCH}" == "amd64" ]]; then ls -l $OMNIBUS_PACKAGE_DIR_SUSE; fi

- export failures=0
- export last_stable=$(inv release.get-release-json-value "last_stable::${MAJOR_VERSION}")
- export last_stable=$(inv release.get-release-json-value "last_stable::${MAJOR_VERSION}" --no-worktree)
# Get stable packages from S3 buckets, send new package sizes & compare stable and new package sizes
# The loop assumes that all flavors start with "da", which is currently the case
# We want to run all package size comparisons before failing, so we set +e while doing the comparisons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
).stdout.split()
# Retrieving integrations from cache
cache_bucket = ENV.fetch('INTEGRATION_WHEELS_CACHE_BUCKET', '')
cache_branch = (shellout! "inv release.get-release-json-value base_branch", cwd: File.expand_path('..', tasks_dir_in)).stdout.strip
cache_branch = (shellout! "inv release.get-release-json-value base_branch --no-worktree", cwd: File.expand_path('..', tasks_dir_in)).stdout.strip
if cache_bucket != ''
mkdir cached_wheels_dir
shellout! "inv -e agent.get-integrations-from-cache " \
Expand Down
2 changes: 1 addition & 1 deletion tasks/kmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,7 @@ def install_ddagent(
assert len(domains) > 0, err_msg

if version is not None:
check_version(version)
check_version(ctx, version)
else:
with open("release.json") as f:
release = json.load(f)
Expand Down
3 changes: 3 additions & 0 deletions tasks/libs/ciproviders/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ def latest_release(self) -> str:
release = self._repository.get_latest_release()
return release.title

def get_releases(self):
return self._repository.get_releases()

def latest_unreleased_release_branches(self):
"""
Get all the release branches that are newer than the latest release.
Expand Down
4 changes: 2 additions & 2 deletions tasks/libs/common/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ def is_agent6(ctx) -> bool:
return get_current_branch(ctx).startswith("6.")


def get_default_branch():
def get_default_branch(major: int | None = None):
"""Returns the default git branch given the current context (agent 6 / 7)."""

# We create a context to avoid passing context in each function
# This context is used to get the current branch so there is no side effect
ctx = Context()

return '6.53.x' if is_agent6(ctx) else 'main'
return '6.53.x' if major is None and is_agent6(ctx) or major == 6 else 'main'


def get_common_ancestor(ctx, branch, base=None) -> str:
Expand Down
7 changes: 3 additions & 4 deletions tasks/libs/releasing/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from invoke.exceptions import Exit

from tasks.libs.common.constants import TAG_FOUND_TEMPLATE
from tasks.libs.common.git import get_default_branch
from tasks.libs.common.worktree import is_worktree
from tasks.libs.common.git import get_default_branch, is_agent6
from tasks.libs.releasing.documentation import _stringify_config, nightly_entry_for, release_entry_for
from tasks.libs.releasing.version import (
VERSION_RE,
Expand Down Expand Up @@ -337,7 +336,7 @@ def set_new_release_branch(branch):
_save_release_json(rj)


def generate_repo_data(warning_mode, next_version, release_branch):
def generate_repo_data(ctx, warning_mode, next_version, release_branch):
repos = ["integrations-core"] if warning_mode else ALL_REPOS
previous_tags = find_previous_tags("release-a7", repos, RELEASE_JSON_FIELDS_TO_UPDATE)
data = {}
Expand All @@ -347,7 +346,7 @@ def generate_repo_data(warning_mode, next_version, release_branch):
branch = (
next_version.branch()
if repo == "integrations-core"
else (DEFAULT_BRANCHES_AGENT6 if is_worktree() else DEFAULT_BRANCHES).get(repo, get_default_branch())
else (DEFAULT_BRANCHES_AGENT6 if is_agent6(ctx) else DEFAULT_BRANCHES).get(repo, get_default_branch())
)
data[repo] = {
'branch': branch,
Expand Down
25 changes: 11 additions & 14 deletions tasks/libs/releasing/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

from invoke import Failure

from tasks.libs.common.constants import GITHUB_REPO_NAME
from tasks.libs.common.constants import DEFAULT_INTEGRATIONS_CORE_BRANCH, GITHUB_REPO_NAME
from tasks.libs.common.git import get_default_branch
from tasks.libs.releasing.version import current_version


def _add_prelude(ctx, version):
res = ctx.run(f"reno new prelude-release-{version}")
new_releasenote = res.stdout.split(' ')[-1].strip() # get the new releasenote file path
branch = DEFAULT_INTEGRATIONS_CORE_BRANCH

with open(new_releasenote, "w") as f:
f.write(
f"""prelude:
|
Release on: {date.today()}

- Please refer to the `{version} tag on integrations-core <https://github.com/DataDog/integrations-core/blob/master/AGENT_CHANGELOG.md#datadog-agent-version-{version.replace('.', '')}>`_ for the list of changes on the Core Checks
- Please refer to the `{version} tag on integrations-core <https://github.com/DataDog/integrations-core/blob/{branch}/AGENT_CHANGELOG.md#datadog-agent-version-{version.replace('.', '')}>`_ for the list of changes on the Core Checks
"""
)

Expand All @@ -26,29 +27,25 @@ def _add_prelude(ctx, version):
print(f"git commit -m \"Add prelude for {version} release\"")


def _add_dca_prelude(ctx, agent7_version, agent6_version=""):
"""
Release of the Cluster Agent should be pinned to a version of the Agent.
"""
res = ctx.run(f"reno --rel-notes-dir releasenotes-dca new prelude-release-{agent7_version}")
new_releasenote = res.stdout.split(' ')[-1].strip() # get the new releasenote file path
def _add_dca_prelude(ctx, version=None):
"""Release of the Cluster Agent should be pinned to a version of the Agent."""

if agent6_version != "":
agent6_version = (
f"--{agent6_version.replace('.', '')}" # generate the right hyperlink to the agent's changelog.
)
branch = get_default_branch()

res = ctx.run(f"reno --rel-notes-dir releasenotes-dca new prelude-release-{version}")
new_releasenote = res.stdout.split(' ')[-1].strip() # get the new releasenote file path

with open(new_releasenote, "w") as f:
f.write(
f"""prelude:
|
Released on: {date.today()}
Pinned to datadog-agent v{agent7_version}: `CHANGELOG <https://github.com/{GITHUB_REPO_NAME}/blob/{get_default_branch()}/CHANGELOG.rst#{agent7_version.replace('.', '')}{agent6_version}>`_."""
Pinned to datadog-agent v{version}: `CHANGELOG <https://github.com/{GITHUB_REPO_NAME}/blob/{branch}/CHANGELOG.rst#{version.replace('.', '')}>`_."""
)

ctx.run(f"git add {new_releasenote}")
print("\nIf not run as part of finish task, commit this with:")
print(f"git commit -m \"Add prelude for {agent7_version} release\"")
print(f"git commit -m \"Add prelude for {version} release\"")


def update_changelog_generic(ctx, new_version, changelog_dir, changelog_file):
Expand Down
14 changes: 6 additions & 8 deletions tasks/libs/releasing/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
REPO_NAME,
TAG_FOUND_TEMPLATE,
)
from tasks.libs.common.git import get_commit_sha, get_current_branch
from tasks.libs.common.git import get_commit_sha, get_current_branch, is_agent6
from tasks.libs.common.user_interactions import yes_no_question
from tasks.libs.releasing.documentation import release_entry_for
from tasks.libs.types.version import Version
Expand Down Expand Up @@ -61,11 +61,13 @@ def _create_version_from_match(match):
return version


def check_version(agent_version):
def check_version(ctx, agent_version):
"""Check Agent version to see if it is valid."""
version_re = re.compile(r'7[.](\d+)[.](\d+)(-rc\.(\d+))?')

major = '6' if is_agent6(ctx) else '7'
version_re = re.compile(rf'{major}[.](\d+)[.](\d+)(-rc\.(\d+))?')
if not version_re.match(agent_version):
raise Exit(message="Version should be of the form 7.Y.Z or 7.Y.Z-rc.t")
raise Exit(message=f"Version should be of the form {major}.Y.Z or {major}.Y.Z-rc.t")


def current_version(ctx, major_version) -> Version:
Expand Down Expand Up @@ -115,10 +117,6 @@ def next_rc_version(ctx, major_version, patch_version=False) -> Version:
return new_version


def parse_major_versions(major_versions):
return sorted(int(x) for x in major_versions.split(","))


##
## Repository version fetch functions
## The following functions aim at returning the correct version to use for a given
Expand Down
4 changes: 2 additions & 2 deletions tasks/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def add_prelude(ctx, version):


@task
def add_dca_prelude(ctx, agent7_version, agent6_version=""):
def add_dca_prelude(ctx, version):
"""
Release of the Cluster Agent should be pinned to a version of the Agent.
"""
_add_dca_prelude(ctx, agent7_version, agent6_version)
_add_dca_prelude(ctx, version)


@task
Expand Down
Loading
Loading