Closed Bug 1422308 Opened 8 years ago Closed 8 years ago

TaskCluster bot replies to PRs with different subject

Categories

(Taskcluster :: Services, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: reuben, Assigned: ydidwania)

Details

Example GitHub PR email: [mozilla/DeepSpeech] Using custom IRC notifications (#1053) Example TC bot response: Re: [mozilla/DeepSpeech] Using custom IRC notifications (85658da) See https://github.com/mozilla/DeepSpeech/pull/1053 This causes my email client to put TaskCluster responses on a new thread. It'd be nice if the bot used the PR number instead of the commit short hash so that its responses were put in the same email thread.
That's no longer a valid URL for seeing this, since the comment was deleted by a force-push. Here's another example: https://github.com/mozilla/DeepSpeech/pull/1102 I think the problem is that TaskCluster is commenting on the commit, rather than on the PR/issue. You can see on the UI that it says "taskcluster bot commented on bfca43d".
Ah, sorry I didn't see this until now! I'll need to get myself set as a triager for this component. I think we can make this happen. :yd has graciously offered to work on this and will assign accordingly.
Assignee: nobody → didwaniayashvardhan
Status: NEW → ASSIGNED
Hi, I would like to work on this bug. I noticed in https://github.com/taskcluster/taskcluster-github/blob/master/src/handlers.js#L342 comments are created using `CreateCommitComment()` function provided in the node module 'github'. In its docs I found another function(https://octokit.github.io/node-github/#api-pullRequests-createComment) which comments on the pull request. I think we can use this here. I will have to first make sure that it works correctly though. I can't figure out how do I test it on my own, because the setup here (https://www.npmjs.com/package/github#example) requires a github-enterprise-enabled-company.
yd, that looks like a great start. For development, we generally mock things out in https://github.com/taskcluster/taskcluster-github/blob/master/test/github-auth.js I would add a mocked createComment for pull requests there and see if you can make it work like that!
To use the api I linked in Comment3 (https://octokit.github.io/node-github/#api-pullRequests-createComment) , we would need the PR number. As you said, I added a `pullRequests.createComment` in test/github.js By logging, I found that this PR number is part of the message that is published on pulse in src.api.js (https://github.com/taskcluster/taskcluster-github/blob/master/src/api.js#L275) Here is the pulse message -> https://pastebin.mozilla.org/9075757 However the PR number is lost in the message received by the handler for the jobListener in src/handlers.js (https://github.com/taskcluster/taskcluster-github/blob/master/src/handlers.js#L85) Here is the message received by the handler -> https://pastebin.mozilla.org/9075758 1) How do we make the PR number available in handlers.js ? 2) Sorry for this out of context question, but how does taskcluster manage to create a taskgraph with the limited information in the message received by the handler. How does it get the info of the commits and files changed ? Thanks!
Is the message you have pasted here from the tests? I believe this may be a bug in how we wrote our tests in that we left out the new sections of the message! You can see in https://github.com/taskcluster/taskcluster-github/blob/master/src/api.js#L39 that the number is added to the data for PRs but we never added it to the mock in https://github.com/taskcluster/taskcluster-github/blob/master/test/handler_test.js#L57. I expect you should be able to add it to that mock in cases where the event.type is a PR.
As for how it works with that limited knowledge, you'll find that most people end up fetching that info themselves in their task definitions. For instance here is how we do it in the taskcluster-github taskcluster tests themselves! https://github.com/taskcluster/taskcluster-github/blob/master/.taskcluster.yml#L30 (good question, btw)
I made the above changes, and had the pullRequests.createComment called from src/handlers.js for pull requests. I also modified some of the tests to ensure that they pass successfully. I made a PR with these changes in place so you can look at it - https://github.com/taskcluster/taskcluster-github/pull/222
This is landed now! The irc messages you receive are not from tc-gh itself but from notify clauses in your task configuration itself. Let me know if you want help getting those to be by PR # rather than commit message. Otherwise I think tc-gh does the right thing now! Thanks, :ydidwania!
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Thanks for fixing this! :)
It was great working on it :reuben Yes :bstack, I would like to work on it, is it related to Bug 1422359 ?
Flags: needinfo?(bstack)
Flags: needinfo?(bstack)
Component: Github → Services
You need to log in before you can comment on or make changes to this bug.