diff options
Diffstat (limited to '.github/scripts')
3 files changed, 52 insertions, 8 deletions
diff --git a/.github/scripts/analytics/data_mart_queries/perfomance_olap_mart.sql b/.github/scripts/analytics/data_mart_queries/perfomance_olap_mart.sql index a56b3574cac..0aa77deae3a 100644 --- a/.github/scripts/analytics/data_mart_queries/perfomance_olap_mart.sql +++ b/.github/scripts/analytics/data_mart_queries/perfomance_olap_mart.sql @@ -132,12 +132,12 @@ SELECT WHEN Db LIKE '%static-node-1.ydb-cluster.com/Root/db%' THEN 'ansible_' WHEN Db LIKE '%ydb-vla-dev04-002%' THEN 'oltp-vla-perf1_' WHEN Db LIKE '%ydb-vla-dev04-005%' THEN 'oltp-vla-perf2_' - WHEN Db LIKE '%ydb-qa-01-klg-010%' THEN 'oltp-klg-perf3_' + WHEN Db LIKE '%ydb-qa-01-klg-015%' THEN 'oltp-klg-perf3_' WHEN Db LIKE '%ydb-qa-01-klg-014%' THEN 'oltp-klg-perf4_' - WHEN Db LIKE '%ydb-qa-01-klg-018%' THEN 'oltp-klg-perf5_' + WHEN Db LIKE '%ydb-qa-01-klg-022%' THEN 'oltp-klg-perf5_' WHEN Db LIKE '%ydb-qa-01-sas-000%' THEN 'oltp-3dc-perf6_' - WHEN Db LIKE '%ydb-qa-01-klg-021%' THEN 'oltp-klg-perf7_' - WHEN Db LIKE '%ydb-qa-01-klg-030%' THEN 'oltp-klg-perf9_' + WHEN Db LIKE '%ydb-qa-01-klg-035%' THEN 'oltp-klg-perf7_' + WHEN Db LIKE '%ydb-qa-01-klg-021%' THEN 'oltp-klg-perf9_' WHEN Db LIKE '%sas%' THEN 'sas_' WHEN Db LIKE '%vla%' THEN 'vla_' WHEN Db LIKE '%klg%' THEN 'klg_' diff --git a/.github/scripts/analytics/data_mart_queries/perfomance_olap_suites_mart.sql b/.github/scripts/analytics/data_mart_queries/perfomance_olap_suites_mart.sql index 9eb51df5577..a09a80d0ee1 100644 --- a/.github/scripts/analytics/data_mart_queries/perfomance_olap_suites_mart.sql +++ b/.github/scripts/analytics/data_mart_queries/perfomance_olap_suites_mart.sql @@ -141,12 +141,12 @@ SELECT WHEN s.Db LIKE '%static-node-1.ydb-cluster.com/Root/db%' THEN 'ansible_' WHEN s.Db LIKE '%ydb-vla-dev04-002%' THEN 'oltp-vla-perf1_' WHEN s.Db LIKE '%ydb-vla-dev04-005%' THEN 'oltp-vla-perf2_' - WHEN s.Db LIKE '%ydb-qa-01-klg-010%' THEN 'oltp-klg-perf3_' + WHEN s.Db LIKE '%ydb-qa-01-klg-015%' THEN 'oltp-klg-perf3_' WHEN s.Db LIKE '%ydb-qa-01-klg-014%' THEN 'oltp-klg-perf4_' - WHEN s.Db LIKE '%ydb-qa-01-klg-018%' THEN 'oltp-klg-perf5_' + WHEN s.Db LIKE '%ydb-qa-01-klg-022%' THEN 'oltp-klg-perf5_' WHEN s.Db LIKE '%ydb-qa-01-sas-000%' THEN 'oltp-3dc-perf6_' - WHEN s.Db LIKE '%ydb-qa-01-klg-021%' THEN 'oltp-klg-perf7_' - WHEN s.Db LIKE '%ydb-qa-01-klg-030%' THEN 'oltp-klg-perf9_' + WHEN s.Db LIKE '%ydb-qa-01-klg-035%' THEN 'oltp-klg-perf7_' + WHEN s.Db LIKE '%ydb-qa-01-klg-021%' THEN 'oltp-klg-perf9_' WHEN s.Db LIKE '%sas%' THEN 'sas_' WHEN s.Db LIKE '%vla%' THEN 'vla_' WHEN s.Db LIKE '%klg%' THEN 'klg_' diff --git a/.github/scripts/cherry_pick_v2.py b/.github/scripts/cherry_pick_v2.py index f1a4aee609d..6efa79cb906 100755 --- a/.github/scripts/cherry_pick_v2.py +++ b/.github/scripts/cherry_pick_v2.py @@ -56,6 +56,10 @@ class BackportResult: return len(self.conflict_files) > 0 +class ChangesAlreadyAppliedError(Exception): + """Raised when all requested commits are already present in the target branch.""" + + def run_git(repo_path: str, cmd: List[str], logger, check=True) -> subprocess.CompletedProcess: """Run git command""" result = subprocess.run( @@ -132,6 +136,15 @@ def create_pr_source(pull: Any, allow_unmerged: bool, logger) -> Source: ) +def is_empty_cherry_pick(output: str) -> bool: + """Detects git empty cherry-pick when patch is already present in the branch.""" + output_lower = output.lower() + return ( + 'now empty' in output_lower + or 'nothing added to commit' in output_lower + ) + + def detect_conflicts(repo_path: str, logger) -> List[ConflictInfo]: """Detects conflicts from git status""" conflict_files = [] @@ -494,6 +507,17 @@ def process_branch( output = (result.stdout or '') + (('\n' + result.stderr) if result.stderr else '') if result.returncode != 0: + if is_empty_cherry_pick(output): + run_git(repo_path, ['cherry-pick', '--skip'], logger, check=False) + logger.info( + "Commit %s is already present in %s, skipping", + commit_sha[:7], target_branch + ) + cherry_pick_logs.append( + f"=== Cherry-picking {commit_sha[:7]} ===\n" + f"Skipped: changes already present in branch\n{output}" + ) + continue if "conflict" in output.lower(): conflicts = detect_conflicts(repo_path, logger) if conflicts: @@ -510,6 +534,20 @@ def process_branch( cherry_pick_logs.append(f"=== Cherry-picking {commit_sha[:7]} ===\n{output}") except subprocess.CalledProcessError as e: raise RuntimeError(f"Cherry-pick failed for commit {commit_sha[:7]}: {e}") + + ahead_result = run_git( + repo_path, ['rev-list', '--count', f'{target_branch}..HEAD'], logger, check=False + ) + if ahead_result.returncode != 0: + raise RuntimeError( + f"Failed to count commits ahead of {target_branch}: " + f"{(ahead_result.stderr or ahead_result.stdout or '').strip()}" + ) + commits_ahead = int((ahead_result.stdout or '0').strip() or 0) + if commits_ahead == 0: + raise ChangesAlreadyAppliedError( + f"All requested changes are already present in {target_branch}" + ) # Push branch run_git(repo_path, ['push', '--set-upstream', 'origin', dev_branch_name], logger) @@ -781,6 +819,12 @@ def main(): repo_name, repo, token, sources, workflow_triggerer, workflow_url, summary_path, logger ) results.append(result) + except ChangesAlreadyAppliedError as e: + logger.info("Branch %s skipped: %s", target_branch, e) + if summary_path: + with open(summary_path, 'a') as f: + f.write(f"Branch `{target_branch}`: skipped (changes already present)\n\n") + skipped_branches.append((target_branch, "changes already present")) except Exception as e: has_errors = True error_msg = f"UNEXPECTED_ERROR: Branch {target_branch} - {type(e).__name__}: {e}" |
