Commit c9b5cedb authored by Miek Gieben's avatar Miek Gieben Committed by Yong Tang

Presubmit (#1719)

* build: add presubmits

We didn't have a way to encode presubmit; with this hack we can just
run a bunch of script on the build; this allows us to automatically
capture things like using the wrong context and maybe other fluff.

This allows us to cut down on code reviews and just have the build fail.

* hook it up

* put presubmit in checks; so we do it for tests as well

* Add explicit exit 1 if things fails
parent 582f91f3
#!/bin/bash
echo "** presubmit/$(basename $0)"
if grep -lr "golang.org/x/net/context" "$@"; then
echo "** presubmit/$(basename $0): please use std lib's 'context' instead"
exit 1
fi
...@@ -5,6 +5,7 @@ SYSTEM:= ...@@ -5,6 +5,7 @@ SYSTEM:=
CHECKS:=check godeps CHECKS:=check godeps
VERBOSE:=-v VERBOSE:=-v
GOPATH?=$(HOME)/go GOPATH?=$(HOME)/go
PRESUBMIT:=core coremain plugin
all: coredns all: coredns
...@@ -13,7 +14,7 @@ coredns: $(CHECKS) ...@@ -13,7 +14,7 @@ coredns: $(CHECKS)
CGO_ENABLED=0 $(SYSTEM) go build $(VERBOSE) -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(GITCOMMIT)" -o $(BINARY) CGO_ENABLED=0 $(SYSTEM) go build $(VERBOSE) -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(GITCOMMIT)" -o $(BINARY)
.PHONY: check .PHONY: check
check: linter goimports core/zplugin.go core/dnsserver/zdirectives.go godeps check: presubmit linter goimports core/zplugin.go core/dnsserver/zdirectives.go godeps
.PHONY: test .PHONY: test
test: check test: check
...@@ -87,6 +88,11 @@ linter: ...@@ -87,6 +88,11 @@ linter:
goimports: goimports:
( gometalinter --deadline=2m --disable-all --enable=goimports --vendor --exclude=^pb/ ./... || true ) ( gometalinter --deadline=2m --disable-all --enable=goimports --vendor --exclude=^pb/ ./... || true )
# Presubmit runs all scripts in .presubmit; any non 0 exit code will fail the build.
.PHONY: presubmit
presubmit:
@for pre in $(PWD)/.presubmit/* ; do "$$pre" $(PRESUBMIT); done
.PHONY: clean .PHONY: clean
clean: clean:
go clean go clean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment