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

git-node: wait time for PR with single approval #290

Merged
merged 2 commits into from
Dec 3, 2018
Merged

git-node: wait time for PR with single approval #290

merged 2 commits into from
Dec 3, 2018

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Oct 7, 2018

One Collaborator approval is enough only if the pull request
has been open for more than 7 days

Refs: nodejs/node#22255

@codecov
Copy link

codecov bot commented Oct 7, 2018

Codecov Report

Merging #290 into master will decrease coverage by 0.28%.
The diff coverage is 93.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #290      +/-   ##
==========================================
- Coverage   74.42%   74.14%   -0.29%     
==========================================
  Files          22       22              
  Lines        1400     1400              
==========================================
- Hits         1042     1038       -4     
- Misses        358      362       +4
Impacted Files Coverage Δ
lib/collaborators.js 100% <100%> (ø) ⬆️
lib/pr_checker.js 96.11% <93.75%> (-2.23%) ⬇️

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 93286f2...24b7cea. Read the comment docs.

@@ -132,12 +133,16 @@ class PRChecker {
*/
getWait(now) {
const createTime = new Date(this.pr.createdAt);
const timeLeft = WAIT_TIME - Math.ceil(
const hoursFromCreateTime = Math.ceil(
Copy link
Member

@joyeecheung joyeecheung Oct 7, 2018

Choose a reason for hiding this comment

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

This seems rather complicated. I believe we can just combine checkReviews() and checkPRWait() so that the number of approvals and wait times are checked together with conditionals instead of independently, the logic would be much clearer that way.

Copy link
Member

Choose a reason for hiding this comment

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

(The two methods are separated only because previously a human would check these two conditions separately, but now there is a relationship between the two we should do what a human brain would do here instead and combine the logic.)

@joyeecheung
Copy link
Member

joyeecheung commented Oct 7, 2018

This is how may brain currently works:

if (approvals.length === 0) {
   return false;  // duh
}

// NOTE: a semver-major PR with fast-track should have either one of these labels removed
// because that doesn't make sense
if (labels.includes('semver-major')) {
  if (tscApprovals.length >= 2) {  // tsc are collaborators
     // check 48 hour and return
  } else {
    return false;  // 7 day rule doesn't matter here
  }
}

// non-semver-major
if (approvals.length >= 2) {
    if (fastTrack) {
        return true;
    }
   // check 48 hour and return
} else if (approvals.length === 1) {
    if (fastTrack) {
        // ????
    }
   // check 7 day
} else {
   // unreachable
}

cc @Trott Is that correct?

@joyeecheung
Copy link
Member

joyeecheung commented Oct 7, 2018

EDIT: Just realized I don't know how fast-track plays out if there is only one approval..(also, should we check the thumbs up message? I don't even know how we can identify the reply that needs emojis programmatically...

@@ -5,6 +5,7 @@ const MINUTE = SECOND * 60;
const HOUR = MINUTE * 60;

const WAIT_TIME = 48;
const WAIT_TIME_SINGLE_APPROVAL = 168;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: 7 * 24 or add comment to make it obvious that this is 7 days

@targos
Copy link
Member

targos commented Oct 7, 2018

Also, should we check the thumbs up message?

I'd say no for now. I think we should take advantage of the bot for that:

  • The person who would like to fast-track adds the label
  • The bot posts a well-known message to ask for thumbs up
  • ncu can find that message and count the number of thumbs up by collaborators (can it?)

@joyeecheung
Copy link
Member

The bot posts a well-known message to ask for thumbs up

I don't think at the moment the bot has any hooks to do this after a label is added by a human?

@targos
Copy link
Member

targos commented Oct 7, 2018

The bot receives all pull request events, which apparently include labels:
image

@Trott
Copy link
Member

Trott commented Oct 8, 2018

cc @Trott Is that correct?

@joyeecheung Yes, and to answer this part:

    if (fastTrack) {
        // ????
    }
   // check 7 day

No need to check fastTrack there. If you remove that check, it checks that the PR is open for 7 days. If you only have one approval, you cannot fast track. So, it's 7 days or else return false.

@joyeecheung
Copy link
Member

Ping @trivikr do you still want to pursue this? Ideally I want to go with a big branch as described in #290 (comment) so it's easier to update later if we are ever going the change the rules again

@targos
Copy link
Member

targos commented Nov 18, 2018

Ping :)

@trivikr
Copy link
Member Author

trivikr commented Nov 19, 2018

@joyeecheung @targos I wanted to make a simple change instead of refactoring the code.
I'm little busy, feel free to pick it up.

One Collaborator approval is enough only if the pull request
has been open for more than 7 days

Refs: nodejs/node#22255
@joyeecheung
Copy link
Member

Rebased and updated the logic. @targos @Trott Can you take a look? Thanks!

@devsnek
Copy link
Member

devsnek commented Dec 3, 2018

from this image:

it would be nice if was on one line, and the 91 hours was made like 3 days 18 hours

@joyeecheung
Copy link
Member

joyeecheung commented Dec 3, 2018

@devsnek Thanks for the feedback, I merged the two logs into one line, regarding the date time improvements that should probably be done in a follow-on PR

@trivikr
Copy link
Member Author

trivikr commented Dec 4, 2018

Thanks @joyeecheung for picking up the refactor task!

@trivikr trivikr deleted the wait-time-single-approval branch December 4, 2018 06:32
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.

6 participants