Skip to content

Commit

Permalink
Merge pull request #240 from ayuryshev/feature/Follow-skycoin-Makefil…
Browse files Browse the repository at this point in the history
…e-and-travis-standards-235

Made corrections Makefile and travis to conform skycoin standards
  • Loading branch information
志宇 authored Mar 21, 2019
2 parents 7ba6eeb + 2edd3da commit 563e138
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
66 changes: 41 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -49,48 +68,45 @@ 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
-${DOCKER_OPTS} go build -o ./node/apps/therealproxy-client.v1.0 ./cmd/apps/therealproxy-client
-${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}'

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down

0 comments on commit 563e138

Please sign in to comment.