Skip to content

Commit 0f26fcb

Browse files
committed
NO-JIRA: add golangci-lint
1 parent 4b2ccc0 commit 0f26fcb

3 files changed

Lines changed: 44 additions & 9 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ dist/
1414
.devspace
1515
web/po-files/
1616
.claude/commands/configs
17+
_output/

.golangci-lint.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# List of all configuration options at https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
2+
version: "2"
3+
4+
linters:
5+
settings:
6+
errcheck:
7+
exclude-functions:
8+
- (net/http.ResponseWriter).Write
9+
exclusions:
10+
generated: strict
11+
rules:
12+
# Disable errcheck linter for test files.
13+
- linters:
14+
- errcheck
15+
path: _test.go
16+
17+
formatters:
18+
enable:
19+
- gci
20+
- gofmt
21+
settings:
22+
gci:
23+
sections:
24+
- standard
25+
- default
26+
- prefix(github.com/openshift/monitoring-plugin)

Makefile

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ PLUGIN_NAME ?=monitoring-plugin
55
IMAGE ?= quay.io/${ORG}/${PLUGIN_NAME}:${VERSION}
66
FEATURES ?=incidents,perses-dashboards,dev-config
77

8+
GOLANGCI_LINT = $(shell pwd)/_output/tools/bin/golangci-lint
9+
GOLANGCI_LINT_VERSION ?= v2.11.3
10+
811
export NODE_OPTIONS?=--max_old_space_size=4096
912

1013
.PHONY: install-frontend
@@ -39,12 +42,6 @@ i18n-frontend:
3942
lint-frontend:
4043
cd web && npm run lint
4144

42-
.PHONY: lint-backend
43-
lint-backend:
44-
go mod tidy
45-
go fmt ./cmd/
46-
go fmt ./pkg/
47-
4845
.PHONY: install-backend
4946
install-backend:
5047
go mod download
@@ -69,7 +66,6 @@ test-frontend:
6966
build-image:
7067
./scripts/build-image.sh
7168

72-
7369
.PHONY: install
7470
install:
7571
make install-frontend && make install-backend
@@ -79,8 +75,7 @@ update-plugin-name:
7975
./scripts/update-plugin-name.sh
8076

8177
.PHONY: deploy
82-
deploy:
83-
make lint-backend
78+
deploy: lint-backend
8479
PUSH=1 scripts/build-image.sh
8580
helm uninstall $(PLUGIN_NAME) -n $(PLUGIN_NAME)-ns || true
8681
helm install $(PLUGIN_NAME) charts/openshift-console-plugin -n monitoring-plugin-ns --create-namespace --set plugin.image=$(IMAGE)
@@ -89,6 +84,19 @@ deploy:
8984
deploy-acm:
9085
./scripts/deploy-acm.sh
9186

87+
# Download and install golangci-lint if not already installed
88+
.PHONY: golangci-lint
89+
golangci-lint:
90+
@[ -f $(GOLANGCI_LINT) ] || { \
91+
set -e ;\
92+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
93+
}
94+
95+
.PHONY: lint-backend
96+
lint-backend: golangci-lint
97+
go mod tidy
98+
$(GOLANGCI_LINT) -c $(shell pwd)/.golangci-lint.yaml run --verbose
99+
92100
.PHONY: build-mcp-image
93101
build-mcp-image:
94102
DOCKER_FILE_NAME="Dockerfile.mcp" REPO="monitoring-console-plugin" scripts/build-image.sh

0 commit comments

Comments
 (0)