From 324bec78ffcc7c5ee124ce6b63010412b3d7dc6c Mon Sep 17 00:00:00 2001 From: Max K Date: Mon, 27 May 2024 18:43:24 +0200 Subject: [PATCH 1/4] CI: Critical bugfix category in PR template --- .github/PULL_REQUEST_TEMPLATE.md | 1 + tests/ci/cherry_pick.py | 8 ++++++++ tests/ci/lambda_shared_package/lambda_shared/pr.py | 9 +++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f9765c1d57b..796d4f6e853 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,6 +11,7 @@ tests/ci/cancel_and_rerun_workflow_lambda/app.py - Backward Incompatible Change - Build/Testing/Packaging Improvement - Documentation (changelog entry is not required) +- Critical Bug Fix (critical issues in non-experimental features, auto backport) - Bug Fix (user-visible misbehavior in an official stable release) - CI Fix or Improvement (changelog entry is not required) - Not for changelog (changelog entry is not required) diff --git a/tests/ci/cherry_pick.py b/tests/ci/cherry_pick.py index 7f267d5ed1a..39d4599a87f 100644 --- a/tests/ci/cherry_pick.py +++ b/tests/ci/cherry_pick.py @@ -245,6 +245,10 @@ close it. ) self.cherrypick_pr.add_to_labels(Labels.PR_CHERRYPICK) self.cherrypick_pr.add_to_labels(Labels.DO_NOT_TEST) + if Labels.PR_CRITICAL_BUGFIX in [label.name for label in self.pr.labels]: + self.cherrypick_pr.add_to_labels(Labels.PR_CRITICAL_BUGFIX) + elif Labels.PR_BUGFIX in [label.name for label in self.pr.labels]: + self.cherrypick_pr.add_to_labels(Labels.PR_BUGFIX) self._assign_new_pr(self.cherrypick_pr) # update cherrypick PR to get the state for PR.mergable self.cherrypick_pr.update() @@ -280,6 +284,10 @@ close it. head=self.backport_branch, ) self.backport_pr.add_to_labels(Labels.PR_BACKPORT) + if Labels.PR_CRITICAL_BUGFIX in [label.name for label in self.pr.labels]: + self.cherrypick_pr.add_to_labels(Labels.PR_CRITICAL_BUGFIX) + elif Labels.PR_BUGFIX in [label.name for label in self.pr.labels]: + self.cherrypick_pr.add_to_labels(Labels.PR_BUGFIX) self._assign_new_pr(self.backport_pr) def ping_cherry_pick_assignees(self, dry_run: bool) -> None: diff --git a/tests/ci/lambda_shared_package/lambda_shared/pr.py b/tests/ci/lambda_shared_package/lambda_shared/pr.py index f80ac896c9b..e547cc855cb 100644 --- a/tests/ci/lambda_shared_package/lambda_shared/pr.py +++ b/tests/ci/lambda_shared_package/lambda_shared/pr.py @@ -50,6 +50,8 @@ TRUSTED_CONTRIBUTORS = { class Labels: + PR_BUGFIX = "pr-bugfix" + PR_CRITICAL_BUGFIX = "pr-critical-bugfix" CAN_BE_TESTED = "can be tested" DO_NOT_TEST = "do not test" MUST_BACKPORT = "pr-must-backport" @@ -68,8 +70,8 @@ class Labels: RELEASE_LTS = "release-lts" SUBMODULE_CHANGED = "submodule changed" - # pr-bugfix autoport can lead to issues in releases, let's do ci fixes only - AUTO_BACKPORT = {"pr-ci"} + # automatic backport for critical bug fixes + AUTO_BACKPORT = {"pr-critical-bugfix"} # Descriptions are used in .github/PULL_REQUEST_TEMPLATE.md, keep comments there @@ -84,6 +86,9 @@ LABEL_CATEGORIES = { "Bug Fix (user-visible misbehaviour in official stable or prestable release)", "Bug Fix (user-visible misbehavior in official stable or prestable release)", ], + "pr-critical-bugfix": [ + "Critical Bug Fix (critical issues in non-experimental features, auto backport)" + ], "pr-build": [ "Build/Testing/Packaging Improvement", "Build Improvement", From edf8d92cf02ce4ac4ed59cc5105010b96a4f4657 Mon Sep 17 00:00:00 2001 From: Max K Date: Tue, 28 May 2024 12:53:52 +0200 Subject: [PATCH 2/4] CI: add category to changelog.py --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- tests/ci/cherry_pick.py | 4 ++-- tests/ci/lambda_shared_package/lambda_shared/pr.py | 2 +- utils/changelog/changelog.py | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 796d4f6e853..041024b21db 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,7 +11,7 @@ tests/ci/cancel_and_rerun_workflow_lambda/app.py - Backward Incompatible Change - Build/Testing/Packaging Improvement - Documentation (changelog entry is not required) -- Critical Bug Fix (critical issues in non-experimental features, auto backport) +- Critical Bug Fix (crash, LOGICAL_ERROR, data loss, RBAC) - Bug Fix (user-visible misbehavior in an official stable release) - CI Fix or Improvement (changelog entry is not required) - Not for changelog (changelog entry is not required) diff --git a/tests/ci/cherry_pick.py b/tests/ci/cherry_pick.py index 39d4599a87f..353b1461b93 100644 --- a/tests/ci/cherry_pick.py +++ b/tests/ci/cherry_pick.py @@ -285,9 +285,9 @@ close it. ) self.backport_pr.add_to_labels(Labels.PR_BACKPORT) if Labels.PR_CRITICAL_BUGFIX in [label.name for label in self.pr.labels]: - self.cherrypick_pr.add_to_labels(Labels.PR_CRITICAL_BUGFIX) + self.backport_pr.add_to_labels(Labels.PR_CRITICAL_BUGFIX) elif Labels.PR_BUGFIX in [label.name for label in self.pr.labels]: - self.cherrypick_pr.add_to_labels(Labels.PR_BUGFIX) + self.backport_pr.add_to_labels(Labels.PR_BUGFIX) self._assign_new_pr(self.backport_pr) def ping_cherry_pick_assignees(self, dry_run: bool) -> None: diff --git a/tests/ci/lambda_shared_package/lambda_shared/pr.py b/tests/ci/lambda_shared_package/lambda_shared/pr.py index e547cc855cb..2a396859850 100644 --- a/tests/ci/lambda_shared_package/lambda_shared/pr.py +++ b/tests/ci/lambda_shared_package/lambda_shared/pr.py @@ -87,7 +87,7 @@ LABEL_CATEGORIES = { "Bug Fix (user-visible misbehavior in official stable or prestable release)", ], "pr-critical-bugfix": [ - "Critical Bug Fix (critical issues in non-experimental features, auto backport)" + "Critical Bug Fix (crash, LOGICAL_ERROR, data loss, RBAC)" ], "pr-build": [ "Build/Testing/Packaging Improvement", diff --git a/utils/changelog/changelog.py b/utils/changelog/changelog.py index 6b70952eced..acc7293473d 100755 --- a/utils/changelog/changelog.py +++ b/utils/changelog/changelog.py @@ -25,6 +25,7 @@ categories_preferred_order = ( "New Feature", "Performance Improvement", "Improvement", + "Critical Bug Fix", "Bug Fix", "Build/Testing/Packaging Improvement", "Other", @@ -112,7 +113,7 @@ def get_descriptions(prs: PullRequests) -> Dict[str, List[Description]]: in_changelog = merge_commit in SHA_IN_CHANGELOG if in_changelog: desc = generate_description(pr, repos[repo_name]) - if desc is not None: + if desc: if desc.category not in descriptions: descriptions[desc.category] = [] descriptions[desc.category].append(desc) @@ -187,7 +188,7 @@ def parse_args() -> argparse.Namespace: # This function mirrors the PR description checks in ClickhousePullRequestTrigger. -# Returns False if the PR should not be mentioned changelog. +# Returns None if the PR should not be mentioned in changelog. def generate_description(item: PullRequest, repo: Repository) -> Optional[Description]: backport_number = item.number if item.head.ref.startswith("backport/"): From a85860408438b64acb8edf155ed78475b26bd069 Mon Sep 17 00:00:00 2001 From: Max K Date: Tue, 28 May 2024 13:10:14 +0200 Subject: [PATCH 3/4] CI: remove category check from lambda --- .../cancel_and_rerun_workflow_lambda/app.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/ci/cancel_and_rerun_workflow_lambda/app.py b/tests/ci/cancel_and_rerun_workflow_lambda/app.py index 9ee884c801a..578ade5c8a0 100644 --- a/tests/ci/cancel_and_rerun_workflow_lambda/app.py +++ b/tests/ci/cancel_and_rerun_workflow_lambda/app.py @@ -9,7 +9,7 @@ from threading import Thread from typing import Any, Dict, List, Optional import requests -from lambda_shared.pr import Labels, check_pr_description +from lambda_shared.pr import Labels from lambda_shared.token import get_cached_access_token NEED_RERUN_OR_CANCELL_WORKFLOWS = { @@ -321,21 +321,21 @@ def main(event): return if action == "edited": - print("PR is edited, check if the body is correct") - error, _ = check_pr_description( - pull_request["body"], pull_request["base"]["repo"]["full_name"] - ) - if error: - print( - f"The PR's body is wrong, is going to comment it. The error is: {error}" - ) - post_json = { - "body": "This is an automatic comment. The PR descriptions does not " - f"match the [template]({pull_request['base']['repo']['html_url']}/" - "blob/master/.github/PULL_REQUEST_TEMPLATE.md?plain=1).\n\n" - f"Please, edit it accordingly.\n\nThe error is: {error}" - } - _exec_post_with_retry(pull_request["comments_url"], token, json=post_json) + print("PR is edited - do nothing") + # error, _ = check_pr_description( + # pull_request["body"], pull_request["base"]["repo"]["full_name"] + # ) + # if error: + # print( + # f"The PR's body is wrong, is going to comment it. The error is: {error}" + # ) + # post_json = { + # "body": "This is an automatic comment. The PR descriptions does not " + # f"match the [template]({pull_request['base']['repo']['html_url']}/" + # "blob/master/.github/PULL_REQUEST_TEMPLATE.md?plain=1).\n\n" + # f"Please, edit it accordingly.\n\nThe error is: {error}" + # } + # _exec_post_with_retry(pull_request["comments_url"], token, json=post_json) return if action == "synchronize": From a15db7b40099a797c69991965afff2b1ffdf41f4 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 28 May 2024 11:16:44 +0000 Subject: [PATCH 4/4] Automatic style fix --- tests/ci/lambda_shared_package/lambda_shared/pr.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/ci/lambda_shared_package/lambda_shared/pr.py b/tests/ci/lambda_shared_package/lambda_shared/pr.py index 2a396859850..e981e28a454 100644 --- a/tests/ci/lambda_shared_package/lambda_shared/pr.py +++ b/tests/ci/lambda_shared_package/lambda_shared/pr.py @@ -86,9 +86,7 @@ LABEL_CATEGORIES = { "Bug Fix (user-visible misbehaviour in official stable or prestable release)", "Bug Fix (user-visible misbehavior in official stable or prestable release)", ], - "pr-critical-bugfix": [ - "Critical Bug Fix (crash, LOGICAL_ERROR, data loss, RBAC)" - ], + "pr-critical-bugfix": ["Critical Bug Fix (crash, LOGICAL_ERROR, data loss, RBAC)"], "pr-build": [ "Build/Testing/Packaging Improvement", "Build Improvement",