2020-12-09 15:31:34 +00:00
|
|
|
# Use bash syntax
|
|
|
|
SHELL=/bin/bash
|
|
|
|
# Go parameters
|
|
|
|
GOCMD=go
|
|
|
|
GOBINPATH=$(shell $(GOCMD) env GOPATH)/bin
|
|
|
|
GOMOD=$(GOCMD) mod
|
|
|
|
GOBUILD=$(GOCMD) build
|
|
|
|
GOCLEAN=$(GOCMD) clean
|
|
|
|
GOTEST=gotestsum
|
|
|
|
GOGET=$(GOCMD) get
|
2021-04-01 08:23:42 +00:00
|
|
|
GOINSTALL=$(GOCMD) install
|
2020-12-09 15:31:34 +00:00
|
|
|
GOTOOL=$(GOCMD) tool
|
|
|
|
GOFMT=$(GOCMD) fmt
|
2021-02-15 14:21:54 +00:00
|
|
|
# ACC tests params
|
|
|
|
ACC_PATTERN ?= TestAcc_
|
2020-12-09 15:31:34 +00:00
|
|
|
|
|
|
|
.PHONY: FORCE
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: fmt lint test build
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build:
|
2021-07-22 08:43:35 +00:00
|
|
|
ENV=dev ./scripts/build.sh
|
2020-12-09 15:31:34 +00:00
|
|
|
|
|
|
|
.PHONY: release
|
|
|
|
release:
|
2021-07-22 08:43:35 +00:00
|
|
|
ENV=release ./scripts/build.sh
|
2020-12-09 15:31:34 +00:00
|
|
|
|
|
|
|
.PHONY: test
|
2021-02-08 14:47:26 +00:00
|
|
|
test: deps
|
2021-03-31 14:35:46 +00:00
|
|
|
$(GOTEST) --format testname --junitfile unit-tests.xml -- -mod=readonly -coverprofile=cover.out.tmp -coverpkg=.,./pkg/... ./...
|
2021-02-23 17:16:10 +00:00
|
|
|
cat cover.out.tmp | grep -v "mock_" > cover.out
|
2020-12-09 15:31:34 +00:00
|
|
|
|
|
|
|
.PHONY: coverage
|
|
|
|
coverage: test
|
|
|
|
$(GOTOOL) cover -func=cover.out
|
|
|
|
|
|
|
|
.PHONY: acc
|
|
|
|
acc:
|
2021-06-03 15:05:41 +00:00
|
|
|
DRIFTCTL_ACC=true $(GOTEST) --format testname --junitfile unit-tests-acc.xml -- -coverprofile=cover-acc.out -test.timeout 2h -coverpkg=./pkg/... -run=$(ACC_PATTERN) ./pkg/...
|
2020-12-09 15:31:34 +00:00
|
|
|
|
|
|
|
.PHONY: mocks
|
|
|
|
mocks: deps
|
|
|
|
rm -rf mocks
|
|
|
|
mockery --all
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: fmt
|
|
|
|
fmt:
|
|
|
|
$(GOFMT) ./...
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
$(GOCLEAN)
|
|
|
|
rm -f bin/*
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
|
|
|
@which golangci-lint > /dev/null 2>&1 || (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $(GOBINPATH) v1.31.0)
|
2021-06-18 10:01:01 +00:00
|
|
|
golangci-lint run -v --timeout=10m
|
2020-12-09 15:31:34 +00:00
|
|
|
|
|
|
|
.PHONY: deps
|
|
|
|
deps:
|
|
|
|
$(GOMOD) download
|
|
|
|
|
|
|
|
.PHONY: install-tools
|
|
|
|
install-tools:
|
2021-04-01 08:23:42 +00:00
|
|
|
$(GOINSTALL) gotest.tools/gotestsum@v1.6.3
|
|
|
|
$(GOINSTALL) github.com/vektra/mockery/v2@latest
|
2020-12-09 15:31:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
go.mod: FORCE
|
|
|
|
$(GOMOD) tidy
|
|
|
|
$(GOMOD) verify
|
|
|
|
go.sum: go.mod
|