Skip to content

Commit ccd0ea0

Browse files
committed
Added some more comments and fixed formatting
Signed-off-by: Robert Seedorff <Robert.Seedorff@iteratec.com>
1 parent 5375eeb commit ccd0ea0

4 files changed

Lines changed: 33 additions & 17 deletions

File tree

Makefile

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
PROJECT_DIR = $(shell pwd)
6-
BIN_DIR = $(PROJECT_DIR)/bin
6+
BIN_DIR = $(PROJECT_DIR)/bin
77
SCANNERS_DIR = $(PROJECT_DIR)/scanners
8-
HOOKS_DIR = $(PROJECT_DIR)/hooks
9-
DEMO_TARGETS_DIR = $(PROJECT_DIR)/demo-targets
8+
HOOKS_DIR = $(PROJECT_DIR)/hooks
9+
DEMO_TARGETS_DIR = $(PROJECT_DIR)/demo-targets
1010
OPERATOR_DIR = $(PROJECT_DIR)/operator
11-
AUTO_DISCOVERY_DIR = $(PROJECT_DIR)/auto-discovery
11+
PARSER_SDK_DIR = $(PROJECT_DIR)/parser-sdk/nodejs
12+
HOOK_SDK_DIR = $(PROJECT_DIR)/hook-sdk/nodejs
13+
AUTO_DISCOVERY_DIR = $(PROJECT_DIR)/auto-discovery
1214
HELM_DOCS_DIR = $(PROJECT_DIR)/.helm-docs
1315
TEMPLATES_DIR = $(PROJECT_DIR)/.templates
1416

1517
SCANNERS_CHART_LIST := $(sort $(wildcard $(SCANNERS_DIR)/*/Chart.yaml))
1618
SCANNERS_TEST_LIST := $(sort $(wildcard $(SCANNERS_DIR)/*/Makefile))
17-
HOOKS_CHART_LIST := $(sort $(wildcard $(HOOKS_DIR)/*/Chart.yaml))
18-
HOOKS_TEST_LIST := $(sort $(wildcard $(HOOKS_DIR)/*/Makefile))
19-
DEMO_TARGETS_CHART_LIST := $(sort $(wildcard $(DEMO_TARGETS_DIR)/*/Chart.yaml))
19+
HOOKS_CHART_LIST := $(sort $(wildcard $(HOOKS_DIR)/*/Chart.yaml))
20+
HOOKS_TEST_LIST := $(sort $(wildcard $(HOOKS_DIR)/*/Makefile))
21+
DEMO_TARGETS_CHART_LIST := $(sort $(wildcard $(DEMO_TARGETS_DIR)/*/Chart.yaml))
2022
# This find construct is based on https://stackoverflow.com/questions/4210042/how-to-exclude-a-directory-in-find-command/4210072#4210072
2123
PACKAGE_JSON_LIST := $(shell find $(PROJECT_DIR) \( \
2224
-name .git -o \
@@ -41,26 +43,33 @@ all: help
4143

4244
.PHONY: npm-ci-all
4345
npm-ci-all: ## Runs npm ci in all node module subfolders.
46+
@echo "Installing all NPM dependencies"
4447
@for package in $(PACKAGE_JSON_LIST); do \
45-
cd $$(dirname $${package}) && npm ci; \
48+
echo "🧱 Installing dependencies for $${package}" && cd $$(dirname $${package}) && npm ci; \
4649
done
4750

4851
.PHONY: npm-test-all
4952
npm-test-all: ## Runs all Jest based test suites.
50-
npm test -- --testPathIgnorePatterns /integration-tests/
53+
npm test -- --ci --colors --coverage --testPathIgnorePatterns /integration-tests/
5154

5255
.PHONY: test-all
53-
test-all: install-operator ## Runs all makefile based test suites.
56+
test-all: install-operator install-sdks ## Runs all makefile based test suites (unit + integration Tests).
5457
@echo "Running make test for all scanner and hook modules..."
5558
@for dir in $(SCANNERS_TEST_LIST) $(HOOKS_TEST_LIST); do \
56-
cd $$(dirname $$dir) && $(MAKE) -s test || exit 1; \
59+
echo "🧪 Test Suite for $${dir}" && cd $$(dirname $$dir) && $(MAKE) -s test || exit 1; \
5760
done
5861

5962
.PHONY: install-operator
6063
install-operator: ## Install the operator for makefile based testing.
6164
@echo "Installing the operator for makefile based testing..."
6265
cd $(OPERATOR_DIR) && $(MAKE) -s docker-build docker-export kind-import helm-deploy
6366

67+
.PHONY: install-sdks
68+
install-sdks: ## Install the SDKs for makefile based testing.
69+
@echo "Installing the SDKs (parser, hooks) for makefile based testing..."
70+
cd $(PARSER_SDK_DIR) && $(MAKE) -s docker-build
71+
cd $(HOOK_SDK_DIR) && $(MAKE) -s docker-build
72+
6473
.PHONY: readme
6574
readme: ## Generate README.md based on Chart.yaml and template.
6675
$(BIN_DIR)/generate-helm-docs.sh --readme $(PROJECT_DIR) $(HELM_DOCS_DIR)

common.mk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ parser-prefix = parser
6161
scanner-prefix = scanner
6262
hook-prefix = hook
6363

64-
test: | clean-integration-tests unit-tests docker-build docker-export kind-import deploy deploy-test-deps integration-tests
64+
all: help
65+
66+
test: | clean-integration-tests clean-demo-targets unit-tests docker-build docker-export kind-import deploy deploy-test-deps integration-tests ## 🧪 Complete clean Test for this module.
6567

6668
.PHONY: help unit-tests-hook install-deps docker-build docker-export kind-import deploy deploy-test-deps integration-tests all build test
6769

@@ -167,7 +169,7 @@ deploy-test-dep-test-scan:
167169
deploy-test-dep-old-joomla:
168170
helm -n demo-targets install old-joomla ../../demo-targets/old-joomla/ --set="fullnameOverride=old-joomla" --wait
169171

170-
clean:
172+
clean: ## 🧹 Cleaning up all generated files for this module.
171173
@echo ".: 🧹 Cleaning up all generated files."
172174
rm -f ./$(module)-$(name).tar
173175
rm -rf ./$(module)/node_modules
@@ -186,3 +188,8 @@ clean-demo-targets:
186188
@echo ".: 🧹 Resetting 'demo-targets' namespace"
187189
kubectl delete namespace demo-targets --wait || true
188190
kubectl create namespace demo-targets
191+
192+
.PHONY: help
193+
help: ## 🔮 Display this help screen.
194+
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
195+
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

hooks.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ unit-tests:
4040
@$(MAKE) -s unit-test-js
4141

4242
.PHONY: deploy
43-
deploy:
43+
deploy: ## 💾 Deploy this module via HelmChart into namespace "integration-tests"
4444
@echo ".: 💾 Deploying '$(name)' $(hook-prefix) HelmChart with the docker tag '$(IMG_TAG)' into kind namespace 'integration-tests'."
4545
helm -n integration-tests upgrade --install $(name) . --wait \
4646
--set="hook.image.repository=docker.io/$(IMG_NS)/$(hook-prefix)-$(name)" \
4747
--set="hook.image.tag=$(IMG_TAG)"
4848

4949
.PHONY: integration-tests
50-
integration-tests:
50+
integration-tests: ## 🩺 Start integration test for this module in the namespace "integration-tests"
5151
@echo ".: 🩺 Starting integration test in kind namespace 'integration-tests'."
5252
kubectl -n integration-tests delete scans --all
5353
cd $(hook-prefix) && npm ci && npm run test --package jest@$(JEST_VERSION)

operator/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ helm-deploy:
116116
helm -n securecodebox-system upgrade --install securecodebox-operator ./ --wait \
117117
--set="image.repository=docker.io/$(IMG_NS)/$(OPERATOR_IMG)" \
118118
--set="image.tag=$(IMG_TAG)" \
119-
--set="image.pullPolicy=IfNotPresent" \
119+
--set="image.pullPolicy=IfNotPresent" \
120120
--set="lurker.image.repository=docker.io/$(IMG_NS)/$(LURKER_IMG)" \
121121
--set="lurker.image.tag=$(IMG_TAG)" \
122-
--set="lurker.image.pullPolicy=IfNotPresent"
122+
--set="lurker.image.pullPolicy=IfNotPresent"
123123

124124
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
125125
$(KUSTOMIZE) build config/crd | kubectl apply -f -

0 commit comments

Comments
 (0)