Skip to content

Commit

Permalink
add circle and .hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc committed Oct 21, 2015
1 parent 06fa32e commit 62bf56a
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 20 deletions.
15 changes: 15 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

fmtcount=`git ls-files | grep '.go$' | xargs gofmt -l 2>&1 | wc -l`
if [ $fmtcount -gt 0 ]; then
echo "Some files aren't formatted, please run 'go fmt ./...' to format your source code before committing"
exit 1
fi

# Due to the way composites work, vet will fail for some of our tests so we ignore it
vetcount=`go tool vet --composites=false ./ 2>&1 | wc -l`
if [ $vetcount -gt 0 ]; then
echo "Some files aren't passing vet heuristics, please run 'go vet ./...' to see the errors it flags and correct your source code before committing"
exit 1
fi
exit 0
6 changes: 3 additions & 3 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ func newAlertNode(et *ExecutingTask, n *pipeline.AlertNode) (an *AlertNode, err
if err != nil {
return nil, err
}
an.levels[InfoAlert] = &expr.StatefulExpr{tree, expr.Functions()}
an.levels[InfoAlert] = &expr.StatefulExpr{Tree: tree, Funcs: expr.Functions()}
}
if n.Warn != "" {
tree, err := expr.ParseForType(n.Warn, expr.ReturnBool)
if err != nil {
return nil, err
}
an.levels[WarnAlert] = &expr.StatefulExpr{tree, expr.Functions()}
an.levels[WarnAlert] = &expr.StatefulExpr{Tree: tree, Funcs: expr.Functions()}
}
if n.Crit != "" {
tree, err := expr.ParseForType(n.Crit, expr.ReturnBool)
if err != nil {
return nil, err
}
an.levels[CritAlert] = &expr.StatefulExpr{tree, expr.Functions()}
an.levels[CritAlert] = &expr.StatefulExpr{Tree: tree, Funcs: expr.Functions()}
}
// Configure flapping
if n.UseFlapping {
Expand Down
16 changes: 16 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
machine:
environment:
IMPORT_PATH: "github.com/influxdb/kapacitor"

dependencies:
override:
- mkdir -p "$GOPATH/src/$IMPORT_PATH"
- rsync -azC --delete ./ "$GOPATH/src/$IMPORT_PATH/"

test:
pre:
- go vet ./...
- go get ./...

override:
- go test ./...
2 changes: 1 addition & 1 deletion cmd/kapacitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ Options:

func doDefine(args []string) error {

if *dtick == "" || *dname == "" || *dtick == "" {
if *dtick == "" || *dname == "" || *dtype == "" {
fmt.Fprintln(os.Stderr, "Must pass name,tick and type options.")
defineFlags.Usage()
os.Exit(2)
Expand Down
2 changes: 1 addition & 1 deletion expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func ExprFunc(field, e string) (TransFunc, error) {
}
x := &expression{
field: field,
se: &expr.StatefulExpr{t, expr.Functions()},
se: &expr.StatefulExpr{Tree: t, Funcs: expr.Functions()},
}
return TransFunc(x.Eval), nil
}
Expand Down
4 changes: 2 additions & 2 deletions expr/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func isValidIdent(r rune) bool {

func lexString(l *lexer) stateFn {
if n := l.next(); n != '\'' {
return l.errorf(`unexpected "%s" expected "'"`, n)
return l.errorf(`unexpected "%c" expected "'"`, n)
}
for {
switch r := l.next(); {
Expand All @@ -384,7 +384,7 @@ func lexString(l *lexer) stateFn {

func lexRegex(l *lexer) stateFn {
if n := l.next(); n != '/' {
return l.errorf(`unexpected "%s" expected "/"`, n)
return l.errorf(`unexpected "%c" expected "/"`, n)
}
for {
switch r := l.next(); {
Expand Down
4 changes: 2 additions & 2 deletions expr/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func compareStrs(l, r string, o tokenType) (b bool, err error) {
case tokenRegexNotEqual:
b, err = regexp.MatchString(l, r)
default:
fmt.Errorf("unsupported operator %v on strings", o)
err = fmt.Errorf("unsupported operator %v on strings", o)
}
return
}
Expand All @@ -542,7 +542,7 @@ func compareNums(l, r float64, o tokenType) (b bool, err error) {
case tokenNotEqual:
b = l != r
default:
fmt.Errorf("unsupported operator %v on numbers", o)
err = fmt.Errorf("unsupported operator %v on numbers", o)
}
return
}
Expand Down
8 changes: 4 additions & 4 deletions functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ func (influxqlMapReducers) Bottom(field string, limit int64, fields ...string) p
// create MapReduceInfo
func mr(field, newField string, m func(*tsdb.MapInput) interface{}, r func([]interface{}) interface{}) pipeline.MapReduceInfo {
return pipeline.MapReduceInfo{
MapInfo{
field,
m,
Map: MapInfo{
Field: field,
Func: m,
},
reduce(r, newField),
Reduce: reduce(r, newField),
}
}

Expand Down
2 changes: 1 addition & 1 deletion integrations/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (m *MockInfluxDBService) NewClient() (*client.Client, error) {

func compareResults(exp, got kapacitor.Result) (bool, string) {
if (exp.Err == nil && got.Err != nil) || (exp.Err != nil && got.Err == nil) {
return false, fmt.Sprintf("unexpected error: exp %p got %p", exp.Err, got.Err)
return false, fmt.Sprintf("unexpected error: exp %v got %v", exp.Err, got.Err)
}
if exp.Err != nil && exp.Err.Error() != got.Err.Error() {
return false, fmt.Sprintf("unexpected error: exp %v got %v", exp.Err, got.Err)
Expand Down
4 changes: 2 additions & 2 deletions pipeline/map_reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package pipeline

// tick:ignore
type MapReduceInfo struct {
MapI interface{}
ReduceI interface{}
Map interface{}
Reduce interface{}
}

// Performs a map operation on the data stream.
Expand Down
4 changes: 2 additions & 2 deletions pipeline/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ func (n *chainnode) MapReduce(mr MapReduceInfo) *ReduceNode {
case StreamEdge:
panic("cannot MapReduce stream edge, did you forget to window the data?")
case BatchEdge:
m = newMapNode(mr.MapI)
r = newReduceNode(mr.ReduceI)
m = newMapNode(mr.Map)
r = newReduceNode(mr.Reduce)
}
n.linkChild(m)
m.linkChild(r)
Expand Down
2 changes: 1 addition & 1 deletion stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newStreamNode(et *ExecutingTask, n *pipeline.StreamNode) (*StreamNode, erro
if err != nil {
return nil, err
}
sn.predicate = &expr.StatefulExpr{tree, expr.Functions()}
sn.predicate = &expr.StatefulExpr{Tree: tree, Funcs: expr.Functions()}
}
return sn, nil
}
Expand Down
2 changes: 1 addition & 1 deletion where.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func newWhereNode(et *ExecutingTask, n *pipeline.WhereNode) (wn *WhereNode, err
if err != nil {
return nil, err
}
wn.predicate = &expr.StatefulExpr{tree, expr.Functions()}
wn.predicate = &expr.StatefulExpr{Tree: tree, Funcs: expr.Functions()}
return
}

Expand Down

0 comments on commit 62bf56a

Please sign in to comment.