Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis config, Makefile cleanup #722

Merged
merged 7 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@ before_install:
- nvm install 10.16

install:
- go get -u github.com/FiloSottile/vendorcheck
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v1.31.0
- make tidy
- make dep

before_script:
- ci_scripts/create-ip-aliases.sh

script:
- make lint # TODO(evanlinjin): Temporary due to https://github.com/golangci/golangci-lint/issues/827
- make build
- make test
- make test-no-ci
- make check
- make install-deps-ui
- make lint-ui
- make build-ui
82 changes: 5 additions & 77 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.PHONY : check lint lint-extra install-linters dep test
.PHONY : build clean install format bin
.PHONY : host-apps bin
.PHONY : run stop config
.PHONY : docker-image docker-clean docker-network
.PHONY : docker-apps docker-bin docker-volume
.PHONY : docker-run docker-stop
Expand All @@ -26,19 +25,14 @@ DOCKER_NETWORK?=SKYNET
DOCKER_NODE?=SKY01
DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container

TEST_OPTS_BASE:=-cover -timeout=5m -mod=vendor
TEST_OPTS:=-cover -timeout=5m -mod=vendor

RACE_FLAG:=-race
GOARCH:=$(shell go env GOARCH)

ifneq (,$(findstring 64,$(GOARCH)))
TEST_OPTS_BASE:=$(TEST_OPTS_BASE) $(RACE_FLAG)
TEST_OPTS:=$(TEST_OPTS) -race
endif

TEST_OPTS_NOCI:=-$(TEST_OPTS_BASE) -v
TEST_OPTS:=$(TEST_OPTS_BASE) -tags no_ci


BUILDINFO_PATH := $(DMSG_BASE)/buildinfo

BUILDINFO_VERSION := -X $(BUILDINFO_PATH).version=$(VERSION)
Expand All @@ -47,7 +41,7 @@ BUILDINFO_COMMIT := -X $(BUILDINFO_PATH).commit=$(COMMIT)

BUILDINFO?=$(BUILDINFO_VERSION) $(BUILDINFO_DATE) $(BUILDINFO_COMMIT)

BUILD_OPTS?="-ldflags=$(BUILDINFO)" -mod=vendor
BUILD_OPTS?="-ldflags=$(BUILDINFO)" -mod=vendor $(RACE_FLAG)
BUILD_OPTS_DEPLOY?="-ldflags=$(BUILDINFO) -w -s"

check: lint test ## Run linters and tests
Expand All @@ -61,15 +55,6 @@ build: host-apps bin ## Install dependencies, build apps and binaries. `go build

build-static: host-apps-static bin-static ## Build apps and binaries. `go build` with ${OPTS}

run: ## Run skywire visor with skywire-config.json, and start a browser if running a hypervisor
./skywire-visor -c ./skywire-config.json --launch-browser

stop: ## Stop running skywire-visor on host
-bash -c "kill $$(ps aux |grep '[s]kywire-visor' | awk '{print $$2}')"

config: ## Generate skywire-config.json
-./skywire-cli visor gen-config -o ./skywire-config.json -r --is-hypervisor

install-generate: ## Installs required execs for go generate.
${OPTS} go install github.com/mjibson/esc
${OPTS} go install github.com/vektra/mockery/cmd/mockery
Expand All @@ -89,16 +74,9 @@ clean: ## Clean project: remove created binaries and apps
install: ## Install `skywire-visor`, `skywire-cli`, `setup-node`
${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node


install-static: ## Install `skywire-visor`, `skywire-cli`, `setup-node`
${STATIC_OPTS} go install -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node

rerun: stop
${OPTS} go build -race -o ./skywire-visor ./cmd/skywire-visor
-./skywire-cli visor gen-config -o ./skywire.json -r
perl -pi -e 's/localhost//g' ./skywire.json
./skywire-visor skywire.json

lint: ## Run linters. Use make install-linters first
${OPTS} golangci-lint run -c .golangci.yml ./...
# The govet version in golangci-lint is out of date and has spurious warnings, run it separately
Expand All @@ -108,43 +86,26 @@ lint-extra: ## Run linters with extra checks.
# The govet version in golangci-lint is out of date and has spurious warnings, run it separately
${OPTS} go vet -all ./...

vendorcheck: ## Run vendorcheck
GO111MODULE=off vendorcheck ./internal/...
GO111MODULE=off vendorcheck ./pkg/...
GO111MODULE=off vendorcheck ./cmd/apps/...
GO111MODULE=off vendorcheck ./cmd/setup-node/...
GO111MODULE=off vendorcheck ./cmd/skywire-cli/...
GO111MODULE=off vendorcheck ./cmd/skywire-visor/...

test: ## Run tests
-go clean -testcache &>/dev/null
${OPTS} go test ${TEST_OPTS} ./internal/...
${OPTS} go test ${TEST_OPTS} ./pkg/...

test-no-ci: ## Run no_ci tests
-go clean -testcache
${OPTS} go test ${TEST_OPTS_NOCI} ./pkg/transport/... -run "TCP|PubKeyTable"

install-linters: ## Install linters
- VERSION=latest ./ci_scripts/install-golangci-lint.sh
# 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
# However, they suggest `curl ... | bash` which we should not do
# ${OPTS} go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
${OPTS} go get -u golang.org/x/tools/cmd/goimports
${OPTS} go get -u github.com/incu6us/goimports-reviser

tidy: ## Tidies and vendors dependencies.
${OPTS} go mod tidy -v
${OPTS} go mod vendor -v

format: tidy ## Formats the code. Must have goimports and goimports-reviser installed (use make install-linters).
${OPTS} goimports -w -local ${PROJECT_BASE} ./pkg
${OPTS} goimports -w -local ${PROJECT_BASE} ./cmd
${OPTS} goimports -w -local ${PROJECT_BASE} ./internal
find . -type f -name '*.go' -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} -file-path {} \;

dep: ## Sorts dependencies
dep: tidy ## Sorts dependencies
${OPTS} go mod vendor -v

host-apps: ## Build app
Expand Down Expand Up @@ -174,40 +135,13 @@ bin-static: ## Build `skywire-visor`, `skywire-cli`
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./skywire-cli ./cmd/skywire-cli
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./setup-node ./cmd/setup-node

release: ## Build `skywire-visor`, `skywire-cli` and apps without -race flag
${OPTS} go build ${BUILD_OPTS} -o ./skywire-visor ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS} -o ./skywire-cli ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS} -o ./setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -o ./apps/skychat ./cmd/apps/skychat
${OPTS} go build ${BUILD_OPTS} -o ./apps/skysocks ./cmd/apps/skysocks
${OPTS} go build ${BUILD_OPTS} -o ./apps/skysocks-client ./cmd/apps/skysocks-client
${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-server ./cmd/apps/vpn-server
${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-client ./cmd/apps/vpn-client

release-static: ## Build `skywire-visor`, `skywire-cli` and apps without -race flag
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./skywire-visor ./cmd/skywire-visor
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./skywire-cli ./cmd/skywire-cli
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./setup-node ./cmd/setup-node
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/skychat ./cmd/apps/skychat
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/skysocks ./cmd/apps/skysocks
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/skysocks-client ./cmd/apps/skysocks-client
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/vpn-server ./cmd/apps/vpn-server
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/vpn-client ./cmd/apps/vpn-client

build-deploy: ## Build for deployment Docker images
${OPTS} go build -tags netgo ${BUILD_OPTS_DEPLOY} -o /release/skywire-visor ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS_DEPLOY} -o /release/skywire-cli ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS_DEPLOY} -o /release/apps/skychat ./cmd/apps/skychat
${OPTS} go build ${BUILD_OPTS_DEPLOY} -o /release/apps/skysocks ./cmd/apps/skysocks
${OPTS} go build ${BUILD_OPTS_DEPLOY} -o /release/apps/skysocks-client ./cmd/apps/skysocks-client

build-deploy-static: ## Build for deployment Docker images
${STATIC_OPTS} go build -tags netgo -trimpath --ldflags '-w -s -linkmode external -extldflags "-static" -buildid=' -o /release/skywire-visor ./cmd/skywire-visor
${STATIC_OPTS} go build -trimpath --ldflags '-w -s -linkmode external -extldflags "-static" -buildid=' -o /release/skywire-cli ./cmd/skywire-cli
${STATIC_OPTS} go build -trimpath --ldflags '-w -s -linkmode external -extldflags "-static" -buildid=' -o /release/apps/skychat ./cmd/apps/skychat
${STATIC_OPTS} go build -trimpath --ldflags '-w -s -linkmode external -extldflags "-static" -buildid=' -o /release/apps/skysocks ./cmd/apps/skysocks
${STATIC_OPTS} go build -trimpath --ldflags '-w -s -linkmode external -extldflags "-static" -buildid=' -o /release/apps/skysocks-client ./cmd/apps/skysocks-client

github-release: ## Create a GitHub release
goreleaser --rm-dist

Expand Down Expand Up @@ -267,17 +201,11 @@ docker-rerun: docker-stop
${DOCKER_OPTS} go build -race -o ./visor/skywire-visor ./cmd/skywire-visor
docker container start -i ${DOCKER_NODE}

run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog
docker-run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog
-rm -rf /tmp/syslog
-mkdir -p /tmp/syslog
-docker container rm syslog-ng -f
docker run -d -p 514:514/udp -v /tmp/syslog:/var/log --name syslog-ng balabit/syslog-ng:latest

mod-comm: ## Comments the 'replace' rule in go.mod
./ci_scripts/go_mod_replace.sh comment go.mod

mod-uncomm: ## Uncomments the 'replace' rule in go.mod
./ci_scripts/go_mod_replace.sh uncomment go.mod

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
20 changes: 0 additions & 20 deletions ci_scripts/run-internal-tests.sh

This file was deleted.

Loading