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

Add a package for wpt.fyi GitHub Checks #726

Merged
merged 6 commits into from
Nov 8, 2018
Merged

Add a package for wpt.fyi GitHub Checks #726

merged 6 commits into from
Nov 8, 2018

Conversation

lukebjerring
Copy link
Contributor

Description

Adds the main logic needed to create basic in_progress or completed GitHub check_runs.

@lukebjerring lukebjerring requested a review from Hexcles November 5, 2018 18:57
@wpt-pr-bot
Copy link

Staging instance deployed by Travis CI!
Running at https://checks-dot-wptdashboard-staging.appspot.com

@wpt-pr-bot
Copy link

Staging instance deployed by Travis CI!
Running at https://checks-dot-announcer-dot-wptdashboard-staging.appspot.com

Copy link
Member

@Hexcles Hexcles left a comment

Choose a reason for hiding this comment

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

First round of review (without the cryptography part)

// RegisterRoutes adds route handlers for webhooks.
func RegisterRoutes() {
// GitHub webhook for creating custom status checks.
shared.AddRoute("/api/webhook/status", "api-webhook-check", checkWebhookHandler)
Copy link
Member

Choose a reason for hiding this comment

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

The inconsistency between the two strings is confusing. Is it a (legacy) status or a check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a check, and that's what the endpoint should be (Fixed).

api/checks/suites.go Show resolved Hide resolved

// checkWebhookHandler listens for check_suite and check_run events,
// responding to requested and rerequested events.
func checkWebhookHandler(w http.ResponseWriter, r *http.Request) {
Copy link
Member

Choose a reason for hiding this comment

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

This function looks very similar to the one in taskcluster.go, which is fine for now, but it'd be good to add a TODO to point out the potential refactoring opportunity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already underway; See #721

}

// PendingCheckRun loads the CheckSuite(s), if any, for the given SHAs, and creates a pending
// check_run for the given browser name for each CheckSuite.
Copy link
Member

Choose a reason for hiding this comment

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

Clarify the return value (i.e. whether a new run is created; also explain when it will create a run).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

// CompleteCheckRun creates a complete check_run for the given browser on GitHub,
// for the given CheckSuite
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

return &suite, err
}

// GetSuitesForSHA returns any CheckSuite entities associated with the given SHA.
Copy link
Member

Choose a reason for hiding this comment

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

IIRC, the convention is to put the documentation for exported methods on the public interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@Hexcles Hexcles left a comment

Choose a reason for hiding this comment

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

I reviewed the authentication flow to my best effort; it LGTM.

So sad we don't have an up-to-date octokit for Go.

claims := &jwt.StandardClaims{
IssuedAt: now.Unix(),
ExpiresAt: now.Add(time.Minute * 10).Unix(),
Issuer: "19965",
Copy link
Member

Choose a reason for hiding this comment

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

This magic number is unfortunate, but at least we should have a comment here.

@lukebjerring lukebjerring merged commit cd4db89 into master Nov 8, 2018
@lukebjerring lukebjerring deleted the checks branch November 8, 2018 14:20
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.

3 participants