Skip to content

Commit 04dae7b

Browse files
committed
Upgrade Makefile, add linting step
1 parent 7804be3 commit 04dae7b

File tree

2 files changed

+136
-5
lines changed

2 files changed

+136
-5
lines changed

.golangci.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
linters:
2+
disable-all: true
3+
enable:
4+
- goimports
5+
- revive
6+
issues:
7+
exclude-use-default: false
8+
linters-settings:
9+
revive:
10+
rules:
11+
- name: blank-imports
12+
- name: context-as-argument
13+
- name: context-keys-type
14+
- name: dot-imports
15+
- name: error-return
16+
- name: error-strings
17+
- name: error-naming
18+
- name: exported
19+
- name: if-return
20+
- name: increment-decrement
21+
- name: var-naming
22+
- name: var-declaration
23+
- name: package-comments
24+
- name: range
25+
- name: receiver-naming
26+
- name: time-naming
27+
- name: unexported-return
28+
- name: indent-error-flow
29+
- name: errorf
30+
- name: empty-block
31+
- name: superfluous-else
32+
- name: unused-parameter
33+
- name: unreachable-code
34+
- name: redefines-builtin-id

makefile

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,108 @@
1+
dockerImage?=marklogic-centos/marklogic-server-centos:10-internal
12

2-
install-go-modules:
3+
## System requirement:
4+
## - Go
5+
## - Helm
6+
## - Minikube
7+
## - GNU Make >= 3.8.2 (preferrably >=4.2.1)
8+
9+
#***************************************************************************
10+
# help
11+
#***************************************************************************
12+
## Get this help text
13+
.PHONY: help
14+
help:
15+
@printf "Usage\n";
16+
17+
@awk '{ \
18+
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
19+
helpCommand = substr($$0, index($$0, ":") + 2); \
20+
if (helpMessage) { \
21+
printf "\033[36m%-20s\033[0m %s\n", \
22+
helpCommand, helpMessage; \
23+
helpMessage = ""; \
24+
} \
25+
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
26+
helpCommand = substr($$0, 0, index($$0, ":")); \
27+
if (helpMessage) { \
28+
printf "\033[36m%-20s\033[0m %s\n", \
29+
helpCommand, helpMessage; \
30+
helpMessage = ""; \
31+
} \
32+
} else if ($$0 ~ /^##/) { \
33+
if (helpMessage) { \
34+
helpMessage = helpMessage"\n "substr($$0, 3); \
35+
} else { \
36+
helpMessage = substr($$0, 3); \
37+
} \
38+
} else { \
39+
if (helpMessage) { \
40+
print "\n "helpMessage"\n" \
41+
} \
42+
helpMessage = ""; \
43+
} \
44+
}' \
45+
$(MAKEFILE_LIST)
46+
47+
## ---------- Development Tasks ----------
48+
49+
#***************************************************************************
50+
# prepare
51+
#***************************************************************************
52+
## Install dependencies
53+
.PHONY: prepare
54+
prepare:
355
go mod tidy
456

5-
test/e2e: install-go-modules
6-
sh ./test/e2e/e2e.sh
57+
#***************************************************************************
58+
# lint
59+
#***************************************************************************
60+
## Lint the code
61+
## Options:
62+
## * [Jenkins] optional. If we are running in Jenkins enviroment. Example: Jenkins=true
63+
.PHONY: lint
64+
lint:
65+
@echo "> Linting helm charts....."
66+
helm lint --with-subcharts charts/ $(if $(Jenkins), > helm-lint-output.txt,)
67+
68+
@echo "> Linting tests....."
69+
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.49.0 golangci-lint run $(if $(Jenkins), > test-lint-output.txt,)
70+
71+
## ---------- Testing Tasks ----------
72+
73+
#***************************************************************************
74+
# e2e-test
75+
#***************************************************************************
76+
## Run all end to end tests
77+
## Options:
78+
## * [dockerImage] optional. default is marklogicdb/marklogic-db:latest. Example: dockerImage=marklogic-centos/marklogic-server-centos:10-internal
79+
.PHONY: e2e-test
80+
e2e-test: prepare
81+
@echo "=====Installing minikube cluster"
82+
minikube start --driver=docker -n=1
83+
84+
@echo "=====Loading marklogc image $(dockerImage) to minikube cluster"
85+
minikube image load $(dockerImage)
86+
87+
@echo "=====Running tests"
88+
go test -v -count=1 ./test/e2e/...
89+
90+
@echo "=====Delete minikube cluster"
91+
minikube delete
792

8-
test/template: install-go-modules
93+
#***************************************************************************
94+
# template-test
95+
#***************************************************************************
96+
## Run all template tests
97+
.PHONY: template-test
98+
template-test: prepare
999
go test -v ./test/template/...
10100

11-
test: test/template test/e2e
101+
#***************************************************************************
102+
# test
103+
#***************************************************************************
104+
## Run all tests
105+
## Options:
106+
## * [dockerImage] optional. default is marklogicdb/marklogic-db:latest. Example: dockerImage=marklogic-centos/marklogic-server-centos:10-internal
107+
.PHONY: test
108+
test: template-test e2e-test

0 commit comments

Comments
 (0)