Skip to content

Commit

Permalink
Chore: Added golangci configuration and formater to the makefile (#300)
Browse files Browse the repository at this point in the history
* Added golangci configuration

Signed-off-by: Vadym Fedorov <vfedorov@nvidia.com>

* Verbose flag added to the golangci-lint command

Signed-off-by: Vadym Fedorov <vfedorov@nvidia.com>

---------

Signed-off-by: Vadym Fedorov <vfedorov@nvidia.com>
nvvfedorov authored Apr 2, 2024
1 parent 31195d5 commit 1c79aca
Showing 3 changed files with 27 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
linters:
enable:
- contextcheck
- gocritic
- gofmt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- misspell
- staticcheck
- unused
- gofumpt

linters-settings:
goimports:
local-prefixes: github.com/NVIDIA/dcgm-exporter

7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ include hack/VERSION

MKDIR ?= mkdir
REGISTRY ?= nvidia
GOLANGCILINT_TIMEOUT ?= 10m

DCGM_VERSION := $(NEW_DCGM_VERSION)
GOLANG_VERSION := 1.21.5
@@ -83,7 +84,7 @@ test-coverage:

.PHONY: lint
lint:
golangci-lint run ./...
golangci-lint run ./... --timeout $(GOLANGCILINT_TIMEOUT) --new-from-rev=HEAD~1 --verbose

.PHONY: validate-modules
validate-modules:
@@ -98,6 +99,10 @@ tools: ## Install required tools and utilities
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2
go install github.com/axw/gocov/gocov@latest
go install golang.org/x/tools/cmd/goimports@latest
go install mvdan.cc/gofumpt@latest

fmt:
find . -name '*.go' | xargs gofumpt -l -w

goimports:
go list -f {{.Dir}} $(MODULE)/... \
4 changes: 2 additions & 2 deletions pkg/dcgmexporter/kubernetes_test.go
Original file line number Diff line number Diff line change
@@ -162,7 +162,6 @@ func (s *PodResourcesMockServer) List(
return &podresourcesapi.ListPodResourcesResponse{
PodResources: podResources,
}, nil

}

func TestProcessPodMapper_WithD_Different_Format_Of_DeviceID(t *testing.T) {
@@ -273,7 +272,8 @@ func TestProcessPodMapper_WithD_Different_Format_Of_DeviceID(t *testing.T) {

podMapper, err := NewPodMapper(&Config{
KubernetesGPUIdType: tc.KubernetesGPUIDType,
PodResourcesKubeletSocket: socketPath})
PodResourcesKubeletSocket: socketPath,
})
require.NoError(t, err)
require.NotNil(t, podMapper)
metrics := MetricsByCounter{}

0 comments on commit 1c79aca

Please sign in to comment.