commands

package
Version: v0.0.0-...-34231cf Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2018 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AggregateCommand = cli.Command{
	Name:        "aggregate",
	Usage:       "aggregate",
	Description: "Aggregates flakes",

	Flags: []cli.Flag{
		cli.IntFlag{
			Name:  "max-age, m",
			Usage: "Lists builds that failed in the last n hours",
			Value: 168,
		},
		cli.IntFlag{
			Name:  "threshold, t",
			Usage: "Defines a test as a flake it if fails at least n times",
			Value: 3,
		},
	},

	Action: func(ctx *cli.Context) error {
		client := ctx.App.Metadata["client"].(fly.Client)

		searcher := hunter.NewSearcher(client)
		spec := hunter.SearchSpec{
			Pattern: regexp.MustCompile("\\[Fail\\].*"),
		}

		builds := searcher.Search(spec)

		aggregator := NewAggregator()
		maxAge := ctx.Int("max-age")
		for build := range builds {
			if maxAge > 0 && age(build) > maxAge {
				break
			}
			for _, match := range build.Matches {
				aggregator.addFailure(&Failure{
					Description:  match,
					JobName:      build.JobName,
					ConcourseURL: build.ConcourseURL,
					Date:         build.StartTime,
				})
			}
		}

		aggregator.printEntries(ctx.Int("threshold"))
		return nil
	},
}
View Source
var SearchCommand = cli.Command{
	Name:        "search",
	Usage:       "search <arguments>",
	Description: "Searches for flakes",

	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:  "show-one-offs",
			Usage: "If set one off failures will be reported as well",
		},
		cli.IntFlag{
			Name:  "max-age, m",
			Usage: "Lists builds that failed in the last n hours",
			Value: -1,
		},
	},

	Action: func(ctx *cli.Context) error {
		if ctx.Args().First() == "" {
			return cli.NewExitError("need to provide a pattern", 1)
		}

		client := ctx.App.Metadata["client"].(fly.Client)

		searcher := hunter.NewSearcher(client)
		spec := hunter.SearchSpec{
			Pattern: regexp.MustCompile(ctx.Args().First()),
		}

		if ctx.Bool("show-one-offs") {
			spec.ShowOneOffs = true
		}
		builds := searcher.Search(spec)

		fmt.Printf("+-------+%-32s+%s\n", "----------------------------------", "-----------------------------------------------------")
		fmt.Printf("| %-5s | %-32s | %s\n", "Ended", "Job", "Url")
		fmt.Printf("+-------+%-32s+%s\n", "----------------------------------", "-----------------------------------------------------")

		maxAge := ctx.Int("max-age")
		for build := range builds {
			if maxAge > 0 && age(build) > maxAge {
				break
			}

			fmt.Printf("| %-5s | %-32s | %s\n", timeSince(build.EndTime), build.PipelineName+"/"+build.JobName, build.ConcourseURL)
		}

		return nil
	},
}

Functions

This section is empty.

Types

type Aggregator

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

func NewAggregator

func NewAggregator() *Aggregator

type Failure

type Failure struct {
	Description  string
	JobName      string
	Date         int64
	ConcourseURL string
}

type FailuresInfo

type FailuresInfo struct {
	Count         int
	LastOccurance int64
	Failures      []Failure
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL