-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
94 lines (74 loc) · 2.99 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
89
90
91
92
93
94
VERSION = v0.0.6
#### Build ####
build: ## Build the binary
@echo "--> Building development binary"
@go build -ldflags="-X github.com/liftedinit/yaci/cmd/yaci.Version=$(VERSION)" -o bin/yaci ./main.go
.PHONY: build
#### Test ####
test: ## Run tests
@echo "--> Running tests"
@go test -v -short -race ./...
test-e2e: ## Run end-to-end tests
@echo "--> Running end-to-end tests"
@go test -v -race ./cmd/yaci/postgres_test.go
.PHONY: test test-e2e
#### Coverage ####
COV_ROOT="/tmp/yaci-coverage"
COV_UNIT="${COV_ROOT}/unit"
COV_E2E="${COV_ROOT}/e2e"
COV_PKG="github.com/liftedinit/yaci/..."
coverage: ## Run tests with coverage
@echo "--> Creating GOCOVERDIR"
@mkdir -p ${COV_UNIT} ${COV_E2E}
@echo "--> Cleaning up coverage files, if any"
@rm -rf ${COV_UNIT}/* ${COV_E2E}/*
@echo "--> Running short tests with coverage"
@go test -v -short -timeout 30m -race -covermode=atomic -cover -cpu=$$(nproc) -coverpkg=${COV_PKG} ./... -args -test.gocoverdir="${COV_UNIT}"
@echo "--> Running end-to-end tests with coverage"
@go test -v -race -timeout 30m -race -covermode=atomic -cover -cpu=$$(nproc) -coverpkg=${COV_PKG} ./cmd/yaci/postgres_test.go -args -test.gocoverdir="${COV_E2E}"
@echo "--> Merging coverage reports"
@go tool covdata merge -i=${COV_UNIT},${COV_E2E} -o ${COV_ROOT}
@echo "--> Converting binary coverage report to text format"
@go tool covdata textfmt -i=${COV_ROOT} -o ${COV_ROOT}/coverage-merged.out
@echo "--> Generating coverage report"
@go tool cover -func=${COV_ROOT}/coverage-merged.out
@echo "--> Generating HTML coverage report"
@go tool cover -html=${COV_ROOT}/coverage-merged.out -o coverage.html
@echo "--> Coverage report available at coverage.html"
@echo "--> Cleaning up coverage files"
@rm -rf ${COV_UNIT}/* ${COV_E2E}/*
@echo "--> Running coverage complete"
#### Docker ####
docker-up:
@echo "--> Running docker compose up --build --wait -d"
@docker compose -f docker/yaci.yml up --build --wait -d
docker-down:
@echo "--> Running docker compose down -v"
@docker compose -f docker/yaci.yml down -v
.PHONY: docker-up docker-down
#### Linting ####
golangci_lint_cmd=golangci-lint
golangci_version=v1.61.0
lint:
@echo "--> Running linter"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run ./... --timeout 15m
lint-fix:
@echo "--> Running linter and fixing issues"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run ./... --fix --timeout 15m
.PHONY: lint lint-fix
#### FORMAT ####
goimports_version=v0.26.0
format: ## Run formatter (goimports)
@echo "--> Running goimports"
@go install golang.org/x/tools/cmd/goimports@$(goimports_version)
@find . -name '*.go' -exec goimports -w -local github.com/liftedinit/yaci {} \;
.PHONY: format
#### GOVULNCHECK ####
govulncheck_version=v1.1.3
govulncheck: ## Run govulncheck
@echo "--> Running govulncheck"
@go install golang.org/x/vuln/cmd/govulncheck@$(govulncheck_version)
@govulncheck ./...
.PHONY: govulncheck