Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (49 loc) · 2.01 KB
/
Copy pathMakefile
File metadata and controls
59 lines (49 loc) · 2.01 KB
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
ROOT_PATH := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
COVERAGE_PATH := $(ROOT_PATH).coverage/
MOCK_GENERATED_PATHS := mock/ ':(glob)**/mock_*_test.go'
# Use the locally installed Go toolchain.
export GOTOOLCHAIN=local
# Ensure our local tools are preferred
export PATH := $(ROOT_PATH)tools/bin:$(PATH)
include $(ROOT_PATH)tools/tools.mk
.PHONY: mockgen
mockgen: install-mockgen
@echo "Generating mocks..."
@rm -rf mock
@mkdir -p mock
$(MOCKGEN_LINK) -destination=mock/Repository.go -package=mock github.com/e2engine/core/repository EntityRepository,ResourceRepository,TestRepository,TestExecutionRepository,TestSuiteExecutionRepository
$(MOCKGEN_LINK) -destination=mock/Runtime.go -package=mock github.com/e2engine/core/execute/runtime Service,ServiceProvider,Router,RouterProvider
$(MOCKGEN_LINK) -destination=mock/Execute.go -package=mock github.com/e2engine/core/execute ProtocolExecutor
go generate ./...
@git diff HEAD --exit-code -- $(MOCK_GENERATED_PATHS)
@test -z "$$(git ls-files --others --exclude-standard -- $(MOCK_GENERATED_PATHS))"
.PHONY: lint
lint: install-golangci-lint
@echo "Running linter..."
$(GOLANGCI_LINT) run
.PHONY: vulncheck
vulncheck: install-govulncheck
@echo "Checking for known vulnerabilities..."
$(GOVULNCHECK) ./...
.PHONY: test
test:
@echo "Running tests..."
@go clean -testcache
@go test ./... -count=1 -timeout=600s
.PHONY: test-cov
test-cov:
@echo "Running tests with coverage..."
@go clean -testcache
@rm -rf $(COVERAGE_PATH)
@mkdir -p $(COVERAGE_PATH)
@go test -v -coverpkg=./... ./... -coverprofile $(COVERAGE_PATH)coverage.txt -count=1 -timeout=600s -tags=debug
@go tool cover -func=$(COVERAGE_PATH)coverage.txt -o $(COVERAGE_PATH)functions.txt
@go tool cover -html=$(COVERAGE_PATH)coverage.txt -o $(COVERAGE_PATH)coverage.html
.PHONY: test-race
test-race:
@echo "Running tests with race detector..."
@go clean -testcache
@go test ./... -race -count=1 -timeout=600s
.PHONY: verify
verify: mockgen lint vulncheck test-race
@echo "All verifications passed successfully."