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

Edit CI comment when subsequent PR jobs are started #226

Closed
wants to merge 2 commits into from

Conversation

phillipj
Copy link
Member

The motivation behind these changes are to prevent flooding PRs with CI comments from the bot whenever new node-test-pull-request jobs are started. Instead if the bot has already posted a CI comment earlier, it will update the last CI comment and change the URL in that comment to the new job that got started.

Snook in a bugfix for the already existing helper function that fetches the bot's username. There has obviously been a regression in that function, so replaced the existing zero-value-unit-test with an integration test that should increase its reliability going forward.

/cc @nodejs/github-bot @cjihrig

lib/push-jenkins-update.js Outdated Show resolved Hide resolved
@cjihrig
Copy link

cjihrig commented Mar 26, 2019

I haven't reviewed the code, but I'm very 👍 on this idea, and thank you for the quick turnaround time on it.

Instead if the bot has already posted a CI comment earlier, it will update the last CI comment and change the URL in that comment to the new job that got started.

Does that include the "automatic CI" comment? I think that would be ideal so that there is one comment at the top of the issue that can be treated as an audit log of sorts. This would also mean appending the comment and not just overwriting it.

function findExistingCiComment (options, logger, cb) {
async.parallel([
botUsername.resolve,
githubClient.issues.getComments.bind(githubClient.issues, {
Copy link
Contributor

@refack refack Mar 26, 2019

Choose a reason for hiding this comment

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

This will only return one page of entries (i.e. 30). We have issues (nodejs/node#26322) with much more, so this won't find the comment and revert to the current behavior...

I'm playing with the graphQL API, that can return 100. I was thinking of fetching a batch from the top, and from the bottom.

BTW: the graphQL schema has viewerDidAuthor property, so no need for the bot's id anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, obviously didn't remember that at first. Fetching all pages of entries is something we'd have to do elsewhere, e.g. in ./lib/node-repo.js.

I'm playing with the graphQL API, that can return 100. I was thinking of fetching a batch from the top, and from the bottom.

Cool, the GraphQL API is something I've been wanting to try out for a while too!

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll try to push a suggestion, as soon as I refresh my sinon & supertest skills...

lib/push-jenkins-update.js Outdated Show resolved Hide resolved
Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

Generally +1
Similar to the implementation I made.

@refack
Copy link
Contributor

refack commented Mar 26, 2019

Does that include the "automatic CI" comment?

I think it should. It's a convenient place, and it's easy to find (see paging) for PRs authored by Collaborators.

@phillipj
Copy link
Member Author

Thanks for the lightning quick reviews!

@cjihrig said:
Does that include the "automatic CI" comment?

My first intention was to put out the immediate "fire" of flooding CI comments since yesterday (#224). On second thought it probably won't be many changes needed to what is currently in this PR to make that happen, and thereby fix both while we're at it.

@refack said:
Similar to the implementation I made.

Mind opening a PR with what you've got if it's ready-ish? I'm certain we'd end up with a better solution at the end if we share notes so to speak..

@refack
Copy link
Contributor

refack commented Mar 26, 2019

Mind opening a PR with what you've got if it's ready-ish? I'm certain we'd end up with a better solution at the end if we share notes so to speak..

#228

@sam-github
Copy link

Perhaps I'm in the minority, but I love having a new CI commit for every CI run. Currently, I manually paste the CI commit in for every single run I do, so the existing behaviour just automates what I do manually.

@phillipj
Copy link
Member Author

@sam-github in general I feel the same way as you do, but I'm not an active core contributor these days and have never been involved in many PRs simultaneously so 🤷‍♂️

The motivation behind these changes are to prevent flooding PRs with CI
comments from the bot whenever new node-test-pull-request jobs are
started. Instead if the bot has already posted a CI comment earlier,
it will update the last CI comment and change the URL in that comment
to the new job that got started.
@phillipj
Copy link
Member Author

Rebased and force pushed after the bot username got hardcoded in 4f4ac43, thereby removing the previous complexity of getting the username async from the API.

@phillipj
Copy link
Member Author

phillipj commented May 5, 2019

Closing this in favour of #228 which is more in line with keeping one bot comment that is edited as soon as new builds are kicked off, and gives GitHub's GraphQL API a shot which is valuable getting some experience with for later.

@phillipj phillipj closed this May 5, 2019
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.

None yet

4 participants