wip: docker and travis

This commit is contained in:
Christoph Haas
2020-11-10 11:06:04 +01:00
parent 3cbc30fe48
commit cd9abfcd5b
4 changed files with 97 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ MODULENAME=github.com/h44z/wg-portal
GOFILES:=$(shell go list ./... | grep -v /vendor/)
BUILDDIR=dist
BINARIES=$(subst cmd/,,$(wildcard cmd/*))
IMAGE=h44z/wg-portal
.PHONY: all test clean phony
@@ -15,12 +16,12 @@ build: dep $(addprefix $(BUILDDIR)/,$(BINARIES))
dep:
$(GOCMD) mod download
validate:
validate: dep
$(GOCMD) fmt $(GOFILES)
$(GOCMD) vet $(GOFILES)
$(GOCMD) test -race $(GOFILES)
coverage:
coverage: dep
$(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+\%)
@@ -28,7 +29,7 @@ coverage:
coverage-html: coverage
$(GOCMD) tool cover -html=.testCoverage.txt
test:
test: dep
$(GOCMD) test $(MODULENAME)/... -v -count=1
clean:
@@ -36,5 +37,11 @@ clean:
rm -rf .testCoverage.txt
rm -rf $(BUILDDIR)
docker-build:
docker build -t $(IMAGE) .
docker-push:
docker push $(IMAGE)
$(BUILDDIR)/%: cmd/%/main.go dep phony
$(GOCMD) build -o $@ $<