-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMakefile
45 lines (32 loc) · 1.46 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
.PHONY: build build-alpine clean test help default docker-build
BIN_NAME=bashhub-server
VERSION=$(shell git tag | sort --version-sort -r | head -1)
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"
default: help
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'
@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}
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) .
clean:
@test ! -e bin/$(BIN_NAME) || rm bin/$(BIN_NAME)
test:
go test ./...
test-postgres:
scripts/test_postgres.sh
test-all: test test-postgres