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 47 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
7 changes: 5 additions & 2 deletions tasks/libs/ciproviders/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import requests

from tasks.libs.common.color import color_message
from tasks.libs.common.constants import GITHUB_REPO_NAME
from tasks.libs.common.constants import DEFAULT_AGENT6_BRANCH, GITHUB_REPO_NAME

try:
import semver
Expand Down Expand Up @@ -202,6 +202,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 Expand Up @@ -444,7 +447,7 @@ def create_release_pr(title, base_branch, target_branch, version, changelog_pr=F
]

if changelog_pr:
CelianR marked this conversation as resolved.
Show resolved Hide resolved
labels.append("backport/main")
labels.append(f"backport/{DEFAULT_AGENT6_BRANCH}" if base_branch.startswith('6.') else "backport/main")

updated_pr = github.update_pr(
pull_number=pr.number,
Expand Down
2 changes: 2 additions & 0 deletions tasks/libs/common/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DEFAULT_AGENT6_VERSION = "6.53.0"
CelianR marked this conversation as resolved.
Show resolved Hide resolved
DEFAULT_AGENT6_BRANCH = "6.53.x"
DEFAULT_BRANCH = "main"
DEFAULT_INTEGRATIONS_CORE_BRANCH = "master"
GITHUB_ORG = "DataDog"
Expand Down
6 changes: 3 additions & 3 deletions tasks/libs/common/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from invoke.exceptions import Exit

from tasks.libs.common.color import Color, color_message
from tasks.libs.common.constants import DEFAULT_BRANCH
from tasks.libs.common.constants import DEFAULT_AGENT6_BRANCH, DEFAULT_BRANCH
from tasks.libs.common.user_interactions import yes_no_question

if TYPE_CHECKING:
Expand Down Expand Up @@ -134,12 +134,12 @@ def get_main_parent_commit(ctx) -> str:
return ctx.run("git merge-base HEAD origin/main", hide=True).stdout.strip()


def check_base_branch(branch, release_version):
def check_base_branch(branch, release_version, agent6=False):
"""
Checks if the given branch is either the default branch or the release branch associated
with the given release version.
"""
return branch == DEFAULT_BRANCH or branch == release_version.branch()
return branch == (DEFAULT_AGENT6_BRANCH if agent6 else DEFAULT_BRANCH) or branch == release_version.branch()


def try_git_command(ctx, git_command):
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,21 +2,22 @@

from invoke import Failure

from tasks.libs.common.constants import DEFAULT_BRANCH, GITHUB_REPO_NAME
from tasks.libs.common.constants import DEFAULT_AGENT6_BRANCH, DEFAULT_BRANCH, GITHUB_REPO_NAME
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_AGENT6_BRANCH if version.startswith('6.') else 'master'
CelianR marked this conversation as resolved.
Show resolved Hide resolved

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 @@ -25,29 +26,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 = DEFAULT_AGENT6_BRANCH if version.startswith('6.') else 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/{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
12 changes: 5 additions & 7 deletions tasks/libs/releasing/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ def _create_version_from_match(match):
return version


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

lead = '6' if agent6 else '7'
CelianR marked this conversation as resolved.
Show resolved Hide resolved
version_re = re.compile(rf'{lead}[.](\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 {lead}.Y.Z or {lead}.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
1 change: 1 addition & 0 deletions tasks/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
independent=False,
lint_targets=None,
used_by_otel=False,
**_kwargs, # Deprecated args
CelianR marked this conversation as resolved.
Show resolved Hide resolved
):
self.path = path
self.targets = targets if targets else ["."]
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