Skip to content

Comments

Add backport reminder and reorganize the backporting actions.#889

Merged
NickDris merged 37 commits intoelastic:masterfrom
NickDris:backport/reminder
Nov 21, 2025
Merged

Add backport reminder and reorganize the backporting actions.#889
NickDris merged 37 commits intoelastic:masterfrom
NickDris:backport/reminder

Conversation

@NickDris
Copy link
Contributor

@NickDris NickDris commented Oct 15, 2025

Introducing backport.py script that interacts with GH API to

  • Label merged PRs lacking a 'backport pending' or a version vX(.Y) label.
  • Post a backporting reminder as a comment in the PR.

Github Workflow changes:

  • Backporting action is separated from the rest of backporting, like it was initially.
  • Backporting reminder and labeler added in a workflow that can be also run manually.

Backport reminder workflow:

  • Mainly uses backport.py to add labels and post reminders in merged PRs.
  • Runs either on schedule, manually or on closing PR, discerning the mode of operation
    with the github.event_name.
  • Based on the mode of operation, backport.py either processes a single PR, or
    fetches the list of PRs, merged the last X days from GH API
  • Checking PR merged status is made inside backport.py.

Inputs:

  • lookback_days: Look for merged PRs within a lookback window.
  • pending_label_age_days: Post reminder based on how old is the last reminder.

@NickDris
Copy link
Contributor Author

NickDris commented Oct 16, 2025

This needs a bit of optimization, in order to apply the DRY principle, as the functionality added in #888 has some significant overlaps.
Please wait before reviewing it.

* Add a backport reminder for unbackported commits

* Add direnv to .gitignore

* Simplify logic and comments

* Fixed linting issue

* Unify label and reminder logic to one module
@NickDris NickDris requested review from fressi-elastic and gbanasiak and removed request for fressi-elastic and gbanasiak October 17, 2025 11:37
@NickDris NickDris changed the title Add backport reminder Add backport reminder and reorganize the backporting actions. Oct 17, 2025
Copy link
Contributor

@gbanasiak gbanasiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial high-level feedback/questions:

  1. Having a CLI tool which can be used in GH actions as well as independently is a great idea.
  2. A dry-run option is highly recommended. It would allow for testing (part of PR review).
  3. Token should not be passed through command-line option, see below.
  4. The tool uses standard libraries only it seems. Is this intentional? Example: why argparse and not something newer, like click?
  5. backport.action.yml still references scripts/backport-pending.py which gets removed.

@NickDris
Copy link
Contributor Author

NickDris commented Oct 20, 2025

All of the review comments were much help. --dry-run added, --token removed and coded to be set only through the environment and backport.action.yml cleaned.
Using click instead of argparse was a pretty good idea, since it is in alignment with our other tools, I followed that.
I also added logging and provided a --debug option, which for now prints the Github API calls.
Thanks a lot for reviewing @gbanasiak

@NickDris NickDris requested a review from gbanasiak October 20, 2025 13:56
Copy link
Contributor

@gbanasiak gbanasiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for these exhaustive tests. Personally I do find some of them too complex to follow easily. One thing that really adds to the complexity is the attempt to verify entire sequences of GH API calls. I think I would keep this simpler looking for key API call depending on the test case. But that's fine, let's not spend more time simplifying these.

I'd like to request the following 2 changes:

  • change filtering logic for reminders - they should apply to PRs with backport pending label
  • make newly added tests discoverable by pytest (and hatch -v -e unit run test), they are currently not covered; the problem is all .* folders are by default excluded from pytest due to default norecursedirs setting (doc) - my suggestion would be to rename .ci to tools and remove scripts sub-dir (tools/scripts seems redundant now, we only have 2 scripts); we also need an extra __init__.py file under tools to make pytest happy

Reminder comments will accumulate in time, especially in case of PRs waiting for the first supported release. It would be nice to remove older comments after adding a new one.

There's a bunch of static type checker (mypy) failures. I've started mentioning them in review but gave up quickly. I recommend using type checker integrated with IDE for now.

My heart sank for a moment when looking at dry-run outputs. I haven't noticed this earlier :)

# these print-outs do not mention dry-run and "added" suggests it was already done
% ./tools/scripts/backport.py --dry-run --repo=elastic/rally-tracks label --lookback-days=7 
2025-11-18 17:21:29,111 INFO __main__ Added label 'backport pending' to PR #917
2025-11-18 17:21:29,112 INFO __main__ Added label 'backport pending' to PR #916
2025-11-18 17:21:29,112 INFO __main__ Added label 'backport pending' to PR #915
2025-11-18 17:21:29,112 INFO __main__ Added label 'backport pending' to PR #904

# this output sometimes says "would" which is nice but mixes this with "posted", confusing
% ./tools/scripts/backport.py --dry-run --repo=elastic/rally-tracks remind --lookback-days=7
2025-11-18 17:27:36,473 INFO __main__ prefetched=12 lookback_days=7 pending_reminder_age_days=7 now=2025-11-18T16:27:36.473747+00:00 threshold=2025-11-11T16:27:36.473747+00:00
2025-11-18 17:27:36,802 INFO __main__ Would post comment to PR #918
2025-11-18 17:27:36,802 INFO __main__ PR #918: initial reminder posted
2025-11-18 17:27:36,802 INFO __main__ PR #917: cooling period not elapsed)
2025-11-18 17:27:36,802 INFO __main__ PR #916: cooling period not elapsed)
2025-11-18 17:27:36,802 INFO __main__ PR #915: cooling period not elapsed)
2025-11-18 17:27:37,146 INFO __main__ Would post comment to PR #911
2025-11-18 17:27:37,146 INFO __main__ PR #911: initial reminder posted
2025-11-18 17:27:37,491 INFO __main__ Would post comment to PR #910
2025-11-18 17:27:37,491 INFO __main__ PR #910: initial reminder posted
2025-11-18 17:27:37,810 INFO __main__ Would post comment to PR #909
2025-11-18 17:27:37,811 INFO __main__ PR #909: initial reminder posted
2025-11-18 17:27:38,212 INFO __main__ Would post comment to PR #908
2025-11-18 17:27:38,212 INFO __main__ PR #908: initial reminder posted
2025-11-18 17:27:38,656 INFO __main__ Would post comment to PR #907
2025-11-18 17:27:38,657 INFO __main__ PR #907: initial reminder posted
2025-11-18 17:27:38,657 INFO __main__ PR #904: cooling period not elapsed)
2025-11-18 17:27:39,065 INFO __main__ Would post comment to PR #902
2025-11-18 17:27:39,065 INFO __main__ PR #902: initial reminder posted
2025-11-18 17:27:39,455 INFO __main__ Would post comment to PR #898
2025-11-18 17:27:39,455 INFO __main__ PR #898: initial reminder posted

Copy link
Contributor

@fressi-elastic fressi-elastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the filing that this PR got lot of unnecessary complexity and technical debt just because we didn't reused pre-existing 3rd party code [1]. It is nice to write code to learn and get code reviewed to be able to exchange ideas and experiences. But for something like this I would have preferred using a pre-existing library. It would have been much less work than writing (and testing) this code. Given the quality of the code of this PR is not very critical to me it LGTM but please read my comments so you can do different the next time (I hope I am not been rude, it has never been my intention).

[1] https://github.com/PyGithub/PyGithub

@gbanasiak
Copy link
Contributor

@fressi-elastic

I have the filing that this PR got lot of unnecessary complexity and technical debt just because we didn't reused pre-existing 3rd party code

Extra context: We've been there before with discussion around click. The decision was taken to use standard Python library only. It eliminates extra dependencies in GH workflows using this script.

@NickDris
Copy link
Contributor Author

@elasticmachine update branch

@elasticmachine
Copy link
Contributor

merge conflict between base and head

@NickDris
Copy link
Contributor Author

I have the filing that this PR got lot of unnecessary complexity and technical debt just because we didn't reused pre-existing 3rd party code [1]. It is nice to write code to learn and get code reviewed to be able to exchange ideas and experiences. But for something like this I would have preferred using a pre-existing library. It would have been much less work than writing (and testing) this code. Given the quality of the code of this PR is not very critical to me it LGTM but please read my comments so you can do different the next time (I hope I am not been rude, it has never been my intention).

[1] https://github.com/PyGithub/PyGithub

Nothing rude about it. I do have the same expectations from myself in the future but it's a learning process and you are actually helping it. Thank you .
I will read your comments carefully and change some parts that I consider critical.

Copy link
Contributor

@gbanasiak gbanasiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I've left final cosmetic changes after testing

Co-authored-by: Grzegorz Banasiak <grzegorz.banasiak@elastic.co>
@NickDris NickDris merged commit ce1de79 into elastic:master Nov 21, 2025
15 checks passed
@NickDris NickDris deleted the backport/reminder branch November 21, 2025 17:41
gbanasiak pushed a commit to gbanasiak/rally-tracks that referenced this pull request Dec 5, 2025
…c#889)

Refactored backport cli to include all requirements existing at the moment for 
automated backporting of PRs. 

Supporting label and remind commands and --dry-run for testing.
@gbanasiak gbanasiak added the v9.2 label Dec 5, 2025
@esbenchmachine
Copy link
Collaborator

💚 All backports created successfully

Status Branch Result
9.2

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

esbenchmachine added a commit that referenced this pull request Dec 9, 2025
…951)

Refactored backport cli to include all requirements existing at the moment for
automated backporting of PRs.

Supporting label and remind commands and --dry-run for testing.

(cherry picked from commit ce1de79)

Co-authored-by: Nick Dris <nick.dris@elastic.co>
NickDris added a commit to NickDris/rally-tracks that referenced this pull request Dec 10, 2025
…c#889)

Refactored backport cli to include all requirements existing at the moment for
automated backporting of PRs.

Supporting label and remind commands and --dry-run for testing.
NickDris added a commit that referenced this pull request Dec 12, 2025
Refactored backport cli to include all requirements existing at the moment for
automated backporting of PRs.

Supporting label and remind commands and --dry-run for testing.
NickDris added a commit that referenced this pull request Dec 12, 2025
Refactored backport cli to include all requirements existing at the moment for
automated backporting of PRs.

Supporting label and remind commands and --dry-run for testing.
NickDris added a commit to NickDris/rally-tracks that referenced this pull request Dec 18, 2025
…c#889)

Refactored backport cli to include all requirements existing at the moment for
automated backporting of PRs.

Supporting label and remind commands and --dry-run for testing.
NickDris added a commit to NickDris/rally-tracks that referenced this pull request Dec 18, 2025
…c#889)

Refactored backport cli to include all requirements existing at the moment for
automated backporting of PRs.

Supporting label and remind commands and --dry-run for testing.
NickDris added a commit that referenced this pull request Dec 20, 2025
* Tests tracks selectively based on PR changes (#858)
* CI builds ES revision from sources based on es-version file (#875)
* Drop Python 3.9 and introduce Python 3.13 in CI (#877)
* [ES-13188] Update GH macOS hosted runner image (#883)
* Address pytest deprecations (#911)
* CI determines Elasticsearch build arguments using unified job in gh workflow [stateful] (#925)
* Fix an error where ci arguments were not applied properly (#928)
* Fix an error where ci arguments were not applied properly
* Test the change
* Test failed retry with another fix
* Previous fix failed retry
* Revert es-version to current
* Keep the indents if if/else
* Add backport reminder and reorganize the backporting actions. (#889)
* Rename IT folders (#938)
* Fix pytest skip argument (#905)
* Backport reminders - fix missing default values in workflow (#947)
* Upgrade pip to 25.2
* Fix conflict in it_tracks
* Update deprecated gh actions
* Track changes for 8.19
* Fix test job which does not require the output of other jobs
* Add backport reminder and reorganize the backporting actions. (#889)
* Fix an error where ci arguments were not applied properly (#928)
* Reduce filtering scope in CI workflow (#908)
* Add pytest marker for cars
* Address merge conflicts
* Run serverless CI only on PRs targeting master (#859)
* Accept pragma risks for joins esql
* Make esql-full-text-functions a snapshot_only_challenge
* Set index template for ingest_mode: data_stream (#849)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants