-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
58 lines (45 loc) · 1.56 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
GOCMD=go
GOTEST=$(GOCMD) test
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
HASH := $(shell git rev-parse --short HEAD)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
.PHONY: all test build clean run
PROJECT_NAME := smolgit
all: help
## Build:
build: ## Build all the binaries and put the output in bin/
$(GOCMD) build -ldflags "-X main.version=$(BRANCH)-$(HASH)" -o bin/$(PROJECT_NAME) .
build-docker: ## Build an image
docker build -t $(PROJECT_NAME) .
## Clean:
clean: ## Remove build related file
@-rm -fr ./bin
## Run:
run: clean build ## Run the smolgit `make run`
./bin/$(PROJECT_NAME) $(ARGS)
run-docker: ## Run smolgit in the container
docker run -it -p 3080:3080 -p 3081:3081 -v $(PWD)/:/etc/smolgit $(PROJECT_NAME)
config-docker: ## Generate smolgit config
docker run -it $(PROJECT_NAME) config > config.yaml
config: ## Generate default config
./bin/$(PROJECT_NAME) config > ./config.yaml
## Test:
test: ## Run the tests of the smolgit
$(GOTEST) -v -race ./...
integration-test: build ## Run the bats tests of the smolgit
@bats ./test/test.bats
## Help:
help: ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)