mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
initial targets for unit test and code coverage
This commit is contained in:
parent
d0e1524480
commit
6690f37426
1 changed files with 31 additions and 1 deletions
32
Makefile
32
Makefile
|
@ -55,4 +55,34 @@ docker-tag-repo:
|
||||||
|
|
||||||
docker-push:
|
docker-push:
|
||||||
@docker push $(REPO):$(IMAGE_TAG)
|
@docker push $(REPO):$(IMAGE_TAG)
|
||||||
@docker push $(REPO):latest
|
@docker push $(REPO):latest
|
||||||
|
|
||||||
|
## Testing & Code-Coverage
|
||||||
|
|
||||||
|
## variables
|
||||||
|
BIN_DIR := $(GOPATH)/bin
|
||||||
|
GO_ACC := $(BIN_DIR)/go-acc
|
||||||
|
CODE_COVERAGE_FILE:= coverage
|
||||||
|
CODE_COVERAGE_FILE_TXT := $(CODE_COVERAGE_FILE).txt
|
||||||
|
CODE_COVERAGE_FILE_HTML := $(CODE_COVERAGE_FILE).html
|
||||||
|
|
||||||
|
## targets
|
||||||
|
$(GO_ACC):
|
||||||
|
@echo " downloading testing tools"
|
||||||
|
go get -v github.com/ory/go-acc
|
||||||
|
$(eval export PATH=$(GO_ACC):$(PATH))
|
||||||
|
# go test provides code coverage per packages only.
|
||||||
|
# go-acc merges the result for pks so that it be used by
|
||||||
|
# go tool cover for reporting
|
||||||
|
|
||||||
|
# go get downloads and installs the binary
|
||||||
|
# we temporarily add the GO_ACC to the path
|
||||||
|
test-all: $(GO_ACC)
|
||||||
|
@echo " running unit tests"
|
||||||
|
go-acc ./... -o $(CODE_COVERAGE_FILE_TXT)
|
||||||
|
|
||||||
|
code-cov-report: $(CODE_COVERAGE_FILE_TXT)
|
||||||
|
# transform to html format
|
||||||
|
@echo " generating code coverage report"
|
||||||
|
go tool cover -html=coverage.txt
|
||||||
|
if [ -a $(CODE_COVERAGE_FILE_HTML) ]; then open $(CODE_COVERAGE_FILE_HTML); fi;
|
Loading…
Reference in a new issue