Skip to content

Commit 41e1866

Browse files
authored
Merge pull request #1102 from secureCodeBox/maintenance/improve-makefile-local-workflow
Improved the local makefile workflow
2 parents c7355a2 + 48388f0 commit 41e1866

6 files changed

Lines changed: 71 additions & 43 deletions

File tree

‎Makefile‎

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,7 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
PROJECT_DIR = $(shell pwd)
6-
BIN_DIR = $(PROJECT_DIR)/bin
7-
SCANNERS_DIR = $(PROJECT_DIR)/scanners
8-
HOOKS_DIR = $(PROJECT_DIR)/hooks
9-
DEMO_TARGETS_DIR = $(PROJECT_DIR)/demo-targets
10-
OPERATOR_DIR = $(PROJECT_DIR)/operator
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
14-
HELM_DOCS_DIR = $(PROJECT_DIR)/.helm-docs
15-
TEMPLATES_DIR = $(PROJECT_DIR)/.templates
16-
17-
SCANNERS_CHART_LIST := $(sort $(wildcard $(SCANNERS_DIR)/*/Chart.yaml))
18-
SCANNERS_TEST_LIST := $(sort $(wildcard $(SCANNERS_DIR)/*/Makefile))
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))
22-
# This find construct is based on https://stackoverflow.com/questions/4210042/how-to-exclude-a-directory-in-find-command/4210072#4210072
23-
PACKAGE_JSON_LIST := $(shell find $(PROJECT_DIR) \( \
24-
-name .git -o \
25-
-name .github -o \
26-
-name .idea -o \
27-
-name .reuse -o \
28-
-name .vagrant -o \
29-
-name .vscode -o \
30-
-name bin -o \
31-
-name docs -o \
32-
-name LICENSES -o \
33-
-name coverage -o \
34-
-name dist -o \
35-
-name node_modules -o \
36-
-name target \) \
37-
-prune \
38-
-false \
39-
-o -type f \
40-
-iname package.json)
5+
include ./env-paths.mk
416

427
all: help
438

@@ -122,4 +87,9 @@ endif
12287
.PHONY: help
12388
help: ## Display this help screen.
12489
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
125-
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
90+
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
91+
92+
test-scanner:
93+
make test -C $(SCANNERS_DIR)/$(target)
94+
test-hook:
95+
make test -C $(HOOKS_DIR)/$(target)

‎common.mk‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ hook-prefix = hook
6767

6868
all: help
6969

70-
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.
71-
70+
test: | reset-integration-tests-namespace reset-demo-targets-namespace clean-operator clean-parser-sdk clean-hook-sdk unit-tests docker-build docker-export kind-import deploy deploy-test-deps integration-tests ## 🧪 Complete clean Test for this module.
7271
.PHONY: help unit-tests-hook install-deps docker-build docker-export kind-import deploy deploy-test-deps integration-tests all build test
7372

7473
install-deps-js:
@@ -173,8 +172,8 @@ deploy-test-dep-test-scan:
173172
deploy-test-dep-old-joomla:
174173
helm -n demo-targets install old-joomla ../../demo-targets/old-joomla/ --set="fullnameOverride=old-joomla" --wait
175174

176-
clean: ## 🧹 Cleaning up all generated files for this module.
177-
@echo ".: 🧹 Cleaning up all generated files."
175+
reset: ## 🧹 removing all generated files for this module.
176+
@echo ".: 🧹 removing all generated files."
178177
rm -f ./$(module)-$(name).tar
179178
rm -rf ./$(module)/node_modules
180179
rm -rf ./$(module)/coverage
@@ -183,16 +182,29 @@ clean: ## 🧹 Cleaning up all generated files for this module.
183182
rm -rf ../node_modules
184183
rm -rf ../coverage
185184

186-
clean-integration-tests:
185+
reset-integration-tests-namespace:
187186
@echo ".: 🧹 Resetting 'integration-tests' namespace"
188187
kubectl delete namespace integration-tests --wait || true
189188
kubectl create namespace integration-tests
190189

191-
clean-demo-targets:
190+
reset-demo-targets-namespace:
192191
@echo ".: 🧹 Resetting 'demo-targets' namespace"
193192
kubectl delete namespace demo-targets --wait || true
194193
kubectl create namespace demo-targets
195194

195+
clean-operator:
196+
make -C $(OPERATOR_DIR) docker-build
197+
make -C $(OPERATOR_DIR) docker-export
198+
make -C $(OPERATOR_DIR) kind-import
199+
rm $(OPERATOR_DIR)/operator.tar $(OPERATOR_DIR)/lurker.tar
200+
make -C $(OPERATOR_DIR) helm-deploy
201+
202+
clean-parser-sdk:
203+
make -C $(PARSER_SDK_DIR) docker-build-sdk
204+
205+
clean-hook-sdk:
206+
make -C $(HOOK_SDK_DIR) docker-build-sdk
207+
196208
.PHONY: help
197209
help: ## 🔮 Display this help screen.
198210
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \

‎env-paths.mk‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-FileCopyrightText: the secureCodeBox authors
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
PROJECT_DIR = $(shell pwd)
6+
BIN_DIR = $(PROJECT_DIR)/bin
7+
SCANNERS_DIR = $(PROJECT_DIR)/scanners
8+
HOOKS_DIR = $(PROJECT_DIR)/hooks
9+
DEMO_TARGETS_DIR = $(PROJECT_DIR)/demo-targets
10+
OPERATOR_DIR = $(PROJECT_DIR)/operator
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
14+
HELM_DOCS_DIR = $(PROJECT_DIR)/.helm-docs
15+
TEMPLATES_DIR = $(PROJECT_DIR)/.templates
16+
17+
SCANNERS_CHART_LIST := $(sort $(wildcard $(SCANNERS_DIR)/*/Chart.yaml))
18+
SCANNERS_TEST_LIST := $(sort $(wildcard $(SCANNERS_DIR)/*/Makefile))
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))
22+
# This find construct is based on https://stackoverflow.com/questions/4210042/how-to-exclude-a-directory-in-find-command/4210072#4210072
23+
PACKAGE_JSON_LIST := $(shell find $(PROJECT_DIR) \( \
24+
-name .git -o \
25+
-name .github -o \
26+
-name .idea -o \
27+
-name .reuse -o \
28+
-name .vagrant -o \
29+
-name .vscode -o \
30+
-name bin -o \
31+
-name docs -o \
32+
-name LICENSES -o \
33+
-name coverage -o \
34+
-name dist -o \
35+
-name node_modules -o \
36+
-name target \) \
37+
-prune \
38+
-false \
39+
-o -type f \
40+
-iname package.json)

‎hooks.mk‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ prefix = hook
2323
name = ${hook}
2424

2525
include ../../common.mk
26+
include ../../env-paths.mk
27+
PROJECT_DIR = ../../ ## Telling the env-paths file where the root project dir is. This is done to allow to generate the relative
2628

2729
module = $(hook-prefix)
2830

‎scanners.mk‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
name = ${scanner}
2222

2323
include ../../common.mk
24+
include ../../env-paths.mk
25+
PROJECT_DIR = ../../ ## Telling the env-paths file where the root project dir is. This is done to allow to generate the relative
2426

2527
module = $(scanner-prefix)
2628

‎sdk.mk‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
name = ${sdk}
2323
module = ${sdk}
2424
include ../../common.mk
25+
include ../../env-paths.mk
26+
PROJECT_DIR = ../../ ## Telling the env-paths file where the root project dir is. This is done to allow to generate the relative
2527

2628
docker-build: | docker-build-sdk
2729
docker-export: | docker-export-sdk

0 commit comments

Comments
 (0)