build(make): reorganization

This commit is contained in:
Marvin Preuss 2022-03-29 11:45:46 +02:00
parent a5f803b333
commit 8cb286ed5c
2 changed files with 49 additions and 32 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
coverage.* coverage.*
dist/* dist/*
report.xml
.gobin/*
.cache/*

View File

@ -1,43 +1,21 @@
.PHONY: build GO := go
build:
goreleaser build --rm-dist --snapshot
.PHONY: release ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
release: CACHE_DIR := $(ROOT_DIR)/.cache
goreleaser release --rm-dist --snapshot --skip-publish
.PHONY: generate export GOBIN := $(ROOT_DIR)/.gobin
generate: export PATH := $(GOBIN):$(PATH)
go generate
.PHONY: lint GORELEASER := $(GO) run github.com/goreleaser/goreleaser@v1.7.0
lint: GOLANGCI_LINT := $(GO) run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
golangci-lint run --enable-all --disable=exhaustivestruct,godox
.PHONY: test GOTESTSUM := $(GO) run gotest.tools/gotestsum@v1.7.0
test:
go test -v \
-race \
-coverprofile coverage.out \
./...
go tool cover -func coverage.out
.PHONY: tidy GOREADME := $(GO) run github.com/posener/goreadme/cmd/goreadme@v1.4.2
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
.PHONY: readme .PHONY: readme
readme: readme:
goreadme \ $(GOREADME) \
-constants \ -constants \
-credit=false \ -credit=false \
-types \ -types \
@ -48,3 +26,39 @@ readme:
.PHONY: setup-githooks .PHONY: setup-githooks
setup-githooks: setup-githooks:
git config core.hooksPath 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