Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also show warnings when PRs are updated #1901

Merged
merged 1 commit into from
Apr 7, 2025

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Feb 9, 2025

This PR tweaks the assign handler to also show warnings when PRs are updated, instead of just doing it when a PR is opened.

Fixes #1831
r? @ehuss

@Urgau Urgau force-pushed the warnings-on-synchronize branch from 7e5fac3 to 0e2641e Compare February 9, 2025 10:46
@ehuss
Copy link
Contributor

ehuss commented Feb 9, 2025

This looks like it will warn on every push, is that right? If possible I'd like to avoid that (maybe with IssueData?).

@Urgau
Copy link
Member Author

Urgau commented Feb 10, 2025

That's a good observation, it would indeed post unnecessary comments.

As suggested I have used IssueData with some state to keep track of the last warnings to avoid posting unnecessary comments. I haven't tested it, but it's very similar to the other avoid comment logic.

@Urgau Urgau force-pushed the warnings-on-synchronize branch from 8054910 to b66a8b6 Compare March 22, 2025 15:29
@Kobzol
Copy link
Contributor

Kobzol commented Mar 27, 2025

Hmm, it's quite weird in the first place that a handler called assign is handling warnings about modified submodules 😅 Since triagebot doesn't try to send the welcome/assignment and warning messages in a single comment, I think that we should split the logic here.

Keep welcoming and initial assignment in the assign.rs handler (which will still only run on Open), and then create a separate handler for checking the commits of a PR (that would run on Open and Synchronize), that would check:

  • submodules
  • merge commits
  • mentions

As I proposed here. What do you think?

@Urgau
Copy link
Member Author

Urgau commented Mar 27, 2025

I agree it would be good to split the submodule warning logic outside of the assign handler. I think it was done their out of convenience since their is already a diff operation going on inside it.

As for a single "commits" handler I fear it will become too complex quickly with the different pre-conditions of each handler. What about keeping them as different handlers but with a simple lazy loading of the commits, that way each handler continues to do it's own thing and we don't unnecessarily fetch the commits multiple times.

As for the submodules warnings it only works only on the PR diff, not commits. We could also create a lazy loading of the diff.

@Kobzol
Copy link
Contributor

Kobzol commented Mar 28, 2025

I think that we could do a single "check_commits" handler that would have several sub-responsibilities (checking submodules, mentions and merge commits), that could also make it more discoverable to figure out where we check commits (I certainly wouldn't look for submodule changes in the assign handler, lol). It's not so much about the used API (diff vs commit list), but rather about related functionality, which could live at a single place. It would also help with removing some of the duplication of PR status checks (e.g. draft and PR title). It's weird if checking merge commits doesn't trigger when you have a WIP PR title, but no_mentions triggers in that situation, that's quite inconsistent..

On the other hand, that would be a bit of a larger change. We can just keep the status quo, as always.

In terms of performance, rather than doing lazy loading, I would create some "per-event context" that is filled when the various handlers are executed. In other words, when handling a single event and threading it through many handlers, the first time something calls ".commits()", they will be loaded from GH and cached. The second time something calls ".commits()", they would be loaded from memory. If we only keep the cache for a specific GH event and don't persist it further, there should be no invalidation problems (it would even help keep the behavior of the individual handlers more consistent, as in theory the GH state can change in between the execution of two handlers on the same webhook event).

(Edit: the caching above is not blocking for this or no_mentions, it's just an idea. In practice the perf. will probably be fine.)

@Urgau
Copy link
Member Author

Urgau commented Apr 1, 2025

Sure, seems fine to parent handler which would have many sub-responsibility, it would even share the logic for printing the warnings, hidden them, checking the draft status, ... I like that.

In terms of how to proceed, what about?

  1. Creation of the check_commits handler and moving of "submodules" and "non-default-branch"
  2. Rebase this PR to be in the check_commits handler (their by introducing hidding and synchronize)
  3. Move the "merge commits" checks into check_commits handler
  4. Add the "mentions" checks within the check_commits handler (tbd in Add no GitHub mentions in commits handler #1917)
  5. Add caching/per-event context

@Kobzol
Copy link
Contributor

Kobzol commented Apr 2, 2025

I didn't want to block this functionality on that refactoring, but I'm willing to review it quickly, and help with the implementation if needed, so hopefully it shouldn't take long. I'm also working now on extending the test suite to give us the ability to actually test the issue handlers, but that does not need to block this refactor.

That plan sounds good!

@Urgau Urgau force-pushed the warnings-on-synchronize branch from b66a8b6 to 507cc27 Compare April 5, 2025 10:05
@Urgau
Copy link
Member Author

Urgau commented Apr 5, 2025

Rebased on top of #1922, the logic is now in the check_commits handler.

Copy link
Contributor

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

For warn_non_default_branch, we should also be checking the PR edited event, but I don't think that's super important, as it should be very rare to "repoint" a PR to a different base branch after it has been created. The important event is Synchronize for the submodules, because that happens quite often, so it would be nice to warn about it.

@Urgau Urgau added this pull request to the merge queue Apr 7, 2025
Merged via the queue into rust-lang:master with commit cc054e0 Apr 7, 2025
3 checks passed
@Urgau Urgau deleted the warnings-on-synchronize branch April 7, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modified submodules are only warned about on PR creation
3 participants