Skip to content

Conversation

@cheese-cakee
Copy link

@cheese-cakee cheese-cakee commented Dec 5, 2025

Description:
Updates the merge conflict detection workflow to recognize conflicts caused by updates to the main branch. Previously, the bot only notified users if the PR itself was updated, missing conflicts caused by external changes in main.

Changes:

  • Updated workflow triggers to detect when main updates.
  • Ensures users are notified of merge conflicts even if they haven't touched their PR recently.

Related issue(s):
Fixes #913

Notes for reviewer:
This addresses the edge case where a PR becomes conflicted due to changes in the base branch, ensuring the author is still notified.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

Hi @cheese-cakee
Great! Much better, I can work with this - nice one!

One issue I think is that we will never see a failed merge conflict workflow
Right now, you get an X if you have a merge conflict.

By extending it to loop through all issues on push to main, and not letting it fail, we are always going to pass that check, I think.

We want:
✅ If a PR has merge conflicts → its workflow run should fail
✅ If main is updated (push to main) → any PR that now conflicts should also fail in its workflow
✅ No duplicate bot commenting

How can we do that?

@cheese-cakee
Copy link
Author

Thanks for the feedback!

Here is my plan to address the three requirements:

For individual PRs: I'll make sure the script exits with an error code (exit 1) if a conflict is found. That will give us the red ❌ immediately on the PR.

For the loop on main: Since we don't want to fail the workflow running on main itself, I think the best move is to use the GitHub Status API to target the specific PR commit and mark it as failed.

For the spam: I'll simply add a check to scan for previous bot comments before posting a new one.

Please let me know what you think about this.

@exploreriii
Copy link
Contributor

excellent ideas!

@cheese-cakee
Copy link
Author

am i allowed to switch the implementation from the Bash script to actions/github-script

@exploreriii
Copy link
Contributor

if you are making big changes i would like it to be tested well please 👍

@cheese-cakee
Copy link
Author

I have refactored the logic to use actions/github-script and tested all edge cases in my fork.

Test Results:

PR Checks: Conflicted PRs correctly fail the workflow run (Red ❌) and receive a comment.

Push to Main: When a push occurs, the bot scans open PRs and updates their commit status to "Failure" via the API without failing the main workflow run.

No Spam: The bot checks for existing comments and does not double-post.
Screenshot 2025-12-05 231913
Screenshot 2025-12-05 230020
Screenshot 2025-12-05 225835

@cheese-cakee
Copy link
Author

cheese-cakee commented Dec 6, 2025

also if there are any new issues i would love to work on them ! @exploreriii

@exploreriii
Copy link
Contributor

I am reviewing this currently but we have 4 concurrent bot PRs to review.
Request help to review @MonaaEid @tech0priyanshu @AntonioCeppellini @Adityarya11 if available

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

Hi @cheese-cakee
Thank you for this - there are many good things here, and might solve the issue!

However you have refactored the logic almost entirely so we cannot go and assume this new bot will work

Therefore, the key thing if you do want to submit this, I want to see you test this on your origin fork

  1. merge it to main
  2. create a pull request 1 with a merge conflict - bot should post
  3. create a pull request 2 without a merge conflict - it should not post
  4. merge soemthing to main that causes a merge conflcit to pull request 2 - it should now post
  5. check maximum nubmer of merge conflict posts is 2

Unfortunately, there are quite a few things to test and it is important to do so otherwise we can risk spamming users and sending incorrect messages

Happy for you to go ahead with this issue if you'd like to do that, however, if you do not want to take on the full work (would be quite a bit to test) happy to reassign or even take it on myself.

@cheese-cakee
Copy link
Author

Hi @exploreriii and @MonaaEid , thanks a lot for the detailed feedback !

I definitely want to see this through and implement the refactor + testing myself. I agree that moving the logic to a script and running the 5-step test plan is the right move for stability.

If you agree, I will work on these changes and run the full test suite on my fork over the next day or two. I'll ping you here with the results once it's ready.

@exploreriii exploreriii marked this pull request as draft December 7, 2025 19:43
@exploreriii
Copy link
Contributor

excellent news! have switched this to draft while its ready to review again

@cheese-cakee cheese-cakee force-pushed the merge-conflict-bot-main-trigger branch from 7fd14a3 to b7f8b99 Compare December 8, 2025 19:47
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
@cheese-cakee cheese-cakee reopened this Dec 9, 2025
@cheese-cakee
Copy link
Author

cheese-cakee commented Dec 9, 2025

Hi @exploreriii

I have updated the bot based on the feedback.

Changes Made:

Moved the helper script to .github/scripts/merge_conflict_helpers.js as requested.

Updated the workflow yaml to dynamically locate the script using GITHUB_WORKSPACE, ensuring it works regardless of the runner's path structure.

Testing Verification: I have tested this thoroughly on my fork.

Test 1(Conflict Detected): Verified that the bot successfully detects a conflict and comments on the PR.
Test 2 (No Conflict): Verified that the bot remains silent when there are no conflicts.

Screenshot 2025-12-09 153256 Screenshot 2025-12-09 015659

@cheese-cakee cheese-cakee marked this pull request as ready for review December 9, 2025 10:23
@exploreriii
Copy link
Contributor

Hi @cheese-cakee were you able to test if

  1. an issue with no conflict
  2. once another issue gets merged
  3. and issue 1 now has a conflict
  4. there is a notification on issue 1?

@exploreriii
Copy link
Contributor

changing to draft while it is ready to review again 👍

@exploreriii exploreriii marked this pull request as draft December 10, 2025 00:00
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
@github-actions
Copy link

Hi, this is MergeConflictBot.
Your pull request cannot be merged because it contains merge conflicts.

Please resolve these conflicts locally and push the changes.

To assist you, please read:

Thank you for contributing!

From the Hiero Python SDK Team

Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
@cheese-cakee cheese-cakee marked this pull request as ready for review December 10, 2025 19:30
@cheese-cakee
Copy link
Author

cheese-cakee commented Dec 10, 2025

Hi @exploreriii

Yes! I verified this exact scenario in a test PR on my fork.

I opened a PR with no conflicts (Bot was silent).
I pushed a conflicting change to main.
I forced the bot to run again.
The bot successfully detected the new conflict and posted the comment. 🎉

I also updated harden-runner to v2.14.0 (the latest release) and just resolved the merge conflicts that popped up with main.

Ready for review!

@exploreriii
Copy link
Contributor

Request review @AntonioCeppellini @MonaaEid @tech0priyanshu if available

Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Copy link
Member

@AntonioCeppellini AntonioCeppellini left a comment

Choose a reason for hiding this comment

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

I think this two points needs to be reviewed

}

// post comment
async function notifyUser(prNumber) {
Copy link
Member

Choose a reason for hiding this comment

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

https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#list-issue-comments i think that this will check only 30 comments with default pagination, this could be a limit @exploreriii, i think that the default value is 30 also for the PRs, so if we have 34 open PRs it could be a problem.

It's a thought and it's debatable for sure :D

Copy link
Contributor

Choose a reason for hiding this comment

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

yep we can definitely paginate if its easy, but yes, currently i think we can get away without

@@ -0,0 +1,92 @@
// scripts/merge_conflict_helpers.js

const BOT_SIGNATURE = '';
Copy link
Member

Choose a reason for hiding this comment

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

if we use this as signature what will happen if a user (not a bot or not that specific bot) has already commented on the pr? will it detect that comment having the BOT_SIGNATURE ?

Copy link
Author

Choose a reason for hiding this comment

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

I have added a unique HTML comment signature so the bot won't confuse user comments for its own @AntonioCeppellini

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the BOT_SIGNATURE is an empty string now?

Copy link
Member

Choose a reason for hiding this comment

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

@cheese-cakee i still see an empty string like @MonaaEid

Copy link
Member

Choose a reason for hiding this comment

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

you could use something simple like [merge-conflict bot] like we did in https://github.com/hiero-ledger/hiero-sdk-python/blob/main/.github/workflows/bot-verified-commits.yml#L50

Copy link
Author

Choose a reason for hiding this comment

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

thanks for the example! I've switched the signature to [merge-conflict bot] as you suggested.

Copy link
Contributor

Choose a reason for hiding this comment

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

why using bot signature? If there is another merge conflict the bot will not be able to warn the author again.
can someone explain this please

Copy link
Member

Choose a reason for hiding this comment

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

nice @cheese-cakee :D, have you also tested the case that a pr already has comments in it from your fork?

Copy link
Author

@cheese-cakee cheese-cakee Dec 11, 2025

Choose a reason for hiding this comment

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

@MonaaEid The signature is necessary to prevent spam. Since this workflow runs on every push, without this check, the bot would post a new comment every single time a user pushes code while a conflict exists. This ensures it alerts the user once.

@AntonioCeppellini Yes tested! Since the signature [merge-conflict bot] is unique I verified that the bot correctly ignores all standard user comments and only identifies its own previous warnings.

Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
@github-actions
Copy link

Hi, this is WorkflowBot.
Your pull request cannot be merged as it is not passing all our workflow checks.
Please click on each check to review the logs and resolve issues so all checks pass.
To help you:

@exploreriii exploreriii added the p3 Low, backlog label Dec 11, 2025
@exploreriii
Copy link
Contributor

@cheese-cakee sorry about all the test failures, should be resolved in the next day or so and can take a look at this again

@cheese-cakee
Copy link
Author

@exploreriii thanks for the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p3 Low, backlog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update merge conflict bot to recognise conflicts caused by others

4 participants