29 Commits

Author SHA1 Message Date
Yaron Kaikov
d3e199984e auto-backport.py: modify instruction for making PR ready for review
Update the comment sent when PR has conflicts with clear instrauctions how to make the PR Ready for review

Fixes: https://scylladb.atlassian.net/browse/RELENG-152

Closes scylladb/scylladb#27547
2025-12-10 14:53:38 +02:00
Yaron Kaikov
3ade3d8f5b auto-backport: Add support for JIRA issue references
- Added support for JIRA issue references in PR body and commit messages
- Supports both short format (PKG-92) and full URL format
- Maintains existing GitHub issue reference support
- JIRA pattern matches https://scylladb.atlassian.net/browse/{PROJECT-ID}
- Allows backporting for PRs that reference JIRA issues with 'fixes' keyword

Fixes: https://github.com/scylladb/scylladb/issues/26955

Closes scylladb/scylladb#26954
2025-11-12 08:15:06 +02:00
Yaron Kaikov
b07505a314 auto-backport.py: sync P0 and P1 labels when applied
When triggering the backport process, adding a check for P0 and P1 labels, if available add them to backport PR together with force_on_cloud label

Implementing first in pkg to test the process, then will move it to scylladb

Fixes: PKG-62

Closes scylladb/scylladb#25856
2025-09-08 11:42:36 +03:00
Yaron Kaikov
c0fd3deeab github: Enhance label sync to support P0/P1 priority labels
Extend the existing label synchronization system to handle P0 and P1
priority labels in addition to backport/* labels:

- Add P0/P1 label syncing between issues and PRs bidirectionally
- Automatically add 'force_on_cloud' label to PRs when P0/P1 labels
  are present (either copied from issues or added directly)

The workflow now triggers on P0 and P1 label events in addition to
backport/* labels, ensuring priority labels are properly reflected
across the entire PR lifecycle.

Refs: https://github.com/scylladb/scylla-pkg/issues/5383

Closes scylladb/scylladb#25604
2025-08-22 06:50:13 +03:00
Yaron Kaikov
ed7c7784e4 auto-backport.py: Avoid bot push to existing backport branches
Changed the backport logic so that the bot only pushes the backport branch if it does not already exist in the remote fork.
If the branch exists, the bot skips the push, allowing only users to update (force-push) the branch after the backport PR is open.

Fixes: https://github.com/scylladb/scylladb/issues/24953

Closes scylladb/scylladb#24954
2025-07-14 11:20:23 +03:00
Yaron Kaikov
b375222408 ./github/scripts/auto-backport.py: don't remove backport label when backport process has an error
Today, when the `Fixes` prefix is missing or the developer is not a collaborator with `scylladbbot` we remove the backport labels to prevent the process from starting and notifying the developers.

Developers are worried that removing these backport labels will cause us to forget we need to do these backports. @nyh suggested to add a `scylladbbot/backport_error` label instead

Applied those changes, so when a `Fixes` prefix is missing we will add a `scylladbbot/backport_error` label and stop the process

When a user doesn't accept the invite we will still open the PR but he will not be assigned and will not be able to edit the branch when we have conflicts

Fixes: https://github.com/scylladb/scylla-pkg/issues/4898
Fixes: https://github.com/scylladb/scylla-pkg/issues/4897

Closes scylladb/scylladb#23259
2025-03-18 16:19:09 +02:00
Yaron Kaikov
084f4d2ee3 .github/scripts/auto-backport.py: search for Fixes also in commits
In #22650 the backport process wasn't completed since the PR body didn't include the Fixes ref as expected but the commits did have it

Expanding the search for `Fixes` to include commits in the same PR

Fixes: https://github.com/scylladb/scylla-pkg/issues/4899

Closes scylladb/scylladb#22988
2025-02-23 13:20:28 +02:00
Kefu Chai
5443d9dabb .github: add check-license-header workflow
this workflow checks the first 10 lines for
"LicenseRef-ScyllaDB-Source-Available-1.0" in newly introduced files
when a new pull request is created against "master" or "next".

if "LicenseRef-ScyllaDB-Source-Available-1.0" is not found, the
workflow fails. for the sake of simplicity, instead of parsing the
header for SPDX License ID, we just check to see if the
"LicenseRef-ScyllaDB-Source-Available-1.0" is included.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#22065
2025-02-06 12:20:23 +03:00
Yaron Kaikov
bc487c9456 .github: cherry-pick each commit instead of merge commit when available
Until today, when we had a PR with multiple commits we cherry-pick the merge commit only, which created a PR with only one commit (the merge commit) with all relevant changes

This was causing an issue when there was a need to backport part of the commits like in https://github.com/scylladb/scylladb/pull/21990 (reported by @gleb-cloudius)

Changing the logic to cherry-pick each commit

Closes scylladb/scylladb#22027
2024-12-26 13:10:18 +02:00
Yaron Kaikov
0fc7e786dd .github/scripts/auto-backport.py: fix wrong username param
In 2e6755ecca I have added a comment when PR has conflicts so the assignee can get a notification about it. There was a problem with the user mention param (a missing `.login`)

Fixing it

Closes scylladb/scylladb#22036
2024-12-25 20:41:34 +02:00
Yaron Kaikov
2e6755ecca .github/scripts/auto-backport.py: Add comment to PR when conflicts apply
When we open a PR with conflicts, the PR owner gets a notification about the assignment but has no idea if this PR is with conflicts or not (in Scylla it's important since CI will not start on draft PR)

Let's add a comment to notify the user we have conflicts

Closes scylladb/scylladb#21939
2024-12-16 14:17:40 +02:00
Yaron Kaikov
d9cde7cca5 .github/scripts/auto-backport.py: add user as collaborator to scylladbbot fork
As reported by @Deexie, during the process of opening backport PRs in https://github.com/scylladb/scylladb/pull/21616, No invite emails were sent, causing a lack of permissions for the backport PR branch

The check if `has_in_collaborators(pr.user.login)` was pointing to `scylladb/scylladb` instead of `scylladbbot/scylladb`, fixing it

I also moved the collaborator check to an early stage, before trying to open a backport PR

Closes scylladb/scylladb#21645
2024-11-20 14:34:38 +02:00
Yaron Kaikov
980f6a48ab .github/scripts/auto-backport.py: validate backport candidate with Fixes prefix
Adding `Fixes` validation to a PR when backport labels were added. When the auto backport process triggers (after promotion), we will ensure each PR with backport/x.y label also has in the PR body a `Fixes` reference to an issue

Fixes: https://github.com/scylladb/scylladb/issues/20021

Closes scylladb/scylladb#21563
2024-11-19 09:48:34 +02:00
Avi Kivity
bef015da0d Revert ".github/scripts/auto-backport.py: validate backport candidate with Fixes prefix"
This reverts commit 8414cd743e. It prevents
pulling pull requests that do have "Fixes" references.
2024-11-18 12:29:22 +02:00
Yaron Kaikov
8414cd743e .github/scripts/auto-backport.py: validate backport candidate with Fixes prefix
Adding `Fixes` validation to a PR when backport labels were added. When the auto backport process triggers (after promotion), we will ensure each PR with backport/x.y label also has in the PR body a `Fixes` reference to an issue

Adding also this validation to `pull_github_pr.sh` per @denesb request,

Fixes: https://github.com/scylladb/scylladb/issues/20021

Closes scylladb/scylladb#21563
2024-11-15 06:51:02 +02:00
Yaron Kaikov
3bc2b34a18 ./github/scripts/label_promoted_commits.py: fix search for closes prefix on merge PRs
In cc71077e33, i have added check for the
last line in pr body looking for `closes` prefix.

It seems that this is wrong, since in a merge PR, the `closes` prefix is
not the last line

Instead, changing the search for the last line contains `closes` prefix

Closes scylladb/scylladb#21545
2024-11-12 13:56:37 +02:00
Yaron Kaikov
cc71077e33 .github/scripts/label_promoted_commits.py: only match the Close tag in the last line in the commit message
When a backport PR is promoted to the release branch, we automatically close the backport PR (since GitHub will only close the one based on the default branch) and update the labels in the original PRs

In a situation when we have multiple `closes` prefixes, the script will use the first one (which is not the correct one), see 3ddb61c90e

Fixing this by always using the last line with the `closes` prefix

Closes scylladb/scylladb#21498
2024-11-11 11:04:33 +02:00
Yaron Kaikov
ef104b7b96 .github/scripts/auto-backport.py: update method to get closed prs
`commit.get_pulls()` in PyGithub returns pull requests that are directly associated with the given commit

Since in closed PR. the relevant commit is an event type, the backport
automation didn't get the PR info for backporting

Ref: https://github.com/scylladb/scylladb/issues/18973

Closes scylladb/scylladb#21468
2024-11-07 09:28:46 +02:00
Yaron Kaikov
77604b4ac7 .github/script/auto-backport.py: push backport PR to scylladbbot fork
Since Scylla is a public repo, when we create a fork, it doesn't fork the team and permissions (unlike private repos where it does).

When we have a backport PR with conflicts, the developers need to be able to update the branch to fix the conflicts. To do so, we modified the logic of the backport automation as follows:

- Every backport PR (with and without conflicts) will be open directly on the `scylladbbot` fork repo
- When there are conflicts, an email will be sent to the original PR author with an invitation to become a contributor in the `scylladbbot` fork with `push` permissions. This will happen only once if Auther is not a contributor.
- Together with sending the invite, all backport labels will be removed and a comment will be added to the original PR with instructions
- The PR author must add the backport labels after the invitation is accepted

Fixes: https://github.com/scylladb/scylladb/issues/18973

Closes scylladb/scylladb#21401
2024-11-06 14:29:37 +02:00
Kefu Chai
673b107ffa github: use GithubException when appropriate
`Exception` could be too general, what we really care about is
`GithubException`. so let's catch the latter instead for better
readability.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#21364
2024-10-31 18:21:29 +03:00
Yaron Kaikov
94a9efbf1c github: add script for backports automation instead of Mergify
Adding an auto-backport.py script to handle backport automation instead of Mergify.

The rules of backport are as follows:

* Merged or Closed PRs with any backport/x.y label (one or more) and promoted-to-master label
* Backport PR will be automatically assigned to the original PR author
* In case of conflicts the backport PR will be open in the original autoor fork in draft mode. This will give the PR owner the option to resolve conflicts and push those changes to the PR branch (Today in Scylla when we have conflicts, the developers are forced to open another PR and manually close the backport PR opened by Mergify)
* Fixing cherry-pick the wrong commit SHA. With the new script, we always take the SHA from the stable branch
* Support backport for enterprise releases (from Enterprise branch)

Fixes: https://github.com/scylladb/scylladb/issues/18973

Closes scylladb/scylladb#21302
2024-10-29 10:04:30 +02:00
Yaron Kaikov
e33126fc3e .github/script/label_promoted_commit.py: add label only if ref is PR
we got a failure during check-commit action:
```
Run python .github/scripts/label_promoted_commits.py --commit_before_merge 30e82a81e8 --commit_after_merge f31d5e3204 --repository scylladb/scylladb --ref refs/heads/master

Commit sha is: d5a149fc01
Commit sha is: 415457be2b
Commit sha is: d3b1ccd03a
Commit sha is: 1fca341514
Commit sha is: f784be6a7e
Commit sha is: 80986c17c3
Commit sha is: 492d0a5c86
Commit sha is: 7b3f55a65f
Commit sha is: 78d6471ce4
Commit sha is: 7a69d9070f
Commit sha is: a9e985fcc9
master branch, pr number is: 19213
Traceback (most recent call last):
  File "/home/runner/work/scylladb/scylladb/.github/scripts/label_promoted_commits.py", line 87, in <module>
    main()
  File "/home/runner/work/scylladb/scylladb/.github/scripts/label_promoted_commits.py", line 81, in main
    pr = repo.get_pull(pr_number)
  File "/usr/lib/python3/dist-packages/github/Repository.py", line 2746, in get_pull
    headers, data = self._requester.requestJsonAndCheck(
  File "/usr/lib/python3/dist-packages/github/Requester.py", line 353, in requestJsonAndCheck
    return self.__check(
  File "/usr/lib/python3/dist-packages/github/Requester.py", line 378, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/pulls/pulls#get-a-pull-request", "status": "404"}
Error: Process completed with exit code 1.
```

The reason for this failure is since in one of the promoted commits
(a9e985fcc9) had a reference of `Closes`
to an issue.

Fixes: https://github.com/scylladb/scylladb/issues/19677

Closes scylladb/scylladb#19678
2024-07-10 15:27:12 +03:00
Yaron Kaikov
efa94b06c2 .github/scripts/label_promoted_commits.py: fix adding labels when PR is closed
`prs = response.json().get("items", [])` will return empty when there are no merged PRs, and this will just skip the all-label replacement process.

This is a regression following the work done in #19442

Adding another part to handle closed PRs (which is the majority of the cases we have in Scylla core)

Fixes: https://github.com/scylladb/scylladb/issues/19441

Closes scylladb/scylladb#19497
2024-06-27 14:00:44 +03:00
Yaron Kaikov
394cba3e4b .github/workflow: close and replace label when backport promoted
Today after Mergify opened a Backport PR, it will stay open until someone manually close the backport PR , also we can't track using labels which backport was done or not since there is no indication for that except digging into the PR and looking for a comment or a commit ref

The following changes were made in this PR:
* trigger add-label-when-promoted.yaml also when the push was made to `branch-x.y`
* Replace label `backport/x.y` with `backport/x.y-done` in the original PR (this will automatically update the original Issue as well)
* Add a comment on the backport PR and close it

Fixes: https://github.com/scylladb/scylladb/issues/19441

Closes scylladb/scylladb#19442
2024-06-25 12:11:28 +03:00
Kefu Chai
c5601a749e github: sync_labels: do not error out if PR's cover letter is empty
if a pull request's cover letter is empty, `pr.body` is None. in that
case we should not try to pass it to `re.findall()` as the "string"
parameter. otherwise, we'd get

```
TypeError: expected string or bytes-like object, got 'NoneType'
```
so, in this change, we just return an empty list if the PR in question
has an empty cover letter.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#18125
2024-04-01 18:13:22 +03:00
Yaron Kaikov
5bd6b4f4c2 github: sync_labels: match issue number with better pattern
Seen in https://github.com/scylladb/scylladb/actions/runs/8357352616/job/22876314535

```
python .github/scripts/sync_labels.py --repo scylladb/scylladb --number 17309 --action labeled --label backport/none
  shell: /usr/bin/bash -e {0}
  env:
    GITHUB_TOKEN: ***

Found issue number: ('', '', '15465')
Traceback (most recent call last):
  File "/home/runner/work/scylladb/scylladb/.github/scripts/sync_labels.py", line 9[3](https://github.com/scylladb/scylladb/actions/runs/8357352616/job/22876314535#step:5:3), in <module>
    main()
  File "/home/runner/work/scylladb/scylladb/.github/scripts/sync_labels.py", line 89, in main
    sync_labels(repo, args.number, args.label, args.action, args.is_issue)
  File "/home/runner/work/scylladb/scylladb/.github/scripts/sync_labels.py", line [7](https://github.com/scylladb/scylladb/actions/runs/8357352616/job/22876314535#step:5:8)1, in sync_labels
    target = repo.get_issue(int(pr_or_issue_number))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'tuple'
Error: Process completed with exit code 1.
```

Fixing the pattern to catch all GitHub supported close keywords as
describe in https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword

Fixed: https://github.com/scylladb/scylladb/issues/17917
Fixed: https://github.com/scylladb/scylladb/issues/17921

Closes scylladb/scylladb#17920
2024-03-21 14:25:24 +02:00
Yaron Kaikov
d859067486 [action sync labels] improve pr search when labeling an issue
This PR contains few fixes and improvment seen during
https://github.com/scylladb/scylladb/issues/15902 label addtion

When we add a label to an issue, we go through all PR.
1) Setting PR base to `master` (release PR are not relevant)
2) Since for each Issue we have only one PR, ending the search after a
   match was found
3) Make sure to skip PR with empty body (mainly debug one)
4) Set backport label prefix to `backport/`

Closes scylladb/scylladb#17912
2024-03-20 12:14:42 +02:00
Yaron Kaikov
ad76f0325e [action] Sync labels from an Issue to linked PR
After merging https://github.com/scylladb/scylladb/pull/17365, all backport labels should be added to PR (before we used to add backport labels to the issues).

Adding a GitHub action which will be triggered in the following conditions only:

1) The base branch is `master` or `next`
2) Pull request events:
- opened: For every new PR that someone opens, we will sync all labels from the linked issue (if available)
- labeled: This role only applies to labels with the `backport/` prefix. When we add a new label for the backport we will update the relevant issue or PR to get them both to sync
- unlabeled: Same as `labeled` only applies to the `backport/` prefix. When we remove a label for backport we will update the relevant issue or pr

Closes scylladb/scylladb#17715
2024-03-19 09:17:07 +02:00
Yaron Kaikov
493327afd8 [action] Add promoted label when commits are in master
In Scylla, we don't merge our PR but use ./script/pull_github_pr.shto close the pull request, addingcloses scylladb/scylladb remark and push changes tonext` branch.
One of the conditions for opening a backport PR is that all relevant commits are in master (passed gating), in this GitHub action, we will go through the list of commits once a push was made to master and will identify the relevant PR, and add promoted label to it. This will allow Mergify to start the process of backporting
2024-02-25 11:56:50 +02:00