*: Refactor build system

- Move prometheus-config-reloader to cmd/
- Refactor Makefile & contrib/kube-prometheus/Makefile
- Only execute a target if its dependencies changed
  - Create empty target file for docker builds
- Replace promu with plain static `go build`
This commit is contained in:
Max Leonard Inden
2018-06-08 17:42:27 +02:00
parent 62fa823e3e
commit 1d36d01b97

View File

@@ -1,26 +1,61 @@
JSONNET_FMT := jsonnet fmt -n 2 --max-blank-lines 2 --string-style s --comment-style s JSONNET_FMT := jsonnet fmt -n 2 --max-blank-lines 2 --string-style s --comment-style s
image: JB_BINARY:=$(GOPATH)/bin/jb
docker build -f ../../scripts/jsonnet/Dockerfile -t po-jsonnet ../../ EMBEDMD_BINARY:=$(GOPATH)/bin/embedmd
generate: image # edit 1
all: generate fmt test
../../hack/jsonnet-docker-image: ../../scripts/jsonnet/Dockerfile
# Create empty target file, for the sole purpose of recording when this target
# was last executed via the last-modification timestamp on the file. See
# https://www.gnu.org/software/make/manual/make.html#Empty-Targets
docker build -f - -t po-jsonnet . < ../../scripts/jsonnet/Dockerfile
touch $@
generate-in-docker: ../../hack/jsonnet-docker-image
@echo ">> Compiling assets and generating Kubernetes manifests" @echo ">> Compiling assets and generating Kubernetes manifests"
docker run --rm -u=$(shell id -u $(USER)):$(shell id -g $(USER)) -v $(shell dirname $(dir $(abspath $(dir $$PWD)))):/go/src/github.com/coreos/prometheus-operator/ --workdir /go/src/github.com/coreos/prometheus-operator/contrib/kube-prometheus po-jsonnet make generate-raw docker run \
--rm \
-u=$(shell id -u $(USER)):$(shell id -g $(USER)) \
-v $(shell dirname $(dir $(abspath $(dir $$PWD)))):/go/src/github.com/coreos/prometheus-operator/ \
--workdir /go/src/github.com/coreos/prometheus-operator/contrib/kube-prometheus \
po-jsonnet make generate
generate-raw: fmt generate: manifests/** **.md
jb install
**.md: $(EMBEDMD_BINARY) $(shell find examples) build.sh example.jsonnet
echo '>>> inside **.md'
$(EMBEDMD_BINARY) -w `find . -name "*.md" | grep -v vendor`
manifests/**: vendor/** example.jsonnet
./build.sh ./build.sh
vendor/**: $(JB_BINARY) jsonnetfile.json
$(JB_BINARY) install
fmt: fmt:
find . -name 'vendor' -prune -o -name '*.libsonnet' -o -name '*.jsonnet' -print | \ find . -name 'vendor' -prune -o -name '*.libsonnet' -o -name '*.jsonnet' -print | \
xargs -n 1 -- $(JSONNET_FMT) -i xargs -n 1 -- $(JSONNET_FMT) -i
test: image test: $(JB_BINARY)
@echo ">> Compiling assets and generating Kubernetes manifests" $(JB_BINARY) install
docker run --rm -u=$(shell id -u $(USER)):$(shell id -g $(USER)) -v $(shell dirname $(dir $(abspath $(dir $$PWD)))):/go/src/github.com/coreos/prometheus-operator/ --workdir /go/src/github.com/coreos/prometheus-operator/contrib/kube-prometheus po-jsonnet make test-raw
test-raw: crdtojsonnet
jb install
./test.sh ./test.sh
.PHONY: image generate crdtojsonnet generate-raw test test-raw fmt test-in-docker: ../../hack/jsonnet-docker-image
@echo ">> Compiling assets and generating Kubernetes manifests"
docker run \
--rm \
-u=$(shell id -u $(USER)):$(shell id -g $(USER)) \
-v $(shell dirname $(dir $(abspath $(dir $$PWD)))):/go/src/github.com/coreos/prometheus-operator/ \
--workdir /go/src/github.com/coreos/prometheus-operator/contrib/kube-prometheus \
po-jsonnet make test
$(JB_BINARY):
go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
$(EMBEDMD_BINARY):
go get github.com/campoy/embedmd
.PHONY: generate generate-in-docker test test-in-docker fmt