2018-05-22 17:28:04 +00:00
|
|
|
# Top level Makefile for the entire project
|
|
|
|
#
|
2018-06-25 23:24:52 +00:00
|
|
|
# This Makefile encodes the "go generate" prerequeisites ensuring that the proper tooling is installed and
|
|
|
|
# that the generate steps are executed when their prerequeisites files change.
|
|
|
|
#
|
2018-05-22 17:28:04 +00:00
|
|
|
# This Makefile follows a few conventions:
|
|
|
|
#
|
|
|
|
# * All cmds must be added to this top level Makefile.
|
|
|
|
# * All binaries are placed in ./bin, its recommended to add this directory to your PATH.
|
|
|
|
# * Each package that has a need to run go generate, must have its own Makefile for that purpose.
|
|
|
|
# * All recursive Makefiles must support the targets: all and clean.
|
|
|
|
#
|
|
|
|
|
2018-09-25 22:40:46 +00:00
|
|
|
SUBDIRS := query task
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
GO_ARGS=-tags '$(GO_TAGS)'
|
|
|
|
|
|
|
|
# Test vars can be used by all recursive Makefiles
|
2018-06-25 23:24:52 +00:00
|
|
|
export GOOS=$(shell go env GOOS)
|
2018-08-26 18:54:24 +00:00
|
|
|
export GO_BUILD=env GO111MODULE=on go build $(GO_ARGS)
|
|
|
|
export GO_TEST=env GO111MODULE=on go test $(GO_ARGS)
|
|
|
|
# Do not add GO111MODULE=on to the call to go generate so it doesn't pollute the environment.
|
2018-05-22 17:28:04 +00:00
|
|
|
export GO_GENERATE=go generate $(GO_ARGS)
|
2018-08-26 18:54:24 +00:00
|
|
|
export GO_VET=env GO111MODULE=on go vet $(GO_ARGS)
|
2018-09-11 15:22:06 +00:00
|
|
|
export PATH := $(PWD)/bin/$(GOOS):$(PATH)
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
# All go source files
|
|
|
|
SOURCES := $(shell find . -name '*.go' -not -name '*_test.go')
|
|
|
|
|
|
|
|
# All go source files excluding the vendored sources.
|
|
|
|
SOURCES_NO_VENDOR := $(shell find . -path ./vendor -prune -o -name "*.go" -not -name '*_test.go' -print)
|
|
|
|
|
2018-09-11 20:55:36 +00:00
|
|
|
# All assets for chronograf
|
|
|
|
UISOURCES := $(shell find chronograf/ui -type f -not \( -path chronograf/ui/build/\* -o -path chronograf/ui/node_modules/\* -o -path chronograf/ui/.cache/\* -o -name Makefile -prune \) )
|
|
|
|
|
|
|
|
# All precanned dashboards
|
|
|
|
PRECANNED := $(shell find chronograf/canned -name '*.json')
|
|
|
|
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
# List of binary cmds to build
|
2018-06-25 23:24:52 +00:00
|
|
|
CMDS := \
|
|
|
|
bin/$(GOOS)/influx \
|
2018-09-25 23:02:06 +00:00
|
|
|
bin/$(GOOS)/influxd
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
# List of utilities to build as part of the build process
|
2018-06-25 23:24:52 +00:00
|
|
|
UTILS := \
|
|
|
|
bin/$(GOOS)/pigeon \
|
2018-08-02 21:02:38 +00:00
|
|
|
bin/$(GOOS)/protoc-gen-gogofaster \
|
2018-08-27 15:34:17 +00:00
|
|
|
bin/$(GOOS)/goreleaser \
|
|
|
|
bin/$(GOOS)/go-bindata
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-08-27 15:34:17 +00:00
|
|
|
# Default target to build all go commands.
|
2018-05-22 17:28:04 +00:00
|
|
|
#
|
2018-08-27 15:34:17 +00:00
|
|
|
# This target sets up the dependencies to correctly build all go commands.
|
2018-05-22 17:28:04 +00:00
|
|
|
# Other targets must depend on this target to correctly builds CMDS.
|
2018-09-04 22:26:40 +00:00
|
|
|
all: GO_ARGS=-tags 'assets $(GO_TAGS)'
|
2018-09-26 05:32:44 +00:00
|
|
|
all: node_modules $(UTILS) subdirs chronograf/ui generate $(CMDS)
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
# Target to build subdirs.
|
|
|
|
# Each subdirs must support the `all` target.
|
|
|
|
subdirs: $(SUBDIRS)
|
2018-06-25 23:24:52 +00:00
|
|
|
@for d in $^; do $(MAKE) -C $$d all; done
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-09-25 22:40:46 +00:00
|
|
|
|
|
|
|
chronograf/ui:
|
|
|
|
$(MAKE) -C chronograf/ui all
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
#
|
|
|
|
# Define targets for commands
|
|
|
|
#
|
2018-06-25 23:24:52 +00:00
|
|
|
$(CMDS): $(SOURCES)
|
2018-09-25 16:33:07 +00:00
|
|
|
$(GO_BUILD) -o $@ ./cmd/$(shell basename "$@")
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Define targets for utilities
|
|
|
|
#
|
|
|
|
|
2018-08-26 18:54:24 +00:00
|
|
|
bin/$(GOOS)/pigeon: go.mod go.sum
|
|
|
|
$(GO_BUILD) -o $@ github.com/mna/pigeon
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-08-26 18:54:24 +00:00
|
|
|
bin/$(GOOS)/protoc-gen-gogofaster: go.mod go.sum
|
|
|
|
$(GO_BUILD) -o $@ github.com/gogo/protobuf/protoc-gen-gogofaster
|
2018-08-02 21:02:38 +00:00
|
|
|
|
2018-08-26 18:54:24 +00:00
|
|
|
bin/$(GOOS)/goreleaser: go.mod go.sum
|
|
|
|
$(GO_BUILD) -o $@ github.com/goreleaser/goreleaser
|
2018-05-22 20:42:32 +00:00
|
|
|
|
2018-08-26 18:54:24 +00:00
|
|
|
bin/$(GOOS)/go-bindata: go.mod go.sum
|
|
|
|
$(GO_BUILD) -o $@ github.com/kevinburke/go-bindata/go-bindata
|
2018-07-23 21:42:03 +00:00
|
|
|
|
2018-09-25 22:40:46 +00:00
|
|
|
|
2018-08-27 15:34:17 +00:00
|
|
|
node_modules: chronograf/ui/node_modules
|
|
|
|
|
2018-09-27 17:46:48 +00:00
|
|
|
chronograf_lint:
|
|
|
|
make -C chronograf/ui lint
|
|
|
|
|
2018-09-11 20:55:36 +00:00
|
|
|
chronograf/ui/node_modules:
|
|
|
|
make -C chronograf/ui node_modules
|
2018-07-23 21:42:03 +00:00
|
|
|
|
2018-09-25 22:40:46 +00:00
|
|
|
chronograf/ui/build:
|
|
|
|
mkdir -p chronograf/ui/build
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
#
|
|
|
|
# Define action only targets
|
|
|
|
#
|
|
|
|
|
|
|
|
fmt: $(SOURCES_NO_VENDOR)
|
2018-10-08 18:16:06 +00:00
|
|
|
gofmt -w -s $^
|
|
|
|
|
|
|
|
checkfmt: $(SOURCES_NO_VENDOR)
|
|
|
|
./etc/checkfmt.sh
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-09-11 20:55:36 +00:00
|
|
|
chronograf/dist/dist_gen.go: chronograf/ui/build $(UISOURCES)
|
2018-09-04 22:26:40 +00:00
|
|
|
$(GO_GENERATE) ./chronograf/dist/...
|
2018-09-11 20:55:36 +00:00
|
|
|
|
|
|
|
chronograf/server/swagger_gen.go: chronograf/server/swagger.json
|
2018-09-04 22:26:40 +00:00
|
|
|
$(GO_GENERATE) ./chronograf/server/...
|
2018-09-11 20:55:36 +00:00
|
|
|
|
|
|
|
chronograf/canned/bin_gen.go: $(PRECANNED)
|
2018-09-04 22:26:40 +00:00
|
|
|
$(GO_GENERATE) ./chronograf/canned/...
|
2018-07-24 20:18:21 +00:00
|
|
|
|
2018-09-11 20:55:36 +00:00
|
|
|
generate: chronograf/dist/dist_gen.go chronograf/server/swagger_gen.go chronograf/canned/bin_gen.go
|
|
|
|
|
2018-08-27 15:34:17 +00:00
|
|
|
test-js: node_modules
|
2018-09-11 20:55:36 +00:00
|
|
|
make -C chronograf/ui test
|
2018-07-24 20:18:21 +00:00
|
|
|
|
2018-08-26 18:54:24 +00:00
|
|
|
test-go:
|
2018-05-22 17:28:04 +00:00
|
|
|
$(GO_TEST) ./...
|
|
|
|
|
2018-08-27 15:34:17 +00:00
|
|
|
test: test-go test-js
|
|
|
|
|
2018-08-26 18:54:24 +00:00
|
|
|
test-go-race:
|
ci: enable GOCACHE for Circle
With a clean GOCACHE, `make test-go` took about 30 seconds. It's hard to
tell the exact time since `make vendor` was implicitly executed in the
same block.
Now, `make test-go` uses GOCACHE and takes about 5 seconds to restore
the cache, then about 8 seconds to run through a fully cached set of
tests. If any test is actually broken or doesn't compile, this will give
us fast feedback.
But this change also runs `go test -race -count=1`, so that we fully
exercise any possible data races. That currently takes about 19 seconds.
Then finally we save GOCACHE, which has our `go test` results, and a
populated build cache for our test files, including built with the race
detector. Saving that takes about 14 seconds.
That means we took about 30 seconds originally to just run `go test
-count=1`, and now we take (5+8+19+14)=46 seconds to run plain go test
and go test with the race detector. There's probably an argument to be
made for just running with the race detector, but running both gives us
more coverage IMO, and it does allow us to run tests that aren't enabled
on race builds.
See https://circleci.com/gh/influxdata/platform/1840 for a run with full
caching.
2018-08-28 16:39:44 +00:00
|
|
|
$(GO_TEST) -race -count=1 ./...
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-08-27 15:34:17 +00:00
|
|
|
vet:
|
2018-05-22 22:19:04 +00:00
|
|
|
$(GO_VET) -v ./...
|
|
|
|
|
2018-08-26 18:54:24 +00:00
|
|
|
bench:
|
2018-05-22 17:28:04 +00:00
|
|
|
$(GO_TEST) -bench=. -run=^$$ ./...
|
|
|
|
|
2018-07-02 16:36:41 +00:00
|
|
|
nightly: bin/$(GOOS)/goreleaser all
|
2018-09-26 05:32:44 +00:00
|
|
|
PATH=./bin/$(GOOS):${PATH} goreleaser --snapshot --rm-dist --publish-snapshots
|
2018-05-22 20:42:32 +00:00
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
# Recursively clean all subdirs
|
|
|
|
clean: $(SUBDIRS)
|
2018-06-25 23:24:52 +00:00
|
|
|
@for d in $^; do $(MAKE) -C $$d $(MAKECMDGOALS); done
|
2018-09-25 22:40:46 +00:00
|
|
|
$(MAKE) -C chronograf/ui $(MAKECMDGOALS)
|
2018-05-22 17:28:04 +00:00
|
|
|
rm -rf bin
|
|
|
|
|
2018-09-25 22:40:46 +00:00
|
|
|
|
|
|
|
define CHRONOGIRAFFE
|
|
|
|
._ o o
|
|
|
|
\_`-)|_
|
|
|
|
,"" _\_
|
|
|
|
," ## | 0 0.
|
|
|
|
," ## ,-\__ `.
|
|
|
|
," / `--._;) - "HAI, I'm Chronogiraffe. Let's be friends!"
|
|
|
|
," ## /
|
|
|
|
," ## /
|
|
|
|
endef
|
|
|
|
export CHRONOGIRAFFE
|
|
|
|
chronogiraffe: $(UTILS) subdirs generate $(CMDS)
|
|
|
|
@echo "$$CHRONOGIRAFFE"
|
|
|
|
|
|
|
|
run: chronogiraffe
|
|
|
|
./bin/$(GOOS)/influxd --developer-mode=true
|
|
|
|
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
# .PHONY targets represent actions that do not create an actual file.
|
2018-09-26 05:32:44 +00:00
|
|
|
.PHONY: all subdirs $(SUBDIRS) chronograf/ui run fmt test test-go test-js test-go-race bench clean node_modules vet nightly chronogiraffe
|