Skip to content

Commit

Permalink
Merge pull request #275 from NVIDIA/collect-code-coverage
Browse files Browse the repository at this point in the history
Added: make test-coverage to show the current test coverage
  • Loading branch information
nvvfedorov authored Mar 1, 2024
2 parents 77a0b14 + 8973818 commit 9d2d633
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ dcgm-exporter
*.pem
*.csr
vendor/
tests.cov
test_results.json
.scannerwork

###############################################################################
# JetBrains
Expand Down
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@ OUTPUT := type=oci,dest=/tmp/dcgm-exporter.tar
PLATFORMS := linux/amd64,linux/arm64
DOCKERCMD := docker buildx build

NON_TEST_FILES := pkg/dcgmexporter/dcgm.go pkg/dcgmexporter/gpu_collector.go pkg/dcgmexporter/parser.go
NON_TEST_FILES += pkg/dcgmexporter/pipeline.go pkg/dcgmexporter/server.go pkg/dcgmexporter/system_info.go
NON_TEST_FILES += pkg/dcgmexporter/types.go pkg/dcgmexporter/utils.go pkg/dcgmexporter/kubernetes.go
NON_TEST_FILES += cmd/dcgm-exporter/main.go
MAIN_TEST_FILES := pkg/dcgmexporter/system_info_test.go

.PHONY: all binary install check-format local
all: ubuntu22.04 ubi9

binary:
cd cmd/dcgm-exporter; go build -ldflags "-X main.BuildVersion=${DCGM_VERSION}-${VERSION}"

test-main: $(NON_TEST_FILES) $(MAIN_TEST_FILES)
test-main:
go test ./... -short

install: binary
Expand Down Expand Up @@ -80,7 +74,10 @@ ubi9:
.PHONY: integration
test-integration:
go test -race -count=1 -timeout 5m -v $(TEST_ARGS) ./tests/integration/


test-coverage:
gocov test ./... | gocov report

.PHONY: lint
lint:
golangci-lint run ./...
Expand All @@ -95,4 +92,6 @@ validate-modules:

.PHONY: tools
tools: ## Install required tools and utilities
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install github.com/axw/gocov/gocov@latest

0 comments on commit 9d2d633

Please sign in to comment.