From 162f1fb1b75efc11886845ae3a808267cfeddcc8 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 23 Jul 2019 19:54:50 +0300 Subject: [PATCH] all: small updates after PR #114 --- .travis.yml | 8 ++++++-- Makefile | 12 +++++------- README.md | 4 ++++ app/victoria-metrics/Makefile | 9 +++++++++ deployment/docker/Makefile | 3 ++- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index e4de0cde6..f5c2bc02f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,12 @@ before_install: script: - make check_all - git diff --exit-code - - make test_full + - make test-full + - make test-pure - make victoria-metrics + - make victoria-metrics-pure + - make victoria-metrics-arm + - make victoria-metrics-arm64 after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file + - bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index ae66b8b69..646967d56 100644 --- a/Makefile +++ b/Makefile @@ -53,15 +53,13 @@ install-errcheck: check_all: fmt vet lint errcheck golangci-lint test: - GO111MODULE=on go test -mod=vendor ./lib/... - GO111MODULE=on go test -mod=vendor ./app/... - -test_full: - GO111MODULE=on go test -tags=integration -mod=vendor -coverprofile=coverage.txt -covermode=atomic ./lib/... ./app/... + GO111MODULE=on go test -tags=integration -mod=vendor ./lib/... ./app/... test-pure: - GO111MODULE=on CGO_ENABLED=0 go test -mod=vendor ./lib/... - GO111MODULE=on CGO_ENABLED=0 go test -mod=vendor ./app/... + GO111MODULE=on CGO_ENABLED=0 go test -tags=integration -mod=vendor ./lib/... ./app/... + +test-full: + GO111MODULE=on go test -tags=integration -mod=vendor -coverprofile=coverage.txt -covermode=atomic ./lib/... ./app/... benchmark: GO111MODULE=on go test -mod=vendor -bench=. ./lib/... diff --git a/README.md b/README.md index f1cdd50dc..4331ecf64 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,10 @@ to your needs. #### Pure Go (CGO_ENABLED=0) +`Pure Go` mode builds only Go code without [cgo](https://golang.org/cmd/cgo/) dependencies. +This is experimental mode, which may result in lower compression ratio and slower decompression performance. +Use it with caution! + 1. [Install Go](https://golang.org/doc/install). The minimum supported version is Go 1.12. 2. Run `make victoria-metrics-pure` from the root folder of the repository. It will build `victoria-metrica-pure` binary and put it into the `bin` folder. diff --git a/app/victoria-metrics/Makefile b/app/victoria-metrics/Makefile index 33ad19296..9cfcb1e65 100644 --- a/app/victoria-metrics/Makefile +++ b/app/victoria-metrics/Makefile @@ -23,12 +23,21 @@ run-victoria-metrics: victoria-metrics-arm: CGO_ENABLED=0 GOOS=linux GOARCH=arm GO111MODULE=on go build -mod=vendor -ldflags "$(GO_BUILDINFO)" -o bin/victoria-metrics-arm ./app/victoria-metrics +victoria-metrics-arm-prod: + APP_NAME=victoria-metrics APP_SUFFIX='-arm' DOCKER_OPTS='--env CGO_ENABLED=0 --env GOARCH=arm' $(MAKE) app-via-docker + victoria-metrics-arm64: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GO111MODULE=on go build -mod=vendor -ldflags "$(GO_BUILDINFO)" -o bin/victoria-metrics-arm64 ./app/victoria-metrics +victoria-metrics-arm64-prod: + APP_NAME=victoria-metrics APP_SUFFIX='-arm64' DOCKER_OPTS='--env CGO_ENABLED=0 --env GOARCH=arm64' $(MAKE) app-via-docker + victoria-metrics-pure: GO111MODULE=on CGO_ENABLED=0 go build -mod=vendor -ldflags "$(GO_BUILDINFO)" -o bin/victoria-metrics-pure ./app/victoria-metrics +victoria-metrics-pure-prod: + APP_NAME=victoria-metrics APP_SUFFIX='-pure' DOCKER_OPTS='--env CGO_ENABLED=0' $(MAKE) app-via-docker + ### Packaging for Debian - amd64 victoria-metrics-package-deb: victoria-metrics echo "GO_BUILDINFO:" "$(GO_BUILDINFO)" diff --git a/deployment/docker/Makefile b/deployment/docker/Makefile index 973e82a80..6fcb0e789 100644 --- a/deployment/docker/Makefile +++ b/deployment/docker/Makefile @@ -19,8 +19,9 @@ app-via-docker: package-certs package-builder --mount type=bind,src="$(shell pwd)/gocache-for-docker",dst=/gocache \ --env GOCACHE=/gocache \ --env GO111MODULE=on \ + $(DOCKER_OPTS) \ $(BUILDER_IMAGE) \ - go build $(RACE) -mod=vendor -ldflags "-s -w -extldflags '-static' $(GO_BUILDINFO)" -tags 'netgo osusergo' -o bin/$(APP_NAME)-prod $(PKG_PREFIX)/app/$(APP_NAME) + go build $(RACE) -mod=vendor -ldflags "-s -w -extldflags '-static' $(GO_BUILDINFO)" -tags 'netgo osusergo' -o bin/$(APP_NAME)$(APP_SUFFIX)-prod $(PKG_PREFIX)/app/$(APP_NAME) package-via-docker: (docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q '$(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE)') || (\