Skip to content

Commit

Permalink
[ACIX-453] Agent 6 release tasks support (#30062)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Schweitzer <[email protected]>
Co-authored-by: sabrina lu <[email protected]>
Co-authored-by: pducolin <[email protected]>
  • Loading branch information
4 people authored Dec 6, 2024
1 parent 38921a7 commit f7625c5
Show file tree
Hide file tree
Showing 15 changed files with 712 additions and 557 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/create_rc_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ jobs:
- name: Create RC PR
if: ${{ steps.check_for_changes.outputs.CHANGES == 'true'}}
env:
MATRIX: ${{ matrix.value }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch
inv -e release.create-rc --slack-webhook=${{ secrets.AGENT_RELEASE_SYNC_SLACK_WEBHOOK }}
inv -e release.create-rc "$MATRIX" --slack-webhook=${{ secrets.AGENT_RELEASE_SYNC_SLACK_WEBHOOK }}
2 changes: 1 addition & 1 deletion .gitlab/check_merge/do_not_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ do-not-merge:
echo "This workflow fails so that the pull request cannot be merged"
exit 1
fi
- inv -e release.check-omnibus-branches || exit 1
- inv -e release.check-omnibus-branches --no-worktree || exit 1
- exit 0
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/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
2 changes: 1 addition & 1 deletion omnibus/config/software/datadog-agent-integrations-py3.rb
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 @@ -334,6 +334,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
6 changes: 3 additions & 3 deletions tasks/libs/common/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ def get_current_branch(ctx) -> str:


def is_agent6(ctx) -> bool:
return get_current_branch(ctx).startswith("6.")
return get_current_branch(ctx).startswith("6.53")


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

0 comments on commit f7625c5

Please sign in to comment.