github.com/mier85/go-sensor@v1.30.1-0.20220920111756-9bf41b3bc7e0/Makefile (about) 1 include instrumentation/instapgx/Makefile 2 3 MODULES = $(filter-out $(EXCLUDE_DIRS), $(shell find . -name go.mod -exec dirname {} \;)) 4 LINTER ?= $(shell go env GOPATH)/bin/golangci-lint 5 6 # The list of Go build tags as they are specified in respective integration test files 7 INTEGRATION_TESTS = fargate gcr lambda 8 9 # the Go version to vendor dependencies listed in go.mod 10 VENDOR_GO_VERSION ?= go1.15 11 VENDOR_GO = $(shell go env GOPATH)/bin/$(VENDOR_GO_VERSION) 12 MODULES_VENDOR = $(addsuffix /vendor,$(MODULES)) 13 14 ifeq ($(RUN_LINTER),yes) 15 test: $(LINTER) 16 endif 17 18 ifeq ($(VENDOR_DEPS),yes) 19 # We need to vendor all dependencies at once before running test, so the `go get -t -d ./...` 20 # on go1.9 and go1.10 does not try to re-download them 21 test: $(MODULES_VENDOR) 22 endif 23 24 test: $(MODULES) legal 25 26 $(MODULES): 27 cd $@ && go get -d -t ./... && go test $(GOFLAGS) ./... 28 ifeq ($(RUN_LINTER),yes) 29 cd $@ && $(LINTER) run 30 endif 31 32 integration: $(INTEGRATION_TESTS) pgx_integration_test 33 34 $(INTEGRATION_TESTS): 35 go test $(GOFLAGS) -tags "$@ integration" $(shell grep --exclude-dir=instapgx -lR '^// +build \($@,\)\?integration\(,$@\)\?' .) 36 37 $(LINTER): 38 curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/a2bc9b7a99e3280805309d71036e8c2106853250/install.sh \ 39 | sh -s -- -b $(basename $(GOPATH))/bin v1.23.8 40 41 $(MODULES_VENDOR): $(VENDOR_GO) 42 cd $(shell dirname $@) && $(VENDOR_GO) mod vendor 43 find $@ -name go.mod -delete 44 45 $(VENDOR_GO): 46 go get golang.org/dl/$(VENDOR_GO_VERSION) 47 $(VENDOR_GO) download 48 49 install: 50 cd .git/hooks && ln -fs ../../.githooks/* . 51 brew install gh 52 53 # Make sure there is a copyright at the first line of each .go file 54 legal: 55 awk 'FNR==1 { if (tolower($$0) !~ "^//.+copyright") { print FILENAME" does not contain copyright header"; rc=1 } }; END { exit rc }' $$(find . -name '*.go' -type f | grep -v "/vendor/") 56 57 instrumentation/% : 58 mkdir -p $@ 59 cd $@ && go mod init github.com/mier85/go-sensor/$@ 60 sed "s~Copyright (c) [0-9]*~Copyright (c) $(shell date +%Y)~" LICENSE.md > $@/LICENSE.md 61 printf "VERSION_TAG_PREFIX ?= $@/v\nGO_MODULE_NAME ?= github.com/mier85/go-sensor/$@\n\ninclude ../../Makefile.release\n" > $@/Makefile 62 printf '// (c) Copyright IBM Corp. %s\n// (c) Copyright Instana Inc. %s\n\npackage %s\n\nconst Version = "0.0.0"\n' $(shell date +%Y) $(shell date +%Y) $(notdir $@) > $@/version.go 63 64 .PHONY: test vendor install legal $(MODULES) $(INTEGRATION_TESTS) 65 66 # Release targets 67 include Makefile.release