influxdb/GNUmakefile

195 lines
5.5 KiB
Makefile
Raw Permalink Normal View History

2018-05-22 17:28:04 +00:00
# Top level Makefile for the entire project
#
2019-12-11 03:45:25 +00:00
# This Makefile encodes the "go generate" prerequisites ensuring that the proper tooling is installed and
# that the generate steps are executed when their prerequisite 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.
#
export GOPATH=$(shell go env GOPATH)
export GOOS=$(shell go env GOOS)
export GOARCH=$(shell go env GOARCH)
ifneq (,$(filter $(GOARCH),amd64 s390x))
# Including the assets tag requires the UI to be built for compilation to succeed.
# Don't force it for running tests.
GO_TEST_TAGS :=
GO_BUILD_TAGS := assets
else
# noasm needed to avoid a panic in Flux for non-amd64, non-s390x.
GO_TEST_TAGS := noasm
GO_BUILD_TAGS := assets,noasm
endif
# Tags used for builds and tests on all architectures
COMMON_TAGS := sqlite_foreign_keys,sqlite_json
GO_TEST_ARGS := -tags '$(COMMON_TAGS),$(GO_TEST_TAGS)'
GO_BUILD_ARGS := -tags '$(COMMON_TAGS),$(GO_BUILD_TAGS)'
# Use default flags, but allow adding -gcflags "..." if desired. Eg, for debug
# builds, may want to use GCFLAGS="all=-N -l" in the build environment.
GCFLAGS ?=
ifneq ($(GCFLAGS),)
GO_BUILD_ARGS += -gcflags "$(GCFLAGS)"
endif
ifeq ($(OS), Windows_NT)
VERSION := $(shell git describe --exact-match --tags 2>nil)
else
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
endif
COMMIT := $(shell git rev-parse --short HEAD)
LDFLAGS := $(LDFLAGS) -X main.commit=$(COMMIT)
ifdef VERSION
LDFLAGS += -X main.version=$(VERSION)
endif
# Allow for `go test` to be swapped out by other tooling, i.e. `gotestsum`
GO_TEST_CMD=go test
# Allow for a subset of tests to be specified.
GO_TEST_PATHS=./...
2018-05-22 17:28:04 +00:00
# Test vars can be used by all recursive Makefiles
export PKG_CONFIG:=$(PWD)/scripts/pkg-config.sh
export GO_BUILD=env GO111MODULE=on go build $(GO_BUILD_ARGS) -ldflags "$(LDFLAGS)"
export GO_INSTALL=env GO111MODULE=on go install $(GO_BUILD_ARGS) -ldflags "$(LDFLAGS)"
export GO_TEST=env GOTRACEBACK=all GO111MODULE=on $(GO_TEST_CMD) $(GO_TEST_ARGS)
# Do not add GO111MODULE=on to the call to go generate so it doesn't pollute the environment.
export GO_GENERATE=go generate $(GO_BUILD_ARGS)
export GO_VET=env GO111MODULE=on go vet $(GO_TEST_ARGS)
export GO_RUN=env GO111MODULE=on go run $(GO_BUILD_ARGS)
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') go.mod go.sum
2018-05-22 17:28:04 +00:00
# All go source files excluding the vendored sources.
SOURCES_NO_VENDOR := $(shell find . -path ./vendor -prune -o -name "*.go" -not -name '*_test.go' -print)
# List of binary cmds to build
CMDS := \
bin/$(GOOS)/influxd
2018-05-22 17:28:04 +00:00
all: generate $(CMDS)
2018-05-22 17:28:04 +00:00
#
# Define targets for commands
#
bin/$(GOOS)/influxd: $(SOURCES)
$(GO_BUILD) -o $@ ./cmd/$(shell basename "$@")
2018-05-22 17:28:04 +00:00
influxd: bin/$(GOOS)/influxd
static/data/build: scripts/fetch-ui-assets.sh
./scripts/fetch-ui-assets.sh
static/data/swagger.json: scripts/fetch-swagger.sh
./scripts/fetch-swagger.sh
# static/static_gen.go is the output of go-bindata, embedding all assets used by the UI.
static/static_gen.go: static/data/build static/data/swagger.json
$(GO_GENERATE) ./static
2018-05-22 17:28:04 +00:00
#
# Define action only targets
#
fmt: $(SOURCES_NO_VENDOR)
2021-01-29 16:50:57 +00:00
./etc/fmt.sh
checkfmt:
./etc/checkfmt.sh
$(GO_RUN) github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker
2018-05-22 17:28:04 +00:00
tidy:
GO111MODULE=on go mod tidy
checktidy:
./etc/checktidy.sh
checkgenerate:
./etc/checkgenerate.sh
2018-07-24 20:18:21 +00:00
checksqlmigrations:
./etc/check-sql-migrations.sh
# generate-web-assets outputs all the files needed to link the UI to the back-end.
# Currently, none of these files are tracked by git.
generate-web-assets: static/static_gen.go
# generate-sources outputs all the Go files generated from protobufs, tmpls, and other tooling.
# These files are tracked by git; CI will enforce that they are up-to-date.
generate-sources: protoc tmpl stringer goimports
$(GO_GENERATE) ./influxql/... ./models/... ./pkg/... ./storage/... ./tsdb/... ./v1/...
generate: generate-web-assets generate-sources
protoc:
$(GO_INSTALL) google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
tmpl:
$(GO_INSTALL) github.com/benbjohnson/tmpl
stringer:
$(GO_INSTALL) golang.org/x/tools/cmd/stringer
goimports:
$(GO_INSTALL) golang.org/x/tools/cmd/goimports
2018-07-24 20:18:21 +00:00
test-go:
$(GO_TEST) $(GO_TEST_PATHS)
2018-05-22 17:28:04 +00:00
test-flux:
@./etc/test-flux.sh
test-tls:
@./etc/test-tls.sh
feat(vault): add vault implementation of secret service test(platform): run testcontainer integration tests for nightly release Integration tests for the vault secret service using testcontiners should not run along with unit tests, however, they should run on some regular schedule. This commit introduces `make test-integration` which runs integration tests for vault using testcontainers. The command introduced relies on docker being available on the host it is executed on. chore(platform): make go modules tidy chore: try to fix go mod chore(platform): remove explicit logrus dependency chore(platform): run go mod tidy chore(platform): replace github.com/Sirupsen/logrus with github.com/sirupsen/logrus chore(platform): update docker dependency feat(vault): add vault implementation of secret service test(platform): run testcontainer integration tests for nightly release Integration tests for the vault secret service using testcontiners should not run along with unit tests, however, they should run on some regular schedule. This commit introduces `make test-integration` which runs integration tests for vault using testcontainers. The command introduced relies on docker being available on the host it is executed on. chore(platform): make go modules tidy chore: try to fix go mod chore(platform): run go mod tidy feat(vault): add vault implementation of secret service chore(platform): make go modules tidy feat(platform): add Put/Patch/Delete methods on secret service feat(vault): add Put/Patch/Delete methods on vault secret service feat(http): add http handler methods for secret service feat(bolt): add Put/Delete/Patch methods to bolt secret service feat(testing): add tests for Put/Patch/Delete methods in secret service feat(mock): add mock secret service feat(http): add tests for secrets endpoints feat(http): update swagger for secrets endpoints chore: run go mod tidy
2018-11-16 16:45:00 +00:00
test-integration: GO_TAGS=integration
test-integration:
$(GO_TEST) -count=1 $(GO_TEST_PATHS)
feat(vault): add vault implementation of secret service test(platform): run testcontainer integration tests for nightly release Integration tests for the vault secret service using testcontiners should not run along with unit tests, however, they should run on some regular schedule. This commit introduces `make test-integration` which runs integration tests for vault using testcontainers. The command introduced relies on docker being available on the host it is executed on. chore(platform): make go modules tidy chore: try to fix go mod chore(platform): remove explicit logrus dependency chore(platform): run go mod tidy chore(platform): replace github.com/Sirupsen/logrus with github.com/sirupsen/logrus chore(platform): update docker dependency feat(vault): add vault implementation of secret service test(platform): run testcontainer integration tests for nightly release Integration tests for the vault secret service using testcontiners should not run along with unit tests, however, they should run on some regular schedule. This commit introduces `make test-integration` which runs integration tests for vault using testcontainers. The command introduced relies on docker being available on the host it is executed on. chore(platform): make go modules tidy chore: try to fix go mod chore(platform): run go mod tidy feat(vault): add vault implementation of secret service chore(platform): make go modules tidy feat(platform): add Put/Patch/Delete methods on secret service feat(vault): add Put/Patch/Delete methods on vault secret service feat(http): add http handler methods for secret service feat(bolt): add Put/Delete/Patch methods to bolt secret service feat(testing): add tests for Put/Patch/Delete methods in secret service feat(mock): add mock secret service feat(http): add tests for secrets endpoints feat(http): update swagger for secrets endpoints chore: run go mod tidy
2018-11-16 16:45:00 +00:00
test: test-go
test-go-race:
$(GO_TEST) -v -race -count=1 $(GO_TEST_PATHS)
2018-05-22 17:28:04 +00:00
vet:
2018-05-22 22:19:04 +00:00
$(GO_VET) -v ./...
bench:
2018-05-22 17:28:04 +00:00
$(GO_TEST) -bench=. -run=^$$ ./...
build: all
pkg-config:
$(GO_INSTALL) github.com/influxdata/pkg-config
clean:
$(RM) -r static/static_gen.go static/data
$(RM) -r bin
$(RM) -r dist
# generate feature flags
flags:
$(GO_GENERATE) ./kit/feature
docker-image-influx:
@cp .gitignore .dockerignore
@docker image build -t influxdb:dev --target influx .
dshell-image:
@cp .gitignore .dockerignore
@docker image build --build-arg "USERID=$(shell id -u)" -t influxdb:dshell --target dshell .
dshell: dshell-image
@docker container run --rm -p 8086:8086 -p 8080:8080 -u $(shell id -u) -it -v $(shell pwd):/code -w /code influxdb:dshell
2018-05-22 17:28:04 +00:00
# .PHONY targets represent actions that do not create an actual file.
.PHONY: all $(SUBDIRS) run fmt checkfmt tidy checktidy checkgenerate test test-go test-go-race test-tls bench clean node_modules vet nightly dist protoc influxd libflux flags dshell dclean docker-image-flux docker-image-influx pkg-config