Go modules (#22)

* Move to go modules

* Move go.mod in root directory

* Update Readme

* Remove golang.org/x/tools from go.mod

* Remove go list from targets

* Set go version to 1.12

* Update Makefile

Co-Authored-By: hanzei <16541325+hanzei@users.noreply.github.com>

* Update dependencies

* Fix build
This commit is contained in:
Hanzei 2019-04-10 21:42:33 +02:00 committed by Christopher Speller
parent 05dd2de750
commit fe3553d999
327 changed files with 208 additions and 58246 deletions

View file

@ -1,8 +1,8 @@
GO ?= $(shell command -v go 2> /dev/null)
DEP ?= $(shell command -v dep 2> /dev/null)
NPM ?= $(shell command -v npm 2> /dev/null)
CURL ?= $(shell command -v curl 2> /dev/null)
MANIFEST_FILE ?= plugin.json
export GO111MODULE=on
# You can include assets this directory into the bundle. This can be e.g. used to include profile pictures.
ASSETS_DIR ?= assets
@ -22,7 +22,7 @@ apply:
## Runs govet and gofmt against all packages.
.PHONY: check-style
check-style: server/.depensure webapp/.npminstall gofmt govet
check-style: webapp/.npminstall gofmt govet
@echo Checking for style guide compliance
ifneq ($(HAS_WEBAPP),)
@ -54,22 +54,16 @@ endif
govet:
ifneq ($(HAS_SERVER),)
@echo Running govet
$(GO) get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
$(GO) vet $$(go list ./server/...)
$(GO) vet -vettool=$(GOPATH)/bin/shadow $$(go list ./server/...)
@# Workaroung because you can't install binaries without adding them to go.mod
env GO111MODULE=off $(GO) get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
$(GO) vet ./server/...
$(GO) vet -vettool=$(GOPATH)/bin/shadow ./server/...
@echo Govet success
endif
## Ensures the server dependencies are installed.
server/.depensure:
ifneq ($(HAS_SERVER),)
cd server && $(DEP) ensure
touch $@
endif
## Builds the server, if it exists, including support for multiple architectures.
.PHONY: server
server: server/.depensure
server:
ifneq ($(HAS_SERVER),)
mkdir -p server/dist;
cd server && env GOOS=linux GOARCH=amd64 $(GO) build -o dist/plugin-linux-amd64;
@ -140,9 +134,9 @@ endif
## Runs any lints and unit tests defined for the server and webapp, if they exist.
.PHONY: test
test: server/.depensure webapp/.npminstall
test: webapp/.npminstall
ifneq ($(HAS_SERVER),)
cd server && $(GO) test -race -v ./...
$(GO) test -race -v ./server/...
endif
ifneq ($(HAS_WEBAPP),)
cd webapp && $(NPM) run fix;
@ -152,8 +146,8 @@ endif
.PHONY: coverage
coverage: server/.depensure webapp/.npminstall
ifneq ($(HAS_SERVER),)
cd server && $(GO) test -race -coverprofile=coverage.txt ./...
@cd server && $(GO) tool cover -html=coverage.txt
$(GO) test -race -coverprofile=server/coverage.txt ./server/...
$(GO) tool cover -html=server/coverage.txt
endif
## Clean removes all build artifacts.
@ -162,7 +156,6 @@ clean:
rm -fr dist/
ifneq ($(HAS_SERVER),)
rm -fr server/dist
rm -fr server/.depensure
endif
ifneq ($(HAS_WEBAPP),)
rm -fr webapp/.npminstall