Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit f96c07a

Browse files
authored
Merge pull request #96 from BlaineEXE/add-e2e-lint-targets
add kubebuilder suggested e2e and lint targets
2 parents e9d5dfb + 89f3653 commit f96c07a

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
release-tools
66
.idea
77
travis.yml
8-
8+
.cache

.golangci.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
run:
2+
timeout: 5m
3+
allow-parallel-runners: true
4+
5+
issues:
6+
# don't skip warning about doc comments
7+
# don't exclude the default set of lint
8+
exclude-use-default: false
9+
# restore some of the defaults
10+
# (fill in the rest as needed)
11+
exclude-rules:
12+
- path: "apis/*"
13+
linters:
14+
- lll
15+
- path: "internal/*"
16+
linters:
17+
- dupl
18+
- lll
19+
linters:
20+
disable-all: true
21+
enable:
22+
- copyloopvar
23+
- dupl
24+
- errcheck
25+
- ginkgolinter
26+
- goconst
27+
- gocyclo
28+
- gofmt
29+
- goimports
30+
- gosimple
31+
- govet
32+
- ineffassign
33+
- lll
34+
- misspell
35+
- nakedret
36+
- prealloc
37+
- revive
38+
- staticcheck
39+
- typecheck
40+
- unconvert
41+
- unparam
42+
- unused
43+
44+
linters-settings:
45+
revive:
46+
rules:
47+
- name: comment-spacings

Makefile

+48
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ vet: vet.client vet.controller vet.sidecar ## Vet code
6060
.PHONY: test
6161
test: .test.proto test.client test.controller test.sidecar ## Run tests including unit tests
6262

63+
.PHONY: test-e2e
64+
test-e2e: # Run e2e tests
65+
@echo "unimplemented placeholder"
66+
67+
.PHONY: lint
68+
lint: golangci-lint.client golangci-lint.controller golangci-lint.sidecar ## Run all linters (suggest `make -k`)
69+
70+
.PHONY: lint-fix
71+
lint-fix: golangci-lint-fix.client golangci-lint-fix.controller golangci-lint-fix.sidecar ## Run all linters and perform fixes where possible (suggest `make -k`)
72+
6373

6474
##@ Build
6575

@@ -81,7 +91,38 @@ clean:
8191
## Clean build environment and cached tools
8292
clobber:
8393
$(MAKE) -C proto clobber
94+
rm -rf $(CURDIR)/.cache
8495

96+
##
97+
## === TOOLS === #
98+
99+
GOLANGCI_LINT_VERSION ?= v1.61.0
100+
101+
TOOLBIN ?= $(CURDIR)/.cache/tools
102+
$(TOOLBIN):
103+
mkdir -p $(TOOLBIN)
104+
105+
GOLANGCI_LINT ?= $(TOOLBIN)/golangci-lint
106+
# .PHONY: golangci-lint
107+
# golangci-lint: $(GOLANGCI_LINT)
108+
$(GOLANGCI_LINT): $(TOOLBIN)
109+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
110+
111+
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
112+
# $1 - target path with name of binary
113+
# $2 - package url which can be installed
114+
# $3 - specific version of package
115+
define go-install-tool
116+
@[ -f "$(1)-$(3)" ] || { \
117+
set -e; \
118+
package=$(2)@$(3) ;\
119+
echo "Downloading $${package}" ;\
120+
rm -f $(1) || true ;\
121+
GOBIN=$(TOOLBIN) go install $${package} ;\
122+
mv $(1) $(1)-$(3) ;\
123+
} ;\
124+
ln -sf $(1)-$(3) $(1)
125+
endef
85126

86127
##
87128
## === INTERMEDIATES === #
@@ -101,6 +142,13 @@ vet.%: FORCE
101142
test.%: fmt.% vet.% FORCE
102143
cd $* && go test ./...
103144

145+
# golangci-lint --new flag only complains about new code
146+
golangci-lint.%: $(GOLANGCI_LINT)
147+
cd $* && $(GOLANGCI_LINT) run --config $(CURDIR)/.golangci.yaml --new
148+
149+
golangci-lint-fix.%: $(GOLANGCI_LINT)
150+
cd $* && $(GOLANGCI_LINT) run --config $(CURDIR)/.golangci.yaml --new --fix
151+
104152
.PHONY: .test.proto
105153
.test.proto: # gRPC proto has a special unit test
106154
$(MAKE) -C proto check

0 commit comments

Comments
 (0)