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

C H E C K S A P I S U P P O R T 🀩 #79

Merged
merged 18 commits into from
Aug 22, 2018
Merged

C H E C K S A P I S U P P O R T 🀩 #79

merged 18 commits into from
Aug 22, 2018

Conversation

hiimbex
Copy link
Contributor

@hiimbex hiimbex commented Jul 5, 2018

What this PR does:

  • Upgrades to Probot 7️⃣. 0️⃣
  • Eliminates use of status API ❌
  • Uses Checks API aka best API πŸŽ†
  • Restructures lib/dco.js to return an array of error messages objects like:
[{ 
  "author": "Bex Warner",
  "committer": "Bex Warner",
  "message": "The sign-off is missing.",
  "sha": "fe9f33191f3a87c86843292920decab97b5b71b",
  "url": "https://github.com/probot/dco/pull/78/commits/fe9f33191f3a87c86843292920decab97b5b71b"
}]
  • Restructures test/dco.test.js to support that format πŸ› 
  • Adds guidance for ammending your commits πŸ†˜
    • supports git commit --amend --signoff for a mistake in the most recent commit
    • supports git rebase Head~$numOfCommits --signoff for mistakes in multiple commits
    • then instructs git push --force origin $your-branch
  • Also includes a list of full length errors for each commit πŸ”’
  • Adds a hard override of the status for anyone with write permissions ✍️

LOOK AT HOW PRETTY IT IS

All commits are signed off:

screen shot 2018-07-05 at 2 37 16 pm

screen shot 2018-07-05 at 2 37 03 pm

One commit incorrectly signed off:

screen shot 2018-07-05 at 2 37 45 pm

screen shot 2018-07-05 at 2 37 56 pm

Multiple commits incorrectly signed off:

screen shot 2018-07-05 at 4 35 40 pm

screen shot 2018-07-05 at 4 35 20 pm

Override button (only visible for those with repo write access):

screen shot 2018-07-05 at 4 55 21 pm

Todo:

  • Properly convert test/index.test.js to v7 and update tests. (tbh I don't fully understand how this test worked before, so not sure how to convert it!)
  • Maybe improve code readability/structure because at the moment it's rather hacky

cc/ @probot/maintainers @kytrinyx for πŸ‘€& πŸ’­'s

@caniszczyk
Copy link

caniszczyk commented Jul 6, 2018 via email

Copy link
Contributor

@bkeepers bkeepers left a comment

Choose a reason for hiding this comment

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

At a quick glance this looks awesome. I haven't had a chance to review the code yet, but love the functionality.

Is there any way we could "staff ship" this big of a change to allow people to opt in to the new behavior?

Could we separate out the upgrade to Probot 7.0 from the changes in functionality?

},
actions: [{
label: 'Set DCO to pass',
description: 'would set status to passing',
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd love to get eyes on this from a legal perspective to make sure that a this is worded properly. Something like "Accept DCO" and "I certify that my contributions fall under the Developer Certificate of Origin: https://developercertificate.org/"

@caniszczyk @mlinksva: could you recommend someone to help here?

Also, I wonder if there should be a separate "Dismiss" vs "Accept" buttons

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it's important to note this option is only accessible for users with write access to the repo.

We get quite a few requests for new users to not have to use git so painfully, so if the maintainers of a repo are happy with the user's comments that they "accept" the DCO, might as well give them a free status pass button.

Copy link

@mlinksva mlinksva Jul 9, 2018

Choose a reason for hiding this comment

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

Maybe I'm missing something, but this looks to me like a way for a maintainer to ignore the test, not for a contributor to agree their contributions are covered by the DCO.

Added: as @hiimbex wrote faster. 😳

Copy link
Contributor

Choose a reason for hiding this comment

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

Doh, sorry, I totally wasn't thinking about who would be the one clicking the button.

@bkeepers bkeepers self-requested a review July 9, 2018 16:15
@hiimbex hiimbex mentioned this pull request Jul 9, 2018
hiimbex and others added 9 commits July 14, 2018 11:42
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Brandon Keepers <bkeepers@github.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Brandon Keepers <bkeepers@github.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Brandon Keepers <bkeepers@github.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
@hiimbex
Copy link
Contributor Author

hiimbex commented Jul 18, 2018

Tests are now working! @bkeepers I'm blaming you 100% for the DCO failing (also a good motivator to implement #75 at some point).

Is there any way we could "staff ship" this big of a change to allow people to opt in to the new behavior?

I'm wondering if you still think this is necessary given that the 'set DCO to passing' otpion is only for those with write access. If you still this is something we should pursue, I'm not sure the best path forward for something like this. Maybe an additional .env variable?

I personally don't think a staff ship is necessary since the only functionality change is giving maintainers a button and using checks not statuses (it should still work in the same way). The other big update that goes with this is updating the permissions the app uses; however, now we get to write a note explaining why! I'm happy to craft one explaining this PR super in depth, so our users know why this change is happening.

But whenever you have ⏳ this is ready for πŸ‘€!

Copy link
Contributor

@bkeepers bkeepers left a comment

Choose a reason for hiding this comment

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

Testing this out locally now and will have more feedback, but first thing I noticed is that there a bunch of undefineds in the tests. Is that just bad test data, or is there something broken?

test/dco.test.js Outdated
const dcoObject = await getDCOStatus([{commit, author: { login: 'hiimbex' }, parents: []}], alwaysRequireSignoff, prInfo)

expect(dcoObject).toEqual([{
url: 'https://github.com/hiimbex/testing-things/pull/1/commits/undefined',
Copy link
Contributor

Choose a reason for hiding this comment

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

undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bkeepers I honestly thought I updated this. All that needs to change is the fake data passed into each test needs a sha value, for example:

const dcoObject = await getDCOStatus([{commit, author: { login: 'bkeepers' }, parents: []}], alwaysRequireSignoff, prInfo)

should be:

const dcoObject = await getDCOStatus([{commit, author: { login: 'bkeepers' }, parents: [], sha: '318g9hnf02b49uthisisasha'}], alwaysRequireSignoff, prInfo)

The code that actually makes this change is here

Copy link
Contributor

@bkeepers bkeepers left a comment

Choose a reason for hiding this comment

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

Gave this a try and it looks pretty good. Eventually I'd love to chat about refactoring some of this code, but it can wait until after this feature lands.

}

function handleMultipleCommits (pr, commitLength, dcoFailed) {
return `You only have ${dcoFailed.length} commits incorrectly signed off! To fix, head to your local branch and run: \n\`\`\`bash\ngit rebase HEAD~${commitLength} --signoff\n\`\`\`\n Now your commits will have your sign off. Next run \n\`\`\`bash\ngit push --force origin ${pr.head.ref}\n\`\`\``
Copy link
Contributor

Choose a reason for hiding this comment

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

This assumes the commits missing the DCO are always the last n commits. What if I have 5 commits, but the one in the middle properly has the DCO?

Could we just have the user rebase based on the base of the pull request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct me if I'm wrong, butgit push --force origin ${pr.head.ref} does exactly what you're describing. I was originally trying to do something fancy with commitLength but I think it's actually dead code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so I forgot what I actually did. So commitLength actually is the number of total commits in the PR, so you always rebase and sign off all of those commits, no matter which ones were wrong via:
git rebase HEAD~${commitLength} --signoff which utilizes this rebase option. And then does:
git push --force origin ${pr.head.ref}

lib/dco.js Outdated
@@ -22,23 +17,34 @@ module.exports = async function (commits, isRequiredFor) {
}
const match = regex.exec(commit.message)

const commitInfo = {
sha,
url: `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}/commits/${sha}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

What about using context.payload.pull_request.html_url as the base for this?

@bkeepers bkeepers removed their assignment Aug 2, 2018
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
@hiimbex
Copy link
Contributor Author

hiimbex commented Aug 3, 2018

Just confirmed via hiimbex/testing-things#71 that the existing PRs that swap mid-way from the old statuses to checks don't need any special work or support. The re-written check will overwrite the status.

@hiimbex
Copy link
Contributor Author

hiimbex commented Aug 3, 2018

Tests are failing due to jestjs/jest#6769 and will I think be fixed in a new Jest release? But it's compeltley unrelated to my changes.

Would love a re-review based on the updates whenever you've got a chance @bkeepers πŸ™‚

Signed-off-by: Bex Warner <bexmwarner@gmail.com>
@bkeepers bkeepers temporarily deployed to probot-dco August 15, 2018 18:07 Inactive
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Signed-off-by: Bex Warner <bexmwarner@gmail.com>
Update docs to reflect swap to checks api
@hiimbex hiimbex mentioned this pull request Aug 22, 2018
@hiimbex hiimbex merged commit 35f7202 into master Aug 22, 2018
@hiimbex hiimbex deleted the checks-api branch August 22, 2018 19:09
@hiimbex
Copy link
Contributor Author

hiimbex commented Aug 22, 2018

Consider it 🚒 d!! πŸŽ‰

@caniszczyk
Copy link

caniszczyk commented Aug 22, 2018 via email

@github-actions
Copy link

πŸŽ‰ This PR is included in version 1.0.0 πŸŽ‰

The release is available on GitHub release

Your semantic-release bot πŸ“¦πŸš€

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants