diff --git a/Makefile b/Makefile index 44743a9..24ae183 100644 --- a/Makefile +++ b/Makefile @@ -2,24 +2,38 @@ CURRENT_DIR := $(shell pwd) BRANCH := $(shell git branch --show-current) DAJE_TEST_NAME := daje-test-$(BRANCH) +# Build Flags +FLAG_PREFIX := -X github.com/Schroedinger-Hat/Daje/constants +# TEST-DEV +FLAG_TEST-DEV_CONFIGBASEPATH := $(FLAG_PREFIX).ConfigBasepath=$(CURRENT_DIR)/testdata +FLAG_TEST-DEV_VERSION := $(FLAG_PREFIX).Version=$(BRANCH)+$(shell git rev-parse --short origin/main)+$(shell git status --porcelain | wc -l | tr -d ' ') +# PROD +FLAG_VERSION := $(FLAG_PREFIX).Version=$(shell git describe --exact-match --tags $(git rev-parse HEAD) 2>/dev/null || git rev-parse --short HEAD) + clean: @echo "\n----- Start CLEAN -----\n" @echo "# Remove all the daje metadata and builds..." rm -r $(CURRENT_DIR)/bin &2>/dev/null @echo "\n----- End CLEAN -----" +test: + @echo "\n----- Start BUILD -----\n" + @echo "# Running unit test..." + go test ./... + @echo "\n----- End BUILD -----" + # The version in this build has the form `|` -build: clean +build: test clean @echo "\n----- Start BUILD -----\n" @echo "# Building daje for production environment..." - go build -ldflags "-X github.com/Schroedinger-Hat/Daje/constants.Version=$(shell git describe --exact-match --tags $(git rev-parse HEAD) 2>/dev/null || git rev-parse --short HEAD)" -o ./bin/daje . + go build -ldflags "$(FLAG_VERSION)" -o ./bin/daje . @echo "\n----- End BUILD -----" # For debugging reason the version in this build has the form `++` -build-test-dev: clean +build-test-dev: test clean @echo "\n----- Start BUILD-TEST-DEV -----\n" @echo "# Building daje for development environment..." - go build -ldflags "-X github.com/Schroedinger-Hat/Daje/constants.ConfigBasepath=$(CURRENT_DIR)/testdata -X github.com/Schroedinger-Hat/Daje/constants.Version=$(BRANCH)+$(shell git rev-parse --short origin/main)+$(shell git status --porcelain | wc -l | tr -d ' ')" -o ./bin/$(DAJE_TEST_NAME) . + go build -ldflags "$(FLAG_TEST-DEV_CONFIGBASEPATH) $(FLAG_TEST-DEV_VERSION)" -o ./bin/$(DAJE_TEST_NAME) . @echo "\n----- End BUILD-TEST-DEV -----" checkhealth: build-test-dev