github

package
v0.0.0-...-0eb6aec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2017 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyseConfig

type AnalyseConfig struct {
	// contains filtered or unexported fields
}

AnalyseConfig is a configuration struct for the Analyse method, all fields are required, unless otherwise stated.

func PullRequestConfig

func PullRequestConfig(e *github.PullRequestEvent) AnalyseConfig

PullRequestConfig return an AnalyseConfig for a GitHub Pull Request.

func PushConfig

func PushConfig(e *github.PushEvent) AnalyseConfig

PushConfig returns an AnalyseConfig for a GitHub Push Event.

type CommitCommentReporter

type CommitCommentReporter struct {
	// contains filtered or unexported fields
}

CommitCommentReporter creates a single commit comment summarising all issues on a given owner, repo, and commit hash.

func NewCommitCommentReporter

func NewCommitCommentReporter(client *github.Client, owner, repo, commit string, commits int, analysisURL string) *CommitCommentReporter

NewCommitCommentReporter returns a CommitCommentReporter. commits is the number of commits the analysis is checking (to be displayed in the message) and analysisURL is the URL of the analysis.

func (*CommitCommentReporter) Report

func (r *CommitCommentReporter) Report(ctx context.Context, issues []db.Issue) error

Report implements the analyser.Reporter interface.

type GitHub

type GitHub struct {
	// contains filtered or unexported fields
}

GitHub is the type gopherci uses to interract with github.com.

func New

func New(logger logger.Logger, analyser analyser.Analyser, db db.DB, queuePush chan<- interface{}, integrationID int, integrationKey []byte, webhookSecret, gciBaseURL string) (*GitHub, error)

New returns a GitHub object for use with GitHub integrations https://developer.github.com/changes/2016-09-14-Integrations-Early-Access/ integrationID is the GitHub Integration ID (not installation ID). integrationKey is the key for the integrationID provided to you by GitHub during the integration registration.

func (*GitHub) Analyse

func (g *GitHub) Analyse(cfg AnalyseConfig) (err error)

Analyse analyses a GitHub event. If cfg.pr is not 0, comments will also be written on the Pull Request.

func (*GitHub) CallbackHandler

func (g *GitHub) CallbackHandler(w http.ResponseWriter, r *http.Request)

CallbackHandler is the net/http handler for github callbacks. This may have only been for old integration behaviour, as it doesn't appear to be documented anymore, but because our installation still has it set, it's still used for us. So just redirect.

https://web-beta.archive.org/web/20161114212139/https://developer.github.com/early-access/integrations/creating-an-integration/ https://web-beta.archive.org/web/20161114200029/https://developer.github.com/early-access/integrations/identifying-users/

func (*GitHub) NewInstallation

func (g *GitHub) NewInstallation(installationID int) (*Installation, error)

func (*GitHub) WebHookHandler

func (g *GitHub) WebHookHandler(w http.ResponseWriter, r *http.Request)

WebHookHandler is the net/http handler for github webhooks.

type InlineCommitCommentReporter

type InlineCommitCommentReporter struct {
	// contains filtered or unexported fields
}

InlineCommitCommentReporter is a analyser.Reporter that creates a commit comment for each issue on a single commit. This should only be used if all issues occur on a single commit (not when an analysis checks multiple commits such as during a push for 2 or more commits).

func NewInlineCommitCommentReporter

func NewInlineCommitCommentReporter(client *github.Client, owner, repo, commit string) *InlineCommitCommentReporter

NewInlineCommitCommentReporter returns a InlineCommitCommentReporter.

func (*InlineCommitCommentReporter) Report

func (r *InlineCommitCommentReporter) Report(ctx context.Context, issues []db.Issue) error

Report implements the analyser.Reporter interface.

type Installation

type Installation struct {
	ID int
	// contains filtered or unexported fields
}

Installation is a GitHub Integration which has operates in the context of a GitHub installation, and therefore performance operations as that installation.

func (*Installation) Diff

func (i *Installation) Diff(ctx context.Context, repositoryID int, commitFrom, commitTo string, requestNumber int) (io.ReadCloser, error)

Diff implements the web.VCSReader interface.

func (*Installation) IsEnabled

func (i *Installation) IsEnabled() bool

IsEnabled returns true if an installation is enabled.

type PRCommentReporter

type PRCommentReporter struct {
	// contains filtered or unexported fields
}

PRCommentReporter is a analyser.Reporter that creates a pull request comment for each issue on a given owner, repo, pr and commit hash. Returns on the first error encountered.

func NewPRCommentReporter

func NewPRCommentReporter(client *github.Client, owner, repo string, number int, commit string) *PRCommentReporter

NewPRCommentReporter returns a PRCommentReporter.

func (*PRCommentReporter) Report

func (r *PRCommentReporter) Report(ctx context.Context, issues []db.Issue) error

Report implements the analyser.Reporter interface.

type PRReviewReporter

type PRReviewReporter struct {
	// contains filtered or unexported fields
}

PRReviewReporter is a analyser.Reporter that creates a pull request review on a given owner, repo, pr and commit hash. Sets review status to COMMENT if there are comments.

func NewPRReviewReporter

func NewPRReviewReporter(client *github.Client, owner, repo string, number int, commit string) *PRReviewReporter

NewPRReviewReporter returns a PRReviewReporter.

func (*PRReviewReporter) Report

func (r *PRReviewReporter) Report(ctx context.Context, issues []db.Issue) error

Report implements the analyser.Reporter interface.

type StatusAPIReporter

type StatusAPIReporter struct {
	// contains filtered or unexported fields
}

StatusAPIReporter uses the GitHub Statuses API to report build status, such as success or failure.

func NewStatusAPIReporter

func NewStatusAPIReporter(logger logger.Logger, client *github.Client, statusURL, context, targetURL string) *StatusAPIReporter

NewStatusAPIReporter returns a StatusAPIReporter.

func (*StatusAPIReporter) Report

func (r *StatusAPIReporter) Report(ctx context.Context, issues []db.Issue) error

Report implements the analyser.Reporter interface.

func (*StatusAPIReporter) SetStatus

func (r *StatusAPIReporter) SetStatus(ctx context.Context, status StatusState, description string) error

SetStatus sets the CI Status API

type StatusState

type StatusState string

StatusState is the state of a GitHub Status API as defined in https://developer.github.com/v3/repos/statuses/

const (
	StatusStatePending StatusState = "pending"
	StatusStateSuccess StatusState = "success"
	StatusStateError   StatusState = "error"
	StatusStateFailure StatusState = "failure"
)

https://developer.github.com/v3/repos/statuses/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL