-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
91 lines (71 loc) · 2.92 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
TEST ?= $(shell $(GO) list ./... | grep -v vendor)
VERSION = $(shell cat version)
REVISION = $(shell git describe --always)
INFO_COLOR=\033[1;34m
RESET=\033[0m
BOLD=\033[1m
GO ?= GO111MODULE=on go
default: build
ci: depsdev ftp test lint integration ## Run test and more...
depsdev: ## Installing dependencies for development
which staticcheck > /dev/null || $(GO) install honnef.co/go/tools/cmd/staticcheck@latest
$(GO) get -u github.com/tcnksm/ghr
$(GO) get github.com/mitchellh/gox
test: ## Run test
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Testing$(RESET)"
$(GO) test -v $(TEST) -timeout=5s -parallel=4
$(GO) test -race $(TEST)
vet: ## Exec $(GO) vet
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Vetting$(RESET)"
$(GO) vet $(TEST)
lint: ## Exec golint
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Linting$(RESET)"
$(GOPATH)/bin/staticcheck ./...
server: ## Run server with gin
$(GO) run main.go
build: ## Build as linux binary
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Building$(RESET)"
$(GO) build -o pftp_bin main.go
ghr: ## Upload to Github releases without token check
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Releasing for Github$(RESET)"
ghr -u pyama86 v$(VERSION)-$(REVISION) pkg
dist: build ## Upload to Github releases
@test -z $(GITHUB_TOKEN) || test -z $(GITHUB_API) || $(MAKE) ghr
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(RESET) %s\n", $$1, $$2}'
vsftpd: vsftpd-cleanup
docker build -t vsftpd-server:test -f Dockerfile-vsftpd ./
docker run -d -v "`pwd`/misc/test/data":/home/vsftpd \
-p 10021:21 -p 11100-11150:11100-11150 \
--name vsftpd --restart=always vsftpd-server:test
vsftpd-cleanup:
docker rm -f vsftpd | true
proftpd: proftpd-cleanup
docker build -t proftpd-server:test -f Dockerfile-proftpd ./
docker run -d -v "`pwd`/misc/test/data/prouser":/home/prouser \
-v "`pwd`/tls/server.crt":/etc/ssl/certs/proftpd.crt \
-v "`pwd`/tls/server.key":/etc/ssl/private/proftpd.key \
-v "`pwd`/tls/server.crt":/etc/ssl/certs/chain.crt \
-p 20021:21 -p 21100-21150:21100-21150 \
--name proftpd --restart=always proftpd-server:test
proftpd-cleanup:
docker rm -f proftpd | true
baseftp: baseftp-cleanup
docker build -t baseftp-server:test -f Dockerfile-base ./
docker run -d \
-v "`pwd`/tls/server.crt":/etc/ssl/certs/proftpd.crt \
-v "`pwd`/tls/server.key":/etc/ssl/private/proftpd.key \
-v "`pwd`/tls/server.crt":/etc/ssl/certs/chain.crt \
-p 21:21 -p 31100-31150:31100-31150 \
--name baseftp --restart=always baseftp-server:test
baseftp-cleanup:
docker rm -f baseftp | true
ftp: baseftp vsftpd proftpd
ftp-cleanup: baseftp-cleanup vsftpd-cleanup proftpd-cleanup
integration:
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Integration Testing$(RESET)"
./misc/server stop || true
./misc/server start
$(GO) test $(VERBOSE) -timeout=300s -integration $(TEST) $(TEST_OPTIONS)
./misc/server stop
.PHONY: default dist test ftp proftpd vsftpd help ghr build server