-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
88 lines (68 loc) · 3.02 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# renovate: datasource=go depName=github.com/golangci/golangci-lint
GOLANGCI_LINT_VERSION=v1.62.2
# renovate: datasource=go depName=gotest.tools/gotestsum
GOTESTSUM_VERSION=v1.12.0
# renovate: datasource=go depName=github.com/boumenot/gocover-cobertura
GOCOVER_COBERTURA_VERSION=v1.3.0
# renovate: datasource=github-releases depName=mockery/mockery
MOCKERY_VERSION=v2.42.0
# renovate: datasource=github-releases depName=palantir/go-license
GO_LICENSE_VERSION=v1.40.0
# renovate: datasource=github-tags depName=igorshubovych/markdownlint-cli
MARKDOWNLINT_VERSION=v0.43.0
# renovate: datasource=docker depName=pipelinecomponents/yamllint
YAMLLINT_VERSION=0.33.0
REPORTS_DIR=build/reports
CONFIG_DIR=build/config
.PHONY: all
check: clean generate lint test
.PHONY: clean
clean:
@rm -rf $(REPORTS_DIR)
@find . -type f -name "mock_*.go" -delete
.PHONY: lint
lint: lint-go lint-license lint-markdown lint-yaml
.PHONY: lint-go
lint-go: .install-linter generate
@golangci-lint run --config $(CONFIG_DIR)/.golangci.yml ./...
.PHONY: lint-fix
lint-fix: .install-linter .install-go-license
@golangci-lint run --fix --config $(CONFIG_DIR)/.golangci.yml ./...
@find . -type f -name '*.go' ! -name 'mock_*.go' | xargs go-license --config $(CONFIG_DIR)/.go-license.yaml
.PHONY: lint-license
lint-license: .install-go-license
@find . -type f -name '*.go' ! -name 'mock_*.go' | xargs go-license --config $(CONFIG_DIR)/.go-license.yaml --verify
.PHONY: lint-markdown
lint-markdown:
@docker run -it --rm -v `pwd`:/workdir:ro ghcr.io/igorshubovych/markdownlint-cli:$(MARKDOWNLINT_VERSION) --config $(CONFIG_DIR)/.markdownlint.yaml .
.PHONY: lint-yaml
lint-yaml:
@docker run -it --rm -v `pwd`:/code:ro pipelinecomponents/yamllint:$(YAMLLINT_VERSION) yamllint --config-file $(CONFIG_DIR)/.yamllint.yaml .
.PHONY: test
test: .install-gotestsum .ensure-reports-dir generate-mocks
@gotestsum --junitfile $(REPORTS_DIR)/unit-tests.xml -- -race -v -coverprofile=$(REPORTS_DIR)/coverage.out -covermode=atomic -v -cover ./...
.PHONY: report-coverage
report-coverage: .install-cover-cobertura .ensure-reports-dir
@sed -i.bak '/\/mock_.*\.go/d' $(REPORTS_DIR)/coverage.out
@sed -i.bak '/internal\/example\.go/d' $(REPORTS_DIR)/coverage.out
@go tool cover -func=$(REPORTS_DIR)/coverage.out
@gocover-cobertura < $(REPORTS_DIR)/coverage.out > $(REPORTS_DIR)/coverage.xml
.PHONY: test-with-coverage
test-with-coverage: test report-coverage
.PHONY: generate
generate: clean generate-mocks
.PHONY: generate-mocks
generate-mocks: .install-mockery
@mockery --config $(CONFIG_DIR)/.mockery.yaml
.install-linter:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
.install-go-license:
@go install github.com/palantir/go-license@$(GO_LICENSE_VERSION)
.install-gotestsum:
@go install gotest.tools/gotestsum@$(GOTESTSUM_VERSION)
.install-cover-cobertura:
@go install github.com/boumenot/gocover-cobertura@$(GOCOVER_COBERTURA_VERSION)
.install-mockery:
@go install github.com/vektra/mockery/v2@$(MOCKERY_VERSION)
.ensure-reports-dir:
@mkdir -p $(REPORTS_DIR)