-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
97 lines (67 loc) · 2.24 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
BINARIES ?= ssh2docker
GODIR ?= github.com/moul/ssh2docker
RUN_ARGS ?= -V --local-user=local-user
PKG_BASE_DIR ?= .
CONVEY_PORT ?= 9042
SOURCES := $(shell find . -type f -name "*.go")
COMMANDS := $(shell go list ./... | grep -v /vendor/ | grep /cmd/)
PACKAGES := $(shell go list ./... | grep -v /vendor/ | grep -v /cmd/)
REL_COMMANDS := $(subst $(GODIR),./,$(COMMANDS))
REL_PACKAGES := $(subst $(GODIR),./,$(PACKAGES))
GOENV ?= GO15VENDOREXPERIMENT=1
GO ?= $(GOENV) go
USER ?= $(shell whoami)
all: build
.PHONY: run
run: build
./$(BINARIES) $(RUN_ARGS)
.PHONY: build
build: $(BINARIES)
$(BINARIES): $(SOURCES)
$(GO) build -o $@ ./cmd/$@
.PHONY: test
test:
#$(GO) get -t ./...
$(GO) test -i $(PACKAGES) $(COMMANDS)
$(GO) test -v $(PACKAGES) $(COMMANDS)
.PHONY: install
install:
$(GO) install $(COMMANDS)
.PHONY: clean
clean:
rm -f $(BINARIES)
.PHONY: re
re: clean all
.PHONY: convey
convey:
$(GO) get github.com/smartystreets/goconvey
goconvey -cover -port=$(CONVEY_PORT) -workDir="$(realpath $(PKG_BASE_DIR))" -depth=1
.PHONY: cover
cover: profile.out
profile.out: $(SOURCES)
rm -f $@
find . -name profile.out -delete
for package in $(REL_PACKAGES); do \
rm -f $$package/profile.out; \
$(GO) test -covermode=count -coverpkg=$(PKG_BASE_DIR) -coverprofile=$$package/profile.out $$package; \
done
echo "mode: count" > profile.out.tmp
cat `find . -name profile.out` | grep -v mode: | sort -r | awk '{if($$1 != last) {print $$0;last=$$1}}' >> profile.out.tmp
mv profile.out.tmp profile.out
docker:
docker build -t moul/ssh2docker .
.PHONY: docker-build
docker-build:
go get github.com/laher/goxc
rm -rf contrib/docker/linux_386
for binary in $(BINARIES); do \
goxc -bc="linux,386" -d . -pv contrib/docker -n $$binary xc; \
mv contrib/docker/linux_386/$$binary contrib/docker/entrypoint; \
docker build -t $(USER)/$$binary contrib/docker; \
docker run -it --rm $(USER)/$$binary || true; \
docker inspect --type=image --format="{{ .Id }}" moul/$$binary || true; \
echo "Now you can run 'docker push $(USER)/$$binary'"; \
done
.PHONY: docker-ps
docker-ps:
docker ps --filter=label=ssh2docker -a