diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/commands/release/make.py b/datadog_checks_dev/datadog_checks/dev/tooling/commands/release/make.py index 53331108a8d77..c6c8027da604a 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/commands/release/make.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/commands/release/make.py @@ -11,7 +11,7 @@ from ...git import get_current_branch, git_commit from ...release import get_agent_requirement_line, update_agent_requirements, update_version_module from ...utils import complete_valid_checks, get_bump_function, get_valid_checks, get_version_string -from ..console import CONTEXT_SETTINGS, abort, echo_info, echo_success, echo_waiting, echo_warning +from ..console import CONTEXT_SETTINGS, abort, echo_debug, echo_info, echo_success, echo_waiting, echo_warning from . import changelog from .show import changes @@ -118,6 +118,7 @@ def make(ctx, checks, version, initial_release, skip_sign, sign_only, exclude, a abort(f'Current version is {cur_version}, cannot bump to {version}') else: cur_version, changelog_types = ctx.invoke(changes, check=check, dry_run=True) + echo_debug(f'Current version: {cur_version}. Changes: {changelog_types}') if not changelog_types: echo_warning(f'No changes for {check}, skipping...') continue diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/commands/release/show/changes.py b/datadog_checks_dev/datadog_checks/dev/tooling/commands/release/show/changes.py index 14ec5d35a2799..3f38de1ad1e40 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/commands/release/show/changes.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/commands/release/show/changes.py @@ -7,7 +7,16 @@ from ....github import get_changelog_types, get_pr, parse_pr_numbers from ....release import get_release_tag_string from ....utils import complete_valid_checks, get_valid_checks, get_version_string -from ...console import CONTEXT_SETTINGS, abort, echo_failure, echo_info, echo_success, echo_warning, validate_check_arg +from ...console import ( + CONTEXT_SETTINGS, + abort, + echo_debug, + echo_failure, + echo_info, + echo_success, + echo_warning, + validate_check_arg, +) @click.command(context_settings=CONTEXT_SETTINGS, short_help='Show all the pending PRs for a given check.') @@ -49,37 +58,32 @@ def changes(ctx, check, tag_pattern, tag_prefix, dry_run, organization, since, e if not dry_run: echo_info(f'Found {len(pr_numbers)} PRs merged since tag: {target_tag}') + applicable_changelog_types = [] user_config = ctx.obj - if dry_run: - changelog_types = [] - - for pr_num in pr_numbers: - try: - payload = get_pr(pr_num, user_config, org=organization) - except Exception as e: - echo_failure(f'Unable to fetch info for PR #{pr_num}: {e}') - continue - current_changelog_types = get_changelog_types(payload) - if not current_changelog_types: + echo_debug(f'Evaluating PRs: {pr_numbers}') + for pr_num in pr_numbers: + try: + payload = get_pr(pr_num, user_config, org=organization) + except Exception as e: + echo_failure(f'Unable to fetch info for PR #{pr_num}: {e}') + continue + changelog_types = get_changelog_types(payload) + if dry_run: + echo_debug('Running changes in dry run mode. Command will abort if there are invalid tags') + if not changelog_types: + echo_failure(f'No valid changelog labels found attached to PR #{pr_num}, please add one!') abort(f'No valid changelog labels found attached to PR #{pr_num}, please add one!') - elif len(current_changelog_types) > 1: + elif len(changelog_types) > 1: + echo_failure(f'Multiple changelog labels found attached to PR #{pr_num}, please only use one!') abort(f'Multiple changelog labels found attached to PR #{pr_num}, please only use one!') - current_changelog_type = current_changelog_types[0] + current_changelog_type = changelog_types[0] if current_changelog_type != 'no-changelog': - changelog_types.append(current_changelog_type) - - return cur_version, changelog_types - else: - for pr_num in pr_numbers: - try: - payload = get_pr(pr_num, user_config, org=organization) - except Exception as e: - echo_failure(f'Unable to fetch info for PR #{pr_num}: {e}') - continue - - changelog_types = get_changelog_types(payload) - + echo_debug(f'Found change {current_changelog_type}') + applicable_changelog_types.append(current_changelog_type) + else: + echo_debug(f'Found no-changelog change for PR {pr_num}, skipping') + else: echo_success(payload.get('title')) echo_info(f" * Url: {payload.get('html_url')}") @@ -90,3 +94,5 @@ def changes(ctx, check, tag_pattern, tag_prefix, dry_run, organization, since, e echo_warning(f"WARNING! Too many changelog labels attached: {', '.join(changelog_types)}\n") else: echo_success(f'{changelog_types[0]}\n') + + return cur_version, applicable_changelog_types