lookout

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: AGPL-3.0 Imports: 10 Imported by: 20

README

lookout Build Status GoDoc

A service for assisted code review, that allows running custom code Analyzers on pull requests.

Installation

go get github.com/src-d/lookout

Dependencies

The included ./docker-compose.yml allows to start all dependencies using Docker Compose

Clone the repository, or download ./docker-compose.yml, and run:

docker-compose up

Example

SDK

If you are developing an Analyzer, please check SDK documentation.

It includes a curl-style binary that allows to trigger Analyzers directly, without launching a full lookout server.

Server

To trigger the analysis on an actual pull request of a GitHub repository do:

  1. Start an analyzer Any of the analyzers or a default dummy one, included in this repository
    go build -o analyzer ./cmd/dummy
    ./analyzer serve
    
  2. Start a lookout server
    1. With posting analysis results on GitHub
      • Obtain GitHub access token
      • Run lookout serve --github-token <token> --github-user <user> <repository>
    2. Without posting analysis results (only printing)
      • lookout serve --dry-run <repository>
  3. Create a new pull requires in the repository

Contribute

Contributions are more than welcome, if you are interested please take a look to our Contributing Guidelines.

Code of Conduct

All activities under source{d} projects are governed by the source{d} code of conduct.

License

Affero GPL v3.0, see LICENSE.

SDK package in ./sdk is released under the terms of the Apache License v2.0

Documentation

Overview

Package lookout provides gRPC APIs to implement analysis servers and clients.

Services

There are two services:

  1. Analyzer: analyzers process source code changes and provide analysis results as text comments, possibly linked to specific parts of the code.

2. Data: provides simple access to source code changes.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NoErrStopWatcher if a new error of this kind is returned by EventHandler
	// the Watcher.Watch function exits without error.
	NoErrStopWatcher = errors.NewKind("Stop watcher")
)

Functions

func RegisterAnalyzerServer

func RegisterAnalyzerServer(s *grpc.Server, srv AnalyzerServer)

func RegisterDataServer

func RegisterDataServer(s *grpc.Server, srv *DataServerHandler)

Types

type Analyzer

type Analyzer struct {
	Client AnalyzerClient
	Config AnalyzerConfig
}

Analyzer is a struct of analyzer client and config

type AnalyzerClient

type AnalyzerClient = pb.AnalyzerClient

func NewAnalyzerClient

func NewAnalyzerClient(conn *grpc.ClientConn) AnalyzerClient

type AnalyzerConfig

type AnalyzerConfig struct {
	Name string
	// Addr is gRPC URL.
	// can be defined only in global config, repository-scoped configuration is ignored
	Addr string
	// Settings any configuration for an analyzer
	Settings map[string]interface{}
}

AnalyzerConfig is a configuration of analyzer

type AnalyzerServer

type AnalyzerServer = pb.AnalyzerServer

type Change

type Change = pb.Change

type ChangeGetter

type ChangeGetter interface {
	// GetChanges returns a ChangeScanner that scans all changes according
	// to the request.
	GetChanges(context.Context, *ChangesRequest) (ChangeScanner, error)
}

ChangeGetter is used to retrieve code changes.

type ChangeScanner

type ChangeScanner interface {
	// Next advances the scanner to the next change. It returns true if a new
	// change is found, and false otherwise. After the user is done scanning,
	// Err must be called to check if all changes were consumed or there was an
	// error.
	Next() bool
	// Err returns any error found during scanning.
	Err() error
	// Change returns the current change.
	Change() *Change
	// Close closes the scanner.
	Close() error
}

ChangeScanner is a scanner for changes.

type ChangesRequest

type ChangesRequest = pb.ChangesRequest

type ClientChangeScanner

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

func (*ClientChangeScanner) Change

func (s *ClientChangeScanner) Change() *Change

func (*ClientChangeScanner) Close

func (s *ClientChangeScanner) Close() error

func (*ClientChangeScanner) Err

func (s *ClientChangeScanner) Err() error

func (*ClientChangeScanner) Next

func (s *ClientChangeScanner) Next() bool

type ClientFileScanner

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

func (*ClientFileScanner) Close

func (s *ClientFileScanner) Close() error

func (*ClientFileScanner) Err

func (s *ClientFileScanner) Err() error

func (*ClientFileScanner) File

func (s *ClientFileScanner) File() *File

func (*ClientFileScanner) Next

func (s *ClientFileScanner) Next() bool

type Comment

type Comment = pb.Comment

type CommitRevision

type CommitRevision = pb.CommitRevision

type DataClient

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

func NewDataClient

func NewDataClient(cc *grpc.ClientConn) *DataClient

func (*DataClient) GetChanges

func (c *DataClient) GetChanges(ctx context.Context, in *ChangesRequest, opts ...grpc.CallOption) (
	ChangeScanner, error)

func (*DataClient) GetFiles

func (c *DataClient) GetFiles(ctx context.Context, in *FilesRequest, opts ...grpc.CallOption) (
	FileScanner, error)

type DataServerHandler

type DataServerHandler struct {
	ChangeGetter ChangeGetter
	FileGetter   FileGetter
}

func (*DataServerHandler) GetChanges

func (s *DataServerHandler) GetChanges(req *ChangesRequest,
	srv pb.Data_GetChangesServer) (err error)

func (*DataServerHandler) GetFiles

func (s *DataServerHandler) GetFiles(req *FilesRequest, srv pb.Data_GetFilesServer) (err error)

type Event

type Event interface {
	// ID returns the EventID.
	ID() EventID
	// Type returns the EventType, in order to identify the concreate type of
	// the event.
	Type() EventType
	// Revision returns a commit revision, containing the head and the base of
	// the changes.
	Revision() *CommitRevision
}

Event represents a repository event.

type EventHandler

type EventHandler func(Event) error

EventHandler funciton to be called when a new event happends.

type EventID

type EventID = pb.EventID

type EventResponse

type EventResponse = pb.EventResponse

type EventType

type EventType = pb.EventType

type File

type File = pb.File

type FileGetter

type FileGetter interface {
	// GetFiles returns a FilesScanner that scans all files according
	// to the request.
	GetFiles(context.Context, *FilesRequest) (FileScanner, error)
}

FileGetter is used to retrieve all code for a revision.

type FileScanner

type FileScanner interface {
	// Next advances the scanner to the next file. It returns true if a new
	// file is found, and false otherwise. After the user is done scanning,
	// Err must be called to check if all files were consumed or there was an
	// error.
	Next() bool
	// Err returns any error found during scanning.
	Err() error
	// File returns the current file.
	File() *File
	// Close closes the scanner.
	Close() error
}

FileScanner is a scanner for files.

type FilesRequest

type FilesRequest = pb.FilesRequest

type FnChangeScanner

type FnChangeScanner struct {
	Scanner ChangeScanner
	Fn      func(*Change) (bool, error)
	OnStart func() error
	// contains filtered or unexported fields
}

FnChangeScanner implements ChangeScanner using functions

func (*FnChangeScanner) Change

func (s *FnChangeScanner) Change() *Change

func (*FnChangeScanner) Close

func (s *FnChangeScanner) Close() error

func (*FnChangeScanner) Err

func (s *FnChangeScanner) Err() error

func (*FnChangeScanner) Next

func (s *FnChangeScanner) Next() bool

type FnFileScanner

type FnFileScanner struct {
	Scanner FileScanner
	Fn      func(*File) (bool, error)
	OnStart func() error
	// contains filtered or unexported fields
}

FnFileScanner implements FileScanner using functions

func (*FnFileScanner) Close

func (s *FnFileScanner) Close() error

func (*FnFileScanner) Err

func (s *FnFileScanner) Err() error

func (*FnFileScanner) File

func (s *FnFileScanner) File() *File

func (*FnFileScanner) Next

func (s *FnFileScanner) Next() bool

type Poster

type Poster interface {
	// Post posts comments about an event.
	Post(context.Context, Event, []*Comment) error
}

Poster can post comments about an event.

type PushEvent

type PushEvent = pb.PushEvent

type ReferencePointer

type ReferencePointer = pb.ReferencePointer

type RepositoryInfo

type RepositoryInfo = pb.RepositoryInfo

type ReviewEvent

type ReviewEvent = pb.ReviewEvent

type Server

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

Server implements glue between providers / data-server / analyzers

func NewServer

func NewServer(w Watcher, p Poster, fileGetter FileGetter, analyzers map[string]Analyzer) *Server

NewServer creates new Server

func (*Server) HandlePush

func (s *Server) HandlePush(ctx context.Context, e *PushEvent) error

HandlePush sends request to analyzers concurrently

func (*Server) HandleReview

func (s *Server) HandleReview(ctx context.Context, e *ReviewEvent) error

HandleReview sends request to analyzers concurrently

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts server

type ServerConfig

type ServerConfig struct {
	Analyzers []AnalyzerConfig
}

ServerConfig is a server configuration

type WatchOptions

type WatchOptions struct {
	URL string
}

WatchOptions options to use in the Watcher constructors.

type Watcher

type Watcher interface {
	// Watch for new events triggering the EventHandler for each new issue,
	// it stops until an error is returned by the EventHandler. Network errors
	// or other temporal errors are handled as non-fatal errors, just logging it.
	Watch(context.Context, EventHandler) error
}

Watcher watch for new events in given provider.

Directories

Path Synopsis
cmd
Package dummy implements an example analyzer.
Package dummy implements an example analyzer.
Package pb contrains the autogenerated gRPC API.
Package pb contrains the autogenerated gRPC API.
provider
service
bblfsh
Package bblfsh provides access to bblfsh parsing for the data service.
Package bblfsh provides access to bblfsh parsing for the data service.
git
Package git provides access to git repositories.
Package git provides access to git repositories.
util

Jump to

Keyboard shortcuts

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