-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
114 lines (89 loc) · 3.18 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
VERSION := $(shell grep -E "version\s+=" `pwd`/main.go | awk -F '"' '{print $$2}')
GOOS :=
prefix :=
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
GOOS=darwin
prefix:=/usr/local
endif
ifeq ($(UNAME_S),Linux)
GOOS=linux
prefix:=/usr
endif
exec_prefix := $(prefix)
bindir := $(exec_prefix)/bin
datarootdir := $(prefix)/share
man1dir := $(datarootdir)/man/man1
bash_completion_dir := $(datarootdir)/bash-completion/completions
zsh_completion_dir := $(datarootdir)/zsh/site-functions
CURR_DIR := $(shell pwd)
BATS_FILE :=
ifdef CASE
BATS_FILE=$(CASE).bats
endif
BATS_FILTER :=
ifdef FILTER
BATS_FILTER=--filter $(FILTER)
endif
all: build man-page completion
update-and-cleanup-deps:
go get -u -t
go mod tidy
deps:
go get -t
go mod download
test: go-test hookscript-tests
verify: test acceptance-tests
mocks:
docker run --rm --user "$(shell id -u):$(shell id -g)" -v "$(CURR_DIR):/src" -w /src vektra/mockery:v2.14.0 --dir=src/ --all --keeptree
go-test: mocks deps
go test -cover ./src/...
fmt: deps
go fmt main.go
go fmt ./src/...
build: deps
ifndef GOPATH
$(error GOPATH is not set)
endif
mkdir -p $(CURR_DIR)/target/bin
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=amd64 go build -o $(CURR_DIR)/target/bin ./...
@echo "[INFO] Successfully built git-team version v$(VERSION)"
man-page: deps
mkdir -p $(CURR_DIR)/target/man/
go run $(CURR_DIR)/main.go --generate-man-page > $(CURR_DIR)/target/man/git-team.1
gzip -f $(CURR_DIR)/target/man/git-team.1
completion: bash_completion zsh_completion
bash_completion: deps
mkdir -p $(CURR_DIR)/target/completion/bash
go run $(CURR_DIR)/main.go completion bash > $(CURR_DIR)/target/completion/bash/git-team.bash
zsh_completion: deps
mkdir -p $(CURR_DIR)/target/completion/zsh
go run $(CURR_DIR)/main.go completion zsh > $(CURR_DIR)/target/completion/zsh/git-team.zsh
install:
@echo "[INFO] Installing into $(bindir)/ ..."
mkdir -p $(bindir)
install $(CURR_DIR)/target/bin/git-team $(bindir)/git-team
mkdir -p $(man1dir)
install -m "0644" $(CURR_DIR)/target/man/git-team.1.gz $(man1dir)/git-team.1.gz
mkdir -p $(bash_completion_dir)
install -m "0644" $(CURR_DIR)/target/completion/bash/git-team.bash $(bash_completion_dir)/git-team
echo "[INFO] bash: Don't forget to source $(bash_completion_dir)/git-team"
mkdir -p $(zsh_completion_dir)
install -m "0644" $(CURR_DIR)/target/completion/zsh/git-team.zsh $(zsh_completion_dir)/_git-team
echo "[INFO] zsh: Don't forget to source $(zsh_completion_dir)/_git-team"
uninstall:
rm -f $(bindir)/git-team
rm -f $(bash_completion_dir)/git-team
rm -f $(zsh_completion_dir)/_git-team
rm -f $(man1dir)/git-team.1.gz
clean:
rm -rf $(CURR_DIR)/mocks
rm -rf $(CURR_DIR)/target
.PHONY: acceptance-tests
acceptance-tests:
docker build -t git-team-acceptance-tests . -f acceptance-tests.Dockerfile
docker run -e "TERM=$(TERM)" --rm -v $(CURR_DIR)/acceptance-tests:/acceptance-tests:ro git-team-acceptance-tests --pretty /acceptance-tests/$(BATS_FILE) $(BATS_FILTER)
.PHONY: hookscript-tests
hookscript-tests:
docker build -t git-team-hookscript-tests . -f hookscript-tests.Dockerfile
docker run -e "TERM=$(TERM)" --rm -v $(CURR_DIR)/hookscript-tests:/hookscript-tests:ro git-team-hookscript-tests --pretty /hookscript-tests/