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

Fixing review state to APPROVED whe 'LGTM' in COMMENTED review #72

Merged
merged 11 commits into from
Nov 8, 2017

Conversation

Tiriel
Copy link
Contributor

@Tiriel Tiriel commented Nov 4, 2017

From #67
Tested with nodejs/node#16248 as given in issue #67

Ran lint and tests.

Comments and reviews deeply welcomed!

@codecov-io
Copy link

codecov-io commented Nov 4, 2017

Codecov Report

Merging #72 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
+ Coverage   98.09%   98.13%   +0.03%     
==========================================
  Files          13       13              
  Lines         473      482       +9     
==========================================
+ Hits          464      473       +9     
  Misses          9        9
Impacted Files Coverage Δ
lib/pr_checker.js 96.47% <100%> (+0.02%) ⬆️
lib/reviews.js 98.41% <100%> (+0.23%) ⬆️
lib/args.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 744a34d...f3f4afb. Read the comment docs.

@priyank-p
Copy link
Contributor

@Tiriel Great Work! can you add tests in test/unit/reviews.test.js

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 4, 2017

Oh yeah sorry, that's indeed a good idea. I'm on it!

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 5, 2017

Original tests were in fact all that was needed. I just had to add a test-case in fixtures for my first draft to make some tests fail. (pr_data tests in fact).
Adding the test case was indeed a great idea, thanks @cPhost !

Corrected work, now tests still pass with proper test case, and command still responds properly.

lib/reviews.js Outdated
* @returns {boolean}
*/
hasLGTM(object, prop) {
return LGTM_RE.test(object[prop]);
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is too loose. It would pass for I'm revoking my LGTM.
IMHO this should be object[prop].toLowerCase() === 'lgtm'.

Copy link
Member

Choose a reason for hiding this comment

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

@refack This is already the case for normal comments, I think we should log an info here, like what we do for those, to remind the landers to double-check. The actual context would be too hard to parse without some kind of natural language processing..

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea!

Copy link
Member

@joyeecheung joyeecheung Nov 5, 2017

Choose a reason for hiding this comment

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

OK maybe not log an info here, but make a new type of REVIEW_SOURCES, maybe FROM_REVIEW_COMMENT, and warn them in checkReviews like what we do for FROM_COMMENT

Copy link
Member

@joyeecheung joyeecheung Nov 5, 2017

Choose a reason for hiding this comment

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

@refack re: I'm revoking my LGTM. they would've put a red cross there I think? (Although if people could click the wrong button for approvals then they might click the same one for objections..

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking of something I saw last week - nodejs/node#16612 (review)

Copy link
Contributor

Choose a reason for hiding this comment

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

That case was not a "Request Changes" , just "Don't count me as approver", same as dismissed review.

Copy link
Member

@joyeecheung joyeecheung Nov 5, 2017

Choose a reason for hiding this comment

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

Another idea: if we are uncertain about a LGTM, we can log it as ?Reviewed-By: xxx, and then core-validate-commit should complain about it (it doesn't at the moment, we can update that. For now we can just warn about them ourselves).

Copy link
Member

@joyeecheung joyeecheung Nov 7, 2017

Choose a reason for hiding this comment

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

On a second thought, I am finding the object[prop].toLowerCase() === 'lgtm' approach better (although we can just do that by changing LGTM_RE to /^lgtm$/i and trim the comments before testing them), it's just simpler that way. I think people who don't give LGTM either this way or with a green review would not mind not being listed in the review-by list. Also it saves you the trouble of listing them back manually if they are already in the metadata.

refack
refack previously approved these changes Nov 5, 2017
Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

Most bits LGTM but I think we should log something about the source, like what we do for LGTM in normal comments (hey look at me using LGTM in an CHANGES_REQUESTED XD)

@refack refack dismissed their stale review November 5, 2017 02:06

And I'm dismissing my review, so we'll have good data

@refack
Copy link
Contributor

refack commented Nov 5, 2017

BTW: people can also dismiss other's reviews, so need to keep track of the author attribution

@joyeecheung
Copy link
Member

@refack Yes, we probably need to dig a bit more into the state machine later as well..

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 5, 2017

By the way, I see that the info telling one PR was approved in comments or commented review is on console.info. Wouldn't it be better to pass it to console.warn?

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 5, 2017

For now, that's what I got:
image

Not committed yet, Just want to see if it's ok for you ;)

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 5, 2017

Okay, I've read all the comments, bit confusing xD

I think I'll go for both things you suggested if possible @joyeecheung , new source and ?in report.

@joyeecheung @refack Otherwise, what about changing the RegEx to this: ^(L|S)GTM!?$ ? This would prevent most cases of matches when people are discussing "LGTM" without actually wanting to validate a PR and still allowing some leeway, don't you think?

@apapirovski
Copy link
Member

apapirovski commented Nov 5, 2017

I know I'm going to be a minority on this but I would scrape the whole LGTM checking (including the existing). Everyone uses the green button. If they're not using and they say 'LGTM' or something that extent, it usually means they scanned it but don't have complete confidence to give it firm approval.

I don't think the few times we'll find a legitimate approval that wasn't logged as such will be more frequent than the comments with LGTM where it's a part of a broader statement that is not necessarily an approval.

@apapirovski
Copy link
Member

apapirovski commented Nov 5, 2017

For example, what does this count as? (This is from a recent PR I landed.)

Basically LGTM, just note that automatic fixing can introduce bugs if another variable of the same name was declared within the function.

I don't think the author would expect to be listed in Reviewed-By even though they gave a LGTM.

Or the more common:

LGTM but I'm not an expert on this domain.

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 5, 2017

That's a good point, but actually that's why I would put the notice in warning.

In a way, just to say "Some people seem to approve, but be careful".

And that's also why I'd say we only register "LGTM" when it's the only thing in the comment (my RegEx proposal)

@joyeecheung
Copy link
Member

Or....maybe we should skip those people in the actual metadata, just log them as "potential reviewers"?

@apapirovski
Copy link
Member

apapirovski commented Nov 5, 2017

@joyeecheung I think that's my favourite suggestion so far.

@apapirovski apapirovski closed this Nov 5, 2017
@apapirovski apapirovski reopened this Nov 5, 2017
@apapirovski
Copy link
Member

Fat fingered the close button. Sorry.

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 5, 2017

Maybe then keeping the line "XXX reviewed in comment" while removing the review from review count?

@joyeecheung
Copy link
Member

joyeecheung commented Nov 5, 2017

@Tiriel Yes that's what I had in mind.

@joyeecheung
Copy link
Member

joyeecheung commented Nov 5, 2017

@Tiriel Or maybe..

The following collaborators are not listed in the metadata,
please add them manually if you think their comments count as approvals:
Foo <[email protected]>: I am not sure about if I can give a proper LGTM but this is a great idea
Bar <[email protected]>: LGTM modulo style nits

(we can even make this interactive and let the user decide!...although for the moment I think this PR is good with just removing them in the metadata)

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 5, 2017

For now that's what I got:
image
Is that okay?

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 5, 2017

I can do like you said in your last comment, but I feel that would need a more important rework of the workflow that would justify another PR

@Tiriel Tiriel force-pushed the feature/approve-commented branch from bdce824 to 6004aed Compare November 5, 2017 17:17
@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 5, 2017

Actually this way other tests fail.

Going to rework already :)

@Tiriel Tiriel force-pushed the feature/approve-commented branch from 6004aed to 6779760 Compare November 6, 2017 13:53
@joyeecheung
Copy link
Member

@Tiriel Let's go with regexp then. Also we might want to trim the text before testing them as well.

@Tiriel Tiriel force-pushed the feature/approve-commented branch from 6ab5a4e to 0f48d22 Compare November 7, 2017 09:19
@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 7, 2017

Done!
Rebased, linted and tested as usual (now) :D

lib/reviews.js Outdated
case COMMENTED:
map.set(
login,
new Review(r.state, r.publishedAt, r.bodyText, FROM_REVIEW_COMMENT)
Copy link
Member

Choose a reason for hiding this comment

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

I suggest we just pass APPROVED as the state here, like what we do for approval in normal comments. This way we don't need to call isApprovedInComment in getReviewers. We still keep the info about its source in review.source.

Copy link
Contributor Author

@Tiriel Tiriel Nov 7, 2017

Choose a reason for hiding this comment

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

Oh thanks, that's what I had done in the first place, forgot to reinstate it when reverting

"bodyText": "LGTM",
"state": "COMMENTED",
"author": {
"login": "Baz"
Copy link
Member

Choose a reason for hiding this comment

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

Can you make a new case for this? This and the case above are overlapping each other so one of them would not be visible in the tests. To do this we need to add another collaborator in collaborators.json and the readme in the fixtures as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are in fact numerous tests using each files. I also had to add an entry in reviewers_approved.json and modify accordingly other tests. Push coming

@joyeecheung
Copy link
Member

Also with this we can probably drop the check for FROM_COMMENT in the pr checker, or put it behind a command line flag and warn about both FROM_COMMENT and FROM_REVIEW_COMMENT (but I don't think we really need a warning for that any more..)

@Tiriel Tiriel force-pushed the feature/approve-commented branch from 0f48d22 to b9b6608 Compare November 7, 2017 14:28
@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 7, 2017

There, this should do it. I added the --comments flag and some tests cases. I'll let you review, since I had to adapt some existing tests cases

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

Very close!

lib/args.js Outdated
@@ -37,6 +37,12 @@ function buildYargs(args = null) {
describe: 'File to write the metadata in',
type: 'string'
})
.option('comments', {
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather let this be --check-comments with no aliases, in case we need the c later. This does not seem to be very in demand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your desires are my commands!

@@ -80,12 +80,13 @@ describe('PRChecker', () => {

const expectedLogs = {
warn: [
['Quux User(Quux)) approved in via LGTM in comments'],
Copy link
Member

Choose a reason for hiding this comment

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

There is a redundant ) here..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this redundant parens is in every test and is in fact in the base template :D
I'll remove it everywhere.

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 8, 2017

Fixed!

@priyank-p
Copy link
Contributor

@Tiriel can you add this option in readme.

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 8, 2017

Very good idea! Incoming!

Copy link
Contributor

@priyank-p priyank-p left a comment

Choose a reason for hiding this comment

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

Very minor nits. I think we are good to merge it.

lib/args.js Outdated
@@ -37,6 +37,11 @@ function buildYargs(args = null) {
describe: 'File to write the metadata in',
type: 'string'
})
.option('check-comments', {
demandOption: false,
describe: 'Check for\'LGTM\' in comments',
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above^

README.md Outdated
--owner, -o GitHub owner of the PR repository [string]
--repo, -r GitHub repository of the PR [string]
--file, -f File to write the metadata in [string]
--check-comments Check for'LGTM' in comments [boolean]
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor Nit: add a space between for and LGTM 'Check for \'LGTM\' in comments'

@Tiriel
Copy link
Contributor Author

Tiriel commented Nov 8, 2017

Going to merge then, unless someone objects!

@Tiriel Tiriel merged commit 1d05665 into nodejs:master Nov 8, 2017
@Tiriel Tiriel deleted the feature/approve-commented branch November 8, 2017 15:37
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.

7 participants