2018-08-27 22:06:55 +01:00
|
|
|
.PHONY: test lint proto check-copyrights build-dev-deps release release-osx release-windows release-linux
|
2018-04-25 15:55:26 +01:00
|
|
|
|
2018-08-22 03:54:56 +01:00
|
|
|
|
|
|
|
GO_VERSION ?= 1.10
|
2018-07-25 22:47:02 +01:00
|
|
|
COMPOSE_PROJECT_NAME := ${TAG}-$(shell git rev-parse --abbrev-ref HEAD)
|
2018-08-22 03:54:56 +01:00
|
|
|
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
ifeq (${BRANCH},master)
|
|
|
|
TAG := $(shell git rev-parse --short HEAD)-go${GO_VERSION}
|
|
|
|
else
|
|
|
|
TAG := $(shell git rev-parse --short HEAD)-${BRANCH}-go${GO_VERSION}
|
|
|
|
endif
|
2018-07-25 22:47:02 +01:00
|
|
|
|
2018-06-21 20:36:39 +01:00
|
|
|
|
2018-08-27 18:28:16 +01:00
|
|
|
# currently disabled linters:
|
|
|
|
# gofmt # enable after switch to go1.11
|
|
|
|
# goimpor # enable after switch to go1.11
|
|
|
|
# unparam # enable later
|
|
|
|
# gosec # enable later
|
|
|
|
# vetshadow # enable later
|
|
|
|
# gochecknoinits # enable later
|
|
|
|
# gochecknoglobals # enable later
|
|
|
|
# dupl # needs tuning
|
|
|
|
# gocyclo # needs tuning
|
|
|
|
# lll # long lines, not relevant
|
|
|
|
# gotype, gotypex # already done by compiling
|
|
|
|
# safesql # no sql
|
|
|
|
# interfacer # not that useful
|
2018-04-23 17:05:52 +01:00
|
|
|
lint: check-copyrights
|
|
|
|
@echo "Running ${@}"
|
2018-04-25 15:55:26 +01:00
|
|
|
@gometalinter \
|
2018-08-28 16:00:18 +01:00
|
|
|
--deadline=10m \
|
|
|
|
--concurrency=1 \
|
|
|
|
--enable-all \
|
|
|
|
--enable=golint \
|
|
|
|
--enable=errcheck \
|
|
|
|
--enable=unconvert \
|
|
|
|
--enable=structcheck \
|
|
|
|
--enable=misspell \
|
|
|
|
--disable=goimports \
|
|
|
|
--enable=ineffassign \
|
|
|
|
--disable=gofmt \
|
|
|
|
--enable=nakedret \
|
|
|
|
--enable=megacheck \
|
|
|
|
--disable=unparam \
|
|
|
|
--disable=gosec \
|
|
|
|
--disable=vetshadow \
|
|
|
|
--disable=gochecknoinits \
|
|
|
|
--disable=gochecknoglobals \
|
|
|
|
--disable=dupl \
|
|
|
|
--disable=gocyclo \
|
|
|
|
--disable=lll \
|
|
|
|
--disable=gotype --disable=gotypex \
|
|
|
|
--disable=safesql \
|
|
|
|
--disable=interfacer \
|
2018-08-27 18:28:16 +01:00
|
|
|
--skip=examples \
|
2018-07-16 20:22:34 +01:00
|
|
|
--exclude=".*\.pb\.go" \
|
2018-07-27 22:11:44 +01:00
|
|
|
--exclude=".*\.dbx\.go" \
|
2018-08-28 16:00:18 +01:00
|
|
|
./...
|
2018-04-12 14:50:22 +01:00
|
|
|
|
2018-04-23 17:05:52 +01:00
|
|
|
check-copyrights:
|
|
|
|
@echo "Running ${@}"
|
|
|
|
@./scripts/check-for-header.sh
|
|
|
|
|
2018-06-13 19:22:32 +01:00
|
|
|
# Applies goimports to every go file (excluding vendored files)
|
|
|
|
goimports-fix:
|
|
|
|
goimports -w $$(find . -type f -name '*.go' -not -path "*/vendor/*")
|
|
|
|
|
2018-04-12 14:50:22 +01:00
|
|
|
proto:
|
|
|
|
@echo "Running ${@}"
|
2018-04-17 18:29:15 +01:00
|
|
|
./scripts/build-protos.sh
|
|
|
|
|
|
|
|
build-dev-deps:
|
2018-05-09 14:21:53 +01:00
|
|
|
go get github.com/golang/protobuf/protoc-gen-go
|
2018-06-26 12:48:02 +01:00
|
|
|
go get github.com/mattn/goveralls
|
2018-08-01 15:15:38 +01:00
|
|
|
go get golang.org/x/tools/cover
|
2018-06-26 12:48:02 +01:00
|
|
|
go get github.com/modocache/gover
|
2018-05-09 14:21:53 +01:00
|
|
|
go get github.com/alecthomas/gometalinter
|
2018-04-25 15:55:26 +01:00
|
|
|
gometalinter --install --force
|
|
|
|
|
2018-05-08 23:02:01 +01:00
|
|
|
test: lint
|
|
|
|
go install -v ./...
|
2018-08-27 18:28:16 +01:00
|
|
|
go test -race -v -covermode=atomic -coverprofile=coverage.out ./...
|
2018-06-26 12:48:02 +01:00
|
|
|
gover
|
2018-05-09 00:01:46 +01:00
|
|
|
@echo done
|
2018-06-05 22:06:37 +01:00
|
|
|
|
|
|
|
build-binaries:
|
2018-07-26 21:01:38 +01:00
|
|
|
docker build -t hc .
|
2018-06-05 22:06:37 +01:00
|
|
|
|
2018-07-26 21:01:38 +01:00
|
|
|
run-hc:
|
2018-06-05 22:06:37 +01:00
|
|
|
docker network create test-net
|
|
|
|
|
|
|
|
docker run -d \
|
|
|
|
--name redis \
|
|
|
|
--network test-net \
|
|
|
|
-p 127.0.0.1:6379:6379 \
|
|
|
|
redis
|
|
|
|
|
|
|
|
docker run -d \
|
2018-07-26 21:01:38 +01:00
|
|
|
--name=hc \
|
2018-06-05 22:06:37 +01:00
|
|
|
--network test-net \
|
2018-06-22 14:33:57 +01:00
|
|
|
-p 127.0.0.1:8080:8080 \
|
2018-06-05 22:06:37 +01:00
|
|
|
-e REDIS_ADDRESS=redis:6379 \
|
|
|
|
-e REDIS_PASSWORD="" \
|
|
|
|
-e REDIS_DB=1 \
|
2018-06-22 14:33:57 +01:00
|
|
|
-e OVERLAY_PORT=7070 \
|
2018-07-26 21:01:38 +01:00
|
|
|
hc
|
2018-06-05 22:06:37 +01:00
|
|
|
|
2018-08-14 17:58:16 +01:00
|
|
|
test-captplanet:
|
|
|
|
@echo "Running ${@}"
|
|
|
|
@./scripts/test-captplanet.sh
|
|
|
|
|
2018-06-05 22:06:37 +01:00
|
|
|
clean-local:
|
2018-07-26 21:01:38 +01:00
|
|
|
# cleanup heavy client
|
|
|
|
docker stop hc || true
|
|
|
|
docker rm hc || true
|
2018-06-05 22:06:37 +01:00
|
|
|
# cleanup redis
|
|
|
|
docker stop redis || true
|
|
|
|
docker rm redis || true
|
|
|
|
# cleanup docker network
|
2018-06-21 20:36:39 +01:00
|
|
|
docker network rm test-net || true
|
|
|
|
|
2018-07-25 22:47:02 +01:00
|
|
|
test-docker:
|
|
|
|
docker-compose up -d --remove-orphans test
|
|
|
|
docker-compose run test make test
|
|
|
|
|
|
|
|
test-docker-clean:
|
|
|
|
-docker-compose down --rmi all
|
|
|
|
|
2018-08-23 16:48:03 +01:00
|
|
|
images: satellite-image storage-node-image uplink-image
|
|
|
|
echo Built version: ${TAG}
|
|
|
|
|
|
|
|
.PHONY: satellite-image
|
|
|
|
satellite-image:
|
2018-08-22 03:54:56 +01:00
|
|
|
docker build --build-arg GO_VERSION=${GO_VERSION} -t storjlabs/satellite:${TAG} -f cmd/hc/Dockerfile .
|
2018-08-23 16:48:03 +01:00
|
|
|
.PHONY: storage-node-image
|
|
|
|
storage-node-image:
|
2018-08-25 02:52:58 +01:00
|
|
|
docker build --build-arg GO_VERSION=${GO_VERSION} -t storjlabs/storage-node:${TAG} -f cmd/storagenode/Dockerfile .
|
2018-08-23 16:48:03 +01:00
|
|
|
.PHONY: uplink-image
|
|
|
|
uplink-image:
|
2018-08-24 21:02:42 +01:00
|
|
|
docker build --build-arg GO_VERSION=${GO_VERSION} -t storjlabs/uplink:${TAG} -f cmd/uplink/Dockerfile .
|
2018-08-23 16:48:03 +01:00
|
|
|
|
|
|
|
.PHONY: all-in-one
|
|
|
|
all-in-one:
|
|
|
|
if [ -z "${VERSION}" ]; then \
|
|
|
|
$(MAKE) images -j 3 \
|
|
|
|
&& export VERSION="${TAG}"; \
|
|
|
|
fi \
|
|
|
|
&& docker-compose up -d storage-node \
|
|
|
|
&& scripts/fix-mock-overlay \
|
|
|
|
&& docker-compose up storage-node satellite uplink
|
2018-06-21 20:36:39 +01:00
|
|
|
|
|
|
|
push-images:
|
2018-08-22 03:54:56 +01:00
|
|
|
docker tag storjlabs/satellite:${TAG} storjlabs/satellite:latest
|
|
|
|
docker push storjlabs/satellite:${TAG}
|
2018-08-08 18:48:59 +01:00
|
|
|
docker push storjlabs/satellite:latest
|
2018-08-22 03:54:56 +01:00
|
|
|
docker tag storjlabs/storage-node:${TAG} storjlabs/storage-node:latest
|
2018-08-08 18:48:59 +01:00
|
|
|
docker push storjlabs/storage-node:${TAG}
|
|
|
|
docker push storjlabs/storage-node:latest
|
2018-08-23 16:48:03 +01:00
|
|
|
docker tag storjlabs/uplink:${TAG} storjlabs/uplink:latest
|
|
|
|
docker push storjlabs/uplink:${TAG}
|
|
|
|
docker push storjlabs/uplink:latest
|
2018-06-22 21:17:37 +01:00
|
|
|
|
2018-08-22 03:54:56 +01:00
|
|
|
ifeq (${BRANCH},master)
|
2018-07-13 16:02:33 +01:00
|
|
|
clean-images:
|
2018-08-22 03:54:56 +01:00
|
|
|
-docker rmi storjlabs/satellite:${TAG} storjlabs/satellite:latest
|
2018-08-08 18:48:59 +01:00
|
|
|
-docker rmi storjlabs/storage-node:${TAG} storjlabs/storage-node:latest
|
2018-08-23 16:48:03 +01:00
|
|
|
-docker rmi storjlabs/uplink:${TAG} storjlabs/uplink:latest
|
2018-08-22 03:54:56 +01:00
|
|
|
else
|
|
|
|
clean-images:
|
|
|
|
-docker rmi storjlabs/satellite:${TAG}
|
|
|
|
-docker rmi storjlabs/storage-node:${TAG}
|
2018-08-23 16:48:03 +01:00
|
|
|
-docker rmi storjlabs/uplink:${TAG}
|
2018-08-22 03:54:56 +01:00
|
|
|
endif
|
2018-07-13 16:02:33 +01:00
|
|
|
|
2018-06-22 21:17:37 +01:00
|
|
|
install-deps:
|
|
|
|
go get -u -v golang.org/x/vgo
|
2018-07-13 16:02:33 +01:00
|
|
|
cd vgo install ./...
|
2018-08-23 22:04:51 +01:00
|
|
|
|
|
|
|
.PHONY: deploy
|
|
|
|
deploy:
|
2018-08-23 22:17:47 +01:00
|
|
|
./scripts/deploy.staging.sh satellite storjlabs/satellite:${TAG}
|
2018-08-23 22:04:51 +01:00
|
|
|
for i in $(shell seq 1 60); do \
|
|
|
|
./scripts/deploy.staging.sh storage-node-$$i storjlabs/storage-node:${TAG}; \
|
|
|
|
done
|
2018-08-27 22:06:55 +01:00
|
|
|
|
|
|
|
release-osx:
|
|
|
|
GOOS=darwin GOARCH=amd64 go build -o release/uplink-osx-amd64/uplink ./cmd/uplink
|
|
|
|
cd release; tar czvf uplink-osx-amd64.tar.gz uplink-osx-amd64
|
|
|
|
rm -rf release/uplink-osx-amd64
|
|
|
|
|
|
|
|
release-linux:
|
|
|
|
GOOS=linux GOARCH=amd64 go build -o release/uplink-linux-amd64/uplink ./cmd/uplink
|
|
|
|
cd release; tar czvf uplink-linux-amd64.tar.gz uplink-linux-amd64
|
|
|
|
rm -rf release/uplink-linux-amd64
|
|
|
|
|
|
|
|
release-windows:
|
|
|
|
GOOS=windows GOARCH=amd64 go build -o release/uplink-windows-amd64/uplink ./cmd/uplink
|
|
|
|
cd release; zip uplink-windows-amd64.zip uplink-windows-amd64
|
|
|
|
rm -rf release/uplink-windows-amd64
|
|
|
|
|
|
|
|
release: release-osx release-linux release-windows
|