From 8cb286ed5cf2457585e4c27c6c1d05cc3fd69d21 Mon Sep 17 00:00:00 2001 From: Marvin Preuss Date: Tue, 29 Mar 2022 11:45:46 +0200 Subject: [PATCH] build(make): reorganization --- .gitignore | 3 +++ Makefile | 78 ++++++++++++++++++++++++++++++++---------------------- 2 files changed, 49 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index d7b7f0a..bf0302e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ coverage.* dist/* +report.xml +.gobin/* +.cache/* diff --git a/Makefile b/Makefile index b18162f..e5db305 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,21 @@ -.PHONY: build -build: - goreleaser build --rm-dist --snapshot +GO := go -.PHONY: release -release: - goreleaser release --rm-dist --snapshot --skip-publish +ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +CACHE_DIR := $(ROOT_DIR)/.cache -.PHONY: generate -generate: - go generate +export GOBIN := $(ROOT_DIR)/.gobin +export PATH := $(GOBIN):$(PATH) -.PHONY: lint -lint: - golangci-lint run --enable-all --disable=exhaustivestruct,godox +GORELEASER := $(GO) run github.com/goreleaser/goreleaser@v1.7.0 +GOLANGCI_LINT := $(GO) run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2 -.PHONY: test -test: - go test -v \ - -race \ - -coverprofile coverage.out \ - ./... - go tool cover -func coverage.out +GOTESTSUM := $(GO) run gotest.tools/gotestsum@v1.7.0 -.PHONY: tidy -tidy: - go mod tidy - go mod vendor - -.PHONY: coverage -coverage: - gocover-cobertura < coverage.out > coverage.xml - -.PHONY: install-tools -install-tools: - go list -f '{{range .Imports}}{{.}} {{end}}' tools/tools.go | xargs go install -v +GOREADME := $(GO) run github.com/posener/goreadme/cmd/goreadme@v1.4.2 .PHONY: readme readme: - goreadme \ + $(GOREADME) \ -constants \ -credit=false \ -types \ @@ -48,3 +26,39 @@ readme: .PHONY: setup-githooks setup-githooks: git config core.hooksPath githooks + +.PHONY: test +test: + $(GOTESTSUM) \ + --junitfile report.xml \ + -- \ + -race \ + -cover \ + -coverprofile=coverage.out \ + -tags=integration \ + ./... \ + -timeout=120m + +.PHONY: lint +lint: + $(GOLANGCI_LINT) run \ + --enable-all \ + --disable=godox,varnamelen,exhaustivestruct \ + --timeout 10m + +.PHONY: tidy +tidy: + $(GO) mod tidy + $(GO) mod vendor + +.PHONY: build +build: + $(GORELEASER) build --rm-dist --snapshot + +.PHONY: release +release: + $(GORELEASER) release --rm-dist + +.PHONY: release-snapshot +release-snapshot: + $(GORELEASER) release --rm-dist --snapshot --skip-publish