Skip to content

Commit

Permalink
Force auto backport workflow
Browse files Browse the repository at this point in the history
Currently if a PR that is elegible for backporting touches a workflow
file then the automatic backport fails.

Now adding the label `force-auto-backport-workflow` to a PR that touches
workflow files will proceed with the automatic backporting. This is
useful because sometimes we need to fix a workflow and backport it to
the current release branch or when we're adding support to a new
Postgres major version that requires workflow changes and it should be
backported to the release branch in case of creating patch releases.
  • Loading branch information
fabriziomello committed Oct 24, 2024
1 parent 946e9b7 commit 04f0b47
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions scripts/backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ def should_backport_by_labels(number, title, labels):
)
return False

force_labels = labels.intersection(["bug", "force-auto-backport"])
force_labels = labels.intersection(
["bug", "force-auto-backport", "force-auto-backport-workflow"]
)
if force_labels:
print(
f"#{number} '{title}' is labeled as '{list(force_labels)[0]}' which requests automated backporting."
Expand Down Expand Up @@ -433,13 +435,22 @@ def report_backport_not_done(original_pr, reason, details=None):
for filename in changed_files
if filename.startswith(".github/workflows/")
}

if changed_workflow_files:
details = (
f"The PR touches a workflow file '{list(changed_workflow_files)[0]}' "
" and cannot be backported automatically"
pull_labels = {label.name for label in original_pr.labels}
force_workflow_label = pull_labels.intersection(
["force-auto-backport-workflow"]
)
if not force_workflow_label:
details = (
f"The PR touches a workflow file '{list(changed_workflow_files)[0]}' "
" and cannot be backported automatically"
)
report_backport_not_done(original_pr, "backport failed", details)
continue
print(
f"PR #{original_pr.number} '{original_pr.title}' touches a workflow file, but will be backported anyway."
)
report_backport_not_done(original_pr, "backport failed", details)
continue

# Push the backport branch.
git_check(f"push --quiet {target_remote} @:refs/heads/{backport_branch}")
Expand Down

0 comments on commit 04f0b47

Please sign in to comment.