wg-portal/Makefile

47 lines
1.0 KiB
Makefile
Raw Normal View History

2020-11-10 03:31:02 -05:00
# Go parameters
GOCMD=go
MODULENAME=github.com/h44z/wg-portal
GOFILES:=$(shell go list ./... | grep -v /vendor/)
BUILDDIR=dist
BINARIES=$(subst cmd/,,$(wildcard cmd/*))
2020-11-10 05:06:04 -05:00
IMAGE=h44z/wg-portal
2020-11-10 03:31:02 -05:00
.PHONY: all test clean phony
all: dep test build
build: dep $(addprefix $(BUILDDIR)/,$(BINARIES))
cp -r assets $(BUILDDIR)
dep:
$(GOCMD) mod download
2020-11-10 05:06:04 -05:00
validate: dep
2020-11-10 03:31:02 -05:00
$(GOCMD) fmt $(GOFILES)
$(GOCMD) vet $(GOFILES)
$(GOCMD) test -race $(GOFILES)
2020-11-10 05:06:04 -05:00
coverage: dep
2020-11-10 03:31:02 -05:00
$(GOCMD) fmt $(GOFILES)
$(GOCMD) test $(GOFILES) -v -coverprofile .testCoverage.txt
$(GOCMD) tool cover -func=.testCoverage.txt # use total:\s+\(statements\)\s+(\d+.\d+\%) as Gitlab CI regextotal:\s+\(statements\)\s+(\d+.\d+\%)
coverage-html: coverage
$(GOCMD) tool cover -html=.testCoverage.txt
2020-11-10 05:06:04 -05:00
test: dep
2020-11-10 03:31:02 -05:00
$(GOCMD) test $(MODULENAME)/... -v -count=1
clean:
$(GOCMD) clean $(GOFILES)
rm -rf .testCoverage.txt
rm -rf $(BUILDDIR)
2020-11-10 05:06:04 -05:00
docker-build:
docker build -t $(IMAGE) .
docker-push:
docker push $(IMAGE)
2020-11-10 03:31:02 -05:00
$(BUILDDIR)/%: cmd/%/main.go dep phony
$(GOCMD) build -o $@ $<