diff --git a/.travis.yml b/.travis.yml index 4d28b17355..b4f0a1cb57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: go go: + # - "1.11.x" At minimum the code should run make check on the latest two go versions in the default linux environment provided by Travis. - "1.12.x" - + dist: xenial matrix: @@ -17,5 +18,4 @@ install: - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v1.13.2 script: - - make test - - make lint + - make check diff --git a/Makefile b/Makefile index ad0b082d1b..5d240e7417 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,47 @@ +.DEFAULT_GOAL := help +.PHONY : check lint install-linters dep test +.PHONY : build clean install format +.PHONY : host-apps bin +.PHONY : run stop +.PHONY : docker-image docker-clean docker-network +.PHONY : docker-apps docker-bin docker-volume +.PHONY : docker-run docker-stop + OPTS?=GO111MODULE=on DOCKER_IMAGE?=skywire-runner # docker image to use for running skywire-node.`golang`, `buildpack-deps:stretch-scm` is OK too DOCKER_NETWORK?=SKYNET DOCKER_NODE?=SKY01 DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container -build: dep host-apps bin +check: lint test ## Run linters and tests + +build: dep host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS} + +run: stop build ## Run skywire-node on host + ./skywire-node + +stop: ## Stop running skywire-node on host + -bash -c "kill $$(ps aux |grep '[s]kywire-node' |awk '{print $$2}')" + -clean: +clean: ## Clean project: remove created binaries and apps -rm -rf ./apps -rm -f ./skywire-node ./skywire-cli ./manager-node ./thereallssh-cli -install: +install: ## Install `skywire-node`, `skywire-cli`, `manager-node`, `therealssh-cli` ${OPTS} go install ./cmd/skywire-node ./cmd/skywire-cli ./cmd/manager-node ./cmd/therealssh-cli -lint: ## Run linters. Use make install-linters first. +lint: ## Run linters. Use make install-linters first # ${OPTS} vendorcheck ./... # TODO: fix vendor check ${OPTS} golangci-lint run -c .golangci.yml ./... # The govet version in golangci-lint is out of date and has spurious warnings, run it separately ${OPTS} go vet -all ./... +test: ## Run tests for net + ${OPTS} go test -race -tags no_ci -cover -timeout=5m ./internal/... + ${OPTS} go test -race -tags no_ci -cover -timeout=5m ./pkg/... + + install-linters: ## Install linters GO111MODULE=off go get -u github.com/FiloSottile/vendorcheck # For some reason this install method is not recommended, see https://github.com/golangci/golangci-lint#install @@ -31,16 +54,12 @@ format: ## Formats the code. Must have goimports installed (use make install-lin ${OPTS} goimports -w -local github.com/skycoin/skywire ./cmd ${OPTS} goimports -w -local github.com/skycoin/skywire ./internal -dep: ## sorts dependencies +dep: ## Sorts dependencies ${OPTS} go mod vendor -v -test: ## Run tests for net - ${OPTS} go test -race -tags no_ci -cover -timeout=5m ./internal/... - ${OPTS} go test -race -tags no_ci -cover -timeout=5m ./pkg/... - # Apps -host-apps: +host-apps: ## Build app ${OPTS} go build -o ./apps/chat.v1.0 ./cmd/apps/chat ${OPTS} go build -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld ${OPTS} go build -o ./apps/therealproxy.v1.0 ./cmd/apps/therealproxy @@ -49,24 +68,24 @@ host-apps: ${OPTS} go build -o ./apps/therealssh-client.v1.0 ./cmd/apps/therealssh-client # Bin -bin: +bin: ## Build `skywire-node`, `skywire-cli`, `manager-node`, `therealssh-cli` ${OPTS} go build -o ./skywire-node ./cmd/skywire-node ${OPTS} go build -o ./skywire-cli ./cmd/skywire-cli ${OPTS} go build -o ./manager-node ./cmd/manager-node ${OPTS} go build -o ./therealssh-cli ./cmd/therealssh-cli # Dockerized skywire-node -docker-image: +docker-image: ## Build docker image `skywire-runner` docker image build --tag=skywire-runner --rm - < skywire-runner.Dockerfile -docker-clean: +docker-clean: ## Clean docker system: remove container ${DOCKER_NODE} and network ${DOCKER_NETWORK} -docker network rm ${DOCKER_NETWORK} -docker container rm --force ${DOCKER_NODE} -docker-network: +docker-network: ## Create docker network ${DOCKER_NETWORK} -docker network create ${DOCKER_NETWORK} -docker-apps: +docker-apps: ## Build apps binaries for dockerized skywire-node. `go build` with ${DOCKER_OPTS} -${DOCKER_OPTS} go build -o ./node/apps/chat.v1.0 ./cmd/apps/chat -${DOCKER_OPTS} go build -o ./node/apps/helloworld.v1.0 ./cmd/apps/helloworld -${DOCKER_OPTS} go build -o ./node/apps/therealproxy.v1.0 ./cmd/apps/therealproxy @@ -74,23 +93,20 @@ docker-apps: -${DOCKER_OPTS} go build -o ./node/apps/therealssh.v1.0 ./cmd/apps/therealssh -${DOCKER_OPTS} go build -o ./node/apps/therealssh-client.v1.0 ./cmd/apps/therealssh-client -docker-bin: +docker-bin: ## Build `skywire-node`, `skywire-cli`, `manager-node`, `therealssh-cli`. `go build` with ${DOCKER_OPTS} ${DOCKER_OPTS} go build -o ./node/skywire-node ./cmd/skywire-node -docker-volume: docker-apps docker-bin bin +docker-volume: docker-apps docker-bin bin ## Prepare docker volume for dockerized skywire-node ./skywire-cli config ./node/skywire.json -docker-run: docker-clean docker-image docker-network docker-volume +docker-run: docker-clean docker-image docker-network docker-volume ## Run dockerized skywire-node ${DOCKER_NODE} in image ${DOCKER_IMAGE} with network ${DOCKER_NETWORK} docker run -it -v $(shell pwd)/node:/sky --network=${DOCKER_NETWORK} \ --name=${DOCKER_NODE} ${DOCKER_IMAGE} bash -c "cd /sky && ./skywire-node" -docker-stop: +docker-stop: ## Stop running dockerized skywire-node ${DOCKER_NODE} -docker container stop ${DOCKER_NODE} -# skywire-node on host -run: stop build - ./skywire-node - -stop: - -bash -c "kill $$(ps aux |grep '[s]kywire-node' |awk '{print $$2}')" +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + \ No newline at end of file diff --git a/README.md b/README.md index 9c22c3f211..bf59ee97b8 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ $ git clone https://github.com/skycoin/skywire $ cd skywire $ git checkout mainnet # Build -$ make # installs all dependencies, build binaries and apps +$ make build # installs all dependencies, build binaries and apps ``` **Note: Environment variable OPTS**