github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/Makefile (about) 1 MODULES = $(filter-out $(EXCLUDE_DIRS) ./example/% , $(shell find . -name go.mod -exec dirname {} \;)) 2 LINTER ?= $(shell go env GOPATH)/bin/golangci-lint 3 4 # The list of Go build tags as they are specified in respective integration test files 5 INTEGRATION_TESTS = fargate gcr lambda azure 6 7 ifeq ($(RUN_LINTER),yes) 8 test: $(LINTER) 9 endif 10 11 test: $(MODULES) legal 12 13 $(MODULES): 14 cd $@ && go get -d -t ./... && go test $(GOFLAGS) ./... 15 ifeq ($(RUN_LINTER),yes) 16 cd $@ && $(LINTER) run 17 endif 18 19 INSTAPGX_EXCLUDED := $(findstring ./instrumentation/instapgx, $(EXCLUDE_DIRS)) 20 INSTAGOCB_EXCLUDED := $(findstring ./instrumentation/instagocb, $(EXCLUDE_DIRS)) 21 INSTACOSMOS_EXCLUDED := $(findstring ./instrumentation/instacosmos, $(EXCLUDE_DIRS)) 22 23 # Run all integration tests 24 integration: $(INTEGRATION_TESTS) 25 ifndef INSTAPGX_EXCLUDED 26 cd instrumentation/instapgx && go test -tags=integration 27 endif 28 ifndef INSTAGOCB_EXCLUDED 29 cd instrumentation/instagocb && go test -v -coverprofile cover.out -tags=integration ./... 30 endif 31 ifndef INSTACOSMOS_EXCLUDED 32 cd instrumentation/instacosmos && go test -v -coverprofile cover.out -tags=integration ./... 33 endif 34 35 # Run all integration tests excluding Couchbase 36 integration-common: $(INTEGRATION_TESTS) 37 ifndef INSTAPGX_EXCLUDED 38 cd instrumentation/instapgx && go test -tags=integration 39 endif 40 ifndef INSTACOSMOS_EXCLUDED 41 cd instrumentation/instacosmos && go test -v -coverprofile cover.out -tags=integration ./... 42 endif 43 44 $(INTEGRATION_TESTS): 45 go test $(GOFLAGS) -tags "$@ integration" $(shell grep --exclude-dir=instagocb --exclude-dir=instapgx --exclude-dir=instacosmos -lR '^// +build \($@,\)\?integration\(,$@\)\?' .) 46 47 integration-couchbase: 48 ifndef INSTAGOCB_EXCLUDED 49 cd instrumentation/instagocb && go test -v -coverprofile cover.out -tags=integration ./... 50 endif 51 52 $(LINTER): 53 curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/a2bc9b7a99e3280805309d71036e8c2106853250/install.sh \ 54 | sh -s -- -b $(basename $(GOPATH))/bin v1.23.8 55 56 install: 57 cd .git/hooks && ln -fs ../../.githooks/* . 58 brew install gh 59 60 # Make sure there is a copyright at the first line of each .go file 61 legal: 62 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/") 63 64 instrumentation/% : 65 mkdir -p $@ 66 cd $@ && go mod init github.com/instana/go-sensor/$@ 67 sed "s~Copyright (c) [0-9]*~Copyright (c) $(shell date +%Y)~" LICENSE.md > $@/LICENSE.md 68 printf "VERSION_TAG_PREFIX ?= $@/v\nGO_MODULE_NAME ?= github.com/instana/go-sensor/$@\n\ninclude ../../Makefile.release\n" > $@/Makefile 69 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 70 71 fmtcheck: 72 @exclude_string=""; \ 73 for exclude_dir in $$(echo $$EXCLUDE_DIRS | tr ' ' '\n'); do \ 74 exclude_string="$$exclude_string -not -path \"$$exclude_dir/*\""; \ 75 done; \ 76 command="find . -type f -name \"*.go\" $$exclude_string"; \ 77 gofmt_output=$$(gofmt -l $$(eval "$$command")); \ 78 if [ -n "$$gofmt_output" ]; then \ 79 echo "Some files are not formatted properly:"; \ 80 echo "$$gofmt_output"; \ 81 exit 1; \ 82 else \ 83 echo "All Go files are formatted properly."; \ 84 fi 85 @gofmt -l $$(eval "$$command") 86 @test -z $(shell gofmt -l $$(eval "$$command") && exit 1) 87 88 importcheck: 89 @test -z $(shell goimports -l . && exit 1) 90 91 .PHONY: test install legal fmtcheck importcheck $(MODULES) $(INTEGRATION_TESTS) 92 93 # Release targets 94 include Makefile.release