From 8cdf7b17905f490188c77e317147d7d21a8f9bf5 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Sun, 13 Nov 2016 22:47:11 -0800 Subject: [PATCH] makefile: Make misc improvements * Add test target and re-use in travis * Add timeout test target * Build binary into ./bin folder * Phony everything --- .gitignore | 1 + .travis.yml | 2 +- Dockerfile | 4 ++-- Makefile | 13 +++++++++++-- bin/.gitkeep | 0 5 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .gitignore create mode 100644 bin/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..66eeedc5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/node-problem-detector diff --git a/.travis.yml b/.travis.yml index 4f5147c4..e9240e10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,5 +13,5 @@ install: - mv $TRAVIS_BUILD_DIR $HOME/gopath/src/k8s.io/node-problem-detector - cd $HOME/gopath/src/k8s.io/node-problem-detector script: - - go test -v -race ./pkg/... + - make test - go build -race diff --git a/Dockerfile b/Dockerfile index 83f2591a..727dd721 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM alpine:3.1 +FROM alpine:3.4 MAINTAINER Random Liu -ADD node-problem-detector /node-problem-detector +ADD ./bin/node-problem-detector /node-problem-detector ADD config /config ENTRYPOINT ["/node-problem-detector", "--kernel-monitor=/config/kernel-monitor.json"] diff --git a/Makefile b/Makefile index d8ad299d..5f4304e3 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +.PHONY: all container push clean node-problem-detector + all: push # See node-problem-detector.yaml for the version currently running-- bump this ahead before rebuilding! @@ -5,9 +7,16 @@ TAG = v0.2 PROJ = google_containers -node-problem-detector: node_problem_detector.go +PKG_SOURCES := $(shell find pkg -name '*.go') + +node-problem-detector: ./bin/node-problem-detector + +./bin/node-problem-detector: $(PKG_SOURCES) node_problem_detector.go CGO_ENABLED=0 GOOS=linux godep go build -a -installsuffix cgo -ldflags '-w' -o node-problem-detector +test: + go test -timeout=1m -v -race ./pkg/... + container: node-problem-detector docker build -t gcr.io/$(PROJ)/node-problem-detector:$(TAG) . @@ -15,4 +24,4 @@ push: container gcloud docker push gcr.io/$(PROJ)/node-problem-detector:$(TAG) clean: - rm -f node-problem-detector + rm -f ./bin/node-problem-detector diff --git a/bin/.gitkeep b/bin/.gitkeep new file mode 100644 index 00000000..e69de29b