X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=Makefile;h=7a8aeca63619729331427e80b1261ffb9a9c42d1;hb=4703b1a7457cf072640adbc0f5487a0675f5b6d3;hp=80618746917a0d50a672436003f14638b8a68d98;hpb=193caf9d7e08b84a0b9c1f0352924a7efd77e77c;p=ric-plt%2Fappmgr.git diff --git a/Makefile b/Makefile index 8061874..7a8aeca 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ + # Copyright (c) 2019 AT&T Intellectual Property. # Copyright (c) 2019 Nokia. # @@ -13,145 +14,28 @@ # See the License for the specific language governing permissions and # limitations under the License. +.DEFAULT: go-build -#------------------------------------------------------------------------------ -# -#-------------------------------------------------------------------- ---------- -ROOT_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -BUILD_DIR:=$(abspath $(ROOT_DIR)/build) - -PACKAGEURL:="gerrit.oran-osc.org/r/ric-plt/appmgr" -HELMVERSION:=v2.13.0-rc.1 - -#------------------------------------------------------------------------------ -# -#-------------------------------------------------------------------- ---------- -COVEROUT := $(abspath $(BUILD_DIR)/cover.out) -COVERHTML := $(abspath $(BUILD_DIR)/cover.html) - -GOOS=$(shell go env GOOS) -GOCMD=go -GOBUILD=$(GOCMD) build -a -installsuffix cgo -GORUN=$(GOCMD) run -a -installsuffix cgo -GOCLEAN=$(GOCMD) clean -GOTEST=$(GOCMD) test -v -coverprofile $(COVEROUT) -GOGET=$(GOCMD) get - -GOFILES := $(shell find $(ROOT_DIR) -name '*.go' -not -name '*_test.go') go.mod go.sum -GOFILES_NO_VENDOR := $(shell find $(ROOT_DIR) -path ./vendor -prune -o -name "*.go" -not -name '*_test.go' -print) - -CMDS:=$(BUILD_DIR)/appmgr - -#------------------------------------------------------------------------------ -# -#-------------------------------------------------------------------- ---------- - .DEFAULT: build - -default: build +default: go-build -.PHONY: FORCE +build: go-build -FORCE: +test: go-test #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ - -$(CMDS): $(GOFILES) - GO111MODULE=on GO_ENABLED=0 GOOS=linux $(GOBUILD) -o $@ ./cmd/$(shell basename "$@") - - -$(addsuffix _test,$(CMDS)): $(GOFILES) - GO111MODULE=on GO_ENABLED=0 GOOS=linux $(GOTEST) -c -o $@ ./cmd/$(patsubst %_test,%, $(shell basename "$@")) - timeout -s KILL 5s $@ -test.coverprofile $(COVEROUT) - go tool cover -html=$(COVEROUT) -o $(COVERHTML) - - -build: $(CMDS) - - -test: $(addsuffix _test,$(CMDS)) - - -test-fmt: $(GOFILES_NO_VENDOR) - @(RESULT="$$(gofmt -l $^)"; test -z "$${RESULT}" || (echo -e "gofmt failed:\n$${RESULT}" && false) ) - - -fmt: $(GOFILES_NO_VENDOR) - gofmt -w -s $^ - - -clean: - @echo " > Cleaning build cache" - @-rm -rf $(CMDS)* 2> /dev/null - go clean 2> /dev/null +ROOT_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +CACHE_DIR?=$(abspath $(ROOT_DIR)/cache) #------------------------------------------------------------------------------ # -#------------------------------------------------------------------------------ - -BUILD_PREFIX?="${USER}-" - -DCKR_FILE:=docker/Dockerfile - -DCKR_NAME:=${BUILD_PREFIX}appmgr -DCKR_NAME:=$(shell echo $(DCKR_NAME) | tr '[:upper:]' '[:lower:]') -DCKR_NAME:=$(subst /,_,${DCKR_NAME}) - -DCKR_BUILD_OPTS:=${DCKR_BUILD_OPTS} --network=host --build-arg HELMVERSION=${HELMVERSION} --build-arg PACKAGEURL=${PACKAGEURL} - -DCKR_RUN_OPTS:=${DCKR_RUN_OPTS} --rm -i -DCKR_RUN_OPTS:=${DCKR_RUN_OPTS}$(shell test -t 0 && echo ' -t') -DCKR_RUN_OPTS:=${DCKR_RUN_OPTS}$(shell test -e /etc/localtime && echo ' -v /etc/localtime:/etc/localtime:ro') -DCKR_RUN_OPTS:=${DCKR_RUN_OPTS}$(shell test -e /var/run/docker.sock && echo ' -v /var/run/docker.sock:/var/run/docker.sock') - - -#------------------------------------------------------------------------------ +# Build and test targets # #------------------------------------------------------------------------------ -docker-name: - @echo $(DCKR_NAME) - -docker-build: - docker build --target release ${DCKR_BUILD_OPTS} -t $(DCKR_NAME) -f $(DCKR_FILE) . - -docker-run: - docker run ${DCKR_RUN_OPTS} -v /opt/ric:/opt/ric -p 8080:8080 $(DCKR_NAME) - -docker-clean: - docker rmi $(DCKR_NAME) - - -#------------------------------------------------------------------------------ -# -#------------------------------------------------------------------------------ - -docker-test-build: - docker build --target test_unit ${DCKR_BUILD_OPTS} -t ${DCKR_NAME}-test_unit -f $(DCKR_FILE) . - docker build --target test_sanity ${DCKR_BUILD_OPTS} -t ${DCKR_NAME}-test_sanity -f $(DCKR_FILE) . - docker build --target test_fmt ${DCKR_BUILD_OPTS} -t ${DCKR_NAME}-test_fmt -f $(DCKR_FILE) . - -docker-test-run-unit: - @( \ - RETVAL=0;\ - docker network create --driver bridge ${DCKR_NAME}-test_unit_network;\ - docker run ${DCKR_RUN_OPTS} -d --name ${DCKR_NAME}-test_unit_redis --network ${DCKR_NAME}-test_unit_network redis;\ - docker run ${DCKR_RUN_OPTS} --name ${DCKR_NAME}-test_unit_run --network ${DCKR_NAME}-test_unit_network -e DBAAS_SERVICE_HOST=${DCKR_NAME}-test_unit_redis ${DCKR_NAME}-test_unit;\ - RETVAL=$$?;\ - docker stop ${DCKR_NAME}-test_unit_redis;\ - docker network rm ${DCKR_NAME}-test_unit_network;\ - exit $${RETVAL};\ - ) - - -docker-test-run-fmt: - docker run ${DCKR_RUN_OPTS} ${DCKR_NAME}-test_fmt - -docker-test-run-sanity: - docker run ${DCKR_RUN_OPTS} ${DCKR_NAME}-test_sanity -docker-test-clean: - docker rmi -f ${DCKR_NAME}-test_unit - docker rmi -f ${DCKR_NAME}-test_sanity - docker rmi -f ${DCKR_NAME}-test_fmt +XAPP_NAME:=appmgr +XAPP_ROOT:=cmd +XAPP_TESTENV:="RMR_SEED_RT=config/uta_rtg.rt CFG_FILE=$(ROOT_DIR)helm_chart/uemgr/descriptors/config-file.json" +include build/make.go.mk