Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-07-23 15:28:26 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-07-29 09:32:56 +0300
commit00608758def7e556d1cb79d1eca3fbea748a0fc8 (patch)
tree59589ce4bedc69f637a2a0dbe9e65fca98401216
parent93949762d15bf1b9e59947f72038a006f23eab9d (diff)
Makefile: Use ctxt.BuildTags for static build tags
Right now, we add build flags to most every Go command in order to enable a certain set of features. This is quite tedious, and naturally there are some invocations of Go commands which do not currently have those tags set. As a result, some may be built inconsistently, but more importantly manually running e.g. `go test ./...` will not use any of those build tags at all. There's an obscure way to configure build tags such that they're always on, which is the "ctxt.BuildTags" file. It is mostly undocumented, except for one small excerpt in `go doc build`: During a particular build, the following words are satisfied: - the target operating system, as spelled by runtime.GOOS ... - "go1.14", from Go version 1.14 onward - any additional words listed in ctxt.BuildTags So it does at least seem to be officially supported, even though it's not that well known. Let's use it to avoid any inconsistencies. Furthermore, it will help us when reintroducing Git2Go into our build dependencies, which will make specifying some build tags mandatory.
-rw-r--r--Makefile11
-rw-r--r--ctxt.BuildTags3
2 files changed, 8 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index a823a01c0..cf9c95a43 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,6 @@ BUILD_TIME := $(shell date +"%Y%m%d.%H%M%S")
GITALY_VERSION := $(shell git describe --match v* 2>/dev/null | sed 's/^v//' || cat ${SOURCE_DIR}/VERSION 2>/dev/null || echo unknown)
GO_LDFLAGS := -ldflags '-X ${GITALY_PACKAGE}/internal/version.version=${GITALY_VERSION} -X ${GITALY_PACKAGE}/internal/version.buildtime=${BUILD_TIME}'
GO_TEST_LDFLAGS := -X gitlab.com/gitlab-org/gitaly/auth.timestampThreshold=5s
-GO_BUILD_TAGS := tracer_static tracer_static_jaeger continuous_profiler_stackdriver
# Dependency versions
GOLANGCI_LINT_VERSION ?= 1.27.0
@@ -123,7 +122,7 @@ all: install
.PHONY: build
build: ${SOURCE_DIR}/.ruby-bundle
- go install ${GO_LDFLAGS} -tags "${GO_BUILD_TAGS}" $(addprefix ${GITALY_PACKAGE}/cmd/, $(call find_commands))
+ go install ${GO_LDFLAGS} $(addprefix ${GITALY_PACKAGE}/cmd/, $(call find_commands))
.PHONY: install
install: build
@@ -172,17 +171,17 @@ test: test-go rspec rspec-gitlab-shell
test-go: prepare-tests ${GO_JUNIT_REPORT}
${Q}mkdir -p ${TEST_REPORT_DIR}
${Q}echo 0>${TEST_EXIT}
- ${Q}go test ${TEST_OPTIONS} -v -tags "${GO_BUILD_TAGS}" -ldflags='${GO_TEST_LDFLAGS}' -count=1 $(call find_go_packages) 2>&1 | tee ${TEST_OUTPUT} || echo $$? >${TEST_EXIT}
+ ${Q}go test ${TEST_OPTIONS} -v -ldflags='${GO_TEST_LDFLAGS}' -count=1 $(call find_go_packages) 2>&1 | tee ${TEST_OUTPUT} || echo $$? >${TEST_EXIT}
${Q}${GO_JUNIT_REPORT} <${TEST_OUTPUT} >${TEST_REPORT}
${Q}exit `cat ${TEST_EXIT}`
.PHONY: test-with-proxies
test-with-proxies: prepare-tests
- ${Q}go test -tags "${GO_BUILD_TAGS}" -count=1 -exec ${SOURCE_DIR}/_support/bad-proxies ${GITALY_PACKAGE}/internal/rubyserver/
+ ${Q}go test -count=1 -exec ${SOURCE_DIR}/_support/bad-proxies ${GITALY_PACKAGE}/internal/rubyserver/
.PHONY: test-with-praefect
test-with-praefect: build prepare-tests
- ${Q}GITALY_TEST_PRAEFECT_BIN=${BUILD_DIR}/bin/praefect go test -tags "${GO_BUILD_TAGS}" -ldflags='${GO_TEST_LDFLAGS}' -count=1 $(call find_go_packages) # count=1 bypasses go 1.10 test caching
+ ${Q}GITALY_TEST_PRAEFECT_BIN=${BUILD_DIR}/bin/praefect go test -ldflags='${GO_TEST_LDFLAGS}' -count=1 $(call find_go_packages) # count=1 bypasses go 1.10 test caching
.PHONY: race-go
race-go: TEST_OPTIONS = -race
@@ -270,7 +269,7 @@ docker:
cp -r ${GITALY_RUBY_DIR} ${BUILD_DIR}/docker/ruby
${Q}rm -rf ${BUILD_DIR}/docker/ruby/vendor/bundle
for command in $(call find_commands); do \
- GOOS=linux GOARCH=amd64 go build -tags "${GO_BUILD_TAGS}" ${GO_LDFLAGS} -o "${BUILD_DIR}/docker/bin/$${command}" ${GITALY_PACKAGE}/cmd/$${command}; \
+ GOOS=linux GOARCH=amd64 go build ${GO_LDFLAGS} -o "${BUILD_DIR}/docker/bin/$${command}" ${GITALY_PACKAGE}/cmd/$${command}; \
done
cp ${SOURCE_DIR}/Dockerfile ${BUILD_DIR}/docker/
docker build -t gitlab/gitaly:v${GITALY_VERSION} -t gitlab/gitaly:latest ${BUILD_DIR}/docker/
diff --git a/ctxt.BuildTags b/ctxt.BuildTags
new file mode 100644
index 000000000..defa606e9
--- /dev/null
+++ b/ctxt.BuildTags
@@ -0,0 +1,3 @@
+continuous_profiler_stackdriver
+tracer_static
+tracer_static_jaeger