bashhub-server/Makefile

46 lines
1.5 KiB
Makefile
Raw Normal View History

2020-02-08 00:45:22 +08:00
.PHONY: build build-alpine clean test help default docker-build
2020-02-07 16:02:18 +08:00
BIN_NAME=bashhub-server
2020-02-10 09:35:45 +08:00
VERSION=$(shell git tag | sort --version-sort -r | head -1)
2020-02-07 16:02:18 +08:00
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
IMAGE_NAME="nicksherron/bashhub-server"
2020-02-07 16:02:18 +08:00
default: help
2020-02-07 16:02:18 +08:00
help:
@echo 'Management commands for bashhub-server:'
@echo
@echo 'Usage:'
@echo ' make build Compile the project'
@echo ' make docker-build Build docker image'
@echo ' make clean Clean the directory tree'
@echo ' make test Run tests on a compiled project'
@echo ' make test-postgres Start postgres in ephemeral docker container and run backend tests'
@echo ' make test-all Run test and test-postgres'
2020-02-07 16:02:18 +08:00
@echo
build:
@echo "building $(BIN_NAME) $(VERSION)"
@echo "GOPATH=$(GOPATH)"
go build -ldflags "-X github.com/nicksherron/bashhub-server/cmd.Version=$(VERSION) -X github.com/nicksherron/bashhub-server/cmd.GitCommit=$(GIT_COMMIT) -X github.com/nicksherron/bashhub-server/cmd.BuildDate=$(BUILD_DATE)" -o bin/${BIN_NAME}
2020-02-08 00:45:22 +08:00
docker-build:
docker build --no-cache=true --build-arg VERSION=${VERSION} --build-arg BUILD_DATE=${BUILD_DATE} --build-arg GIT_COMMIT=${GIT_COMMIT} -t $(IMAGE_NAME) .
2020-02-08 00:45:22 +08:00
2020-02-07 16:02:18 +08:00
clean:
@test ! -e bin/$(BIN_NAME) || rm bin/$(BIN_NAME)
2020-02-07 16:02:18 +08:00
test:
go test ./...
2020-02-14 21:53:40 +08:00
test-postgres:
2020-02-15 01:43:54 +08:00
scripts/test_postgres.sh
2020-02-14 21:53:40 +08:00
test-all: test test-postgres
2020-02-14 21:53:40 +08:00