forked from kilnfi/go-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (40 loc) · 1.62 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# List of effective go files
GOFILES := $(shell find . -name '*.go' -not -path "./vendor/*" -not -path "./tests/*" | egrep -v "^\./\.go" | grep -v _test.go)
# List of packages except testsutils
PACKAGES ?= $(shell go list ./... | grep -v "mock" )
# Build folder
BUILD_FOLDER = build
# Test coverage variables
COVERAGE_BUILD_FOLDER = $(BUILD_FOLDER)/coverage
UNIT_COVERAGE_OUT = $(COVERAGE_BUILD_FOLDER)/ut_cov.out
UNIT_COVERAGE_HTML =$(COVERAGE_BUILD_FOLDER)/ut_index.html
INTEGRATION_COVERAGE_OUT = $(COVERAGE_BUILD_FOLDER)/it_cov.out
INTEGRATION_COVERAGE_HTML =$(COVERAGE_BUILD_FOLDER)/it_index.html
# Test lint variables
GOLANGCI_VERSION = v1.48.0
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OPEN = xdg-open
endif
ifeq ($(UNAME_S),Darwin)
OPEN = open
endif
ifneq (,$(wildcard ./.env))
include .env
export
endif
build/coverage:
@mkdir -p build/coverage
unit-test: build/coverage
@go test -covermode=count -coverprofile $(UNIT_COVERAGE_OUT) -v $(PACKAGES)
unit-test-cov: unit-test
@go tool cover -html=$(UNIT_COVERAGE_OUT) -o $(UNIT_COVERAGE_HTML)
fix-lint: ## Run linter to fix issues
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:$(GOLANGCI_VERSION) golangci-lint run --fix
# @misspell -error $(GOFILES)
test-lint: ## Check linting
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:$(GOLANGCI_VERSION) golangci-lint run -v
integration-test: build/coverage
@go test -covermode=count -coverprofile $(INTEGRATION_COVERAGE_OUT) -v --tags integration ${PACKAGES}
integration-test-cov: integration-test
@go tool cover -html=$(INTEGRATION_COVERAGE_OUT) -o $(INTEGRATION_COVERAGE_HTML)