Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Added golangci configuration and formater to the makefile #300

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -16,6 +16,7 @@ include hack/VERSION

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

DCGM_VERSION := $(NEW_DCGM_VERSION)
GOLANG_VERSION := 1.21.5
Expand Down Expand Up @@ -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:
Expand All @@ -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)/... \
Expand Down
4 changes: 2 additions & 2 deletions pkg/dcgmexporter/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func (s *PodResourcesMockServer) List(
return &podresourcesapi.ListPodResourcesResponse{
PodResources: podResources,
}, nil

}

func TestProcessPodMapper_WithD_Different_Format_Of_DeviceID(t *testing.T) {
Expand Down Expand Up @@ -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{}
Expand Down
Loading