-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathMakefile
170 lines (134 loc) · 8.05 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
.PHONY: all run test clean start
VERSION=$(shell jq -r .version developer-portal-ui/package.json)
ARC42_SRC = $(shell find docs/arc42/src)
PLANTUML_SRC = $(shell find docs/arc42/diagrams -type f -name '*.puml')
DEPENDENCIES = jq npm plantuml asciidoctor docker-compose mvn docker
build-services: build-java-services build-ui-services build-arc-42 ## Build all services
## Install section ##
install: ##Install developer tools
ifeq ($(shell uname),Darwin)
make install-for-MacOS
else ifeq ($(shell uname),Linux)
make install-for-Linux
else
@echo "Doesn't support your OS"
endif
# Install developer tools for Linux
install-for-Linux:
sudo apt-get install jq
sudo apt-get install plantuml
sudo apt-get install -y asciidoctor
sudo apt-get install -y jsonlint yamllint libxml2-utils
# Install developer tools for MacOS
install-for-MacOS:
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install | ruby
brew install jq
brew install plantuml
brew install asciidoctor
brew install jsonlint yamllint
# Lint section
lint-all: lint-dockerfiles lint-tpp-ui lint-admin-ui lint-oba-ui lint-developer-portal-ui lint-tpp-rest-server lint-admin-rest-server lint-online-banking lint-docker-compose lint-pmd-cpd-report #lint all services
lint-dockerfiles:
docker run --rm -i hadolint/hadolint < tpp-ui/Dockerfile
docker run --rm -i hadolint/hadolint < admin-ui/Dockerfile
docker run --rm -i hadolint/hadolint < oba-ui/Dockerfile
docker run --rm -i hadolint/hadolint < developer-portal-ui/Dockerfile
docker run --rm -i hadolint/hadolint < tpp-app/tpp-rest-server/Dockerfile
docker run --rm -i hadolint/hadolint < admin-app/admin-rest-server/Dockerfile
docker run --rm -i hadolint/hadolint < online-banking/online-banking-app/Dockerfile
lint-tpp-ui:
find tpp-ui -type f -name "*.json" -not -path "tpp-ui/node_modules/*" -exec jsonlint -q {} \; # lint all json
find tpp-ui -type f \( -name "*.yml" -o -name "*.yaml" \) -exec yamllint -d "{extends: relaxed, rules: {line-length: {max: 160}}}" {} \;
find tpp-ui -type f \( -iname "*.xml" ! -iname pom.xml \) -exec xmllint --noout {} \;
cd tpp-ui && npm ci && npm install
cd tpp-ui && npm run lint
lint-admin-ui:
find admin-ui -type f -name "*.json" -not -path "admin-ui/node_modules/*" -exec jsonlint -q {} \; # lint all json
find admin-ui -type f \( -name "*.yml" -o -name "*.yaml" \) -exec yamllint -d "{extends: relaxed, rules: {line-length: {max: 160}}}" {} \;
find admin-ui -type f \( -iname "*.xml" ! -iname pom.xml \) -exec xmllint --noout {} \;
cd admin-ui && npm ci && npm install
cd admin-ui && npm run lint
lint-oba-ui:
cd oba-ui
find oba-ui -type f -name "*.json" -not -path "oba-ui/node_modules/*" -exec jsonlint -q {} \; # lint all json
find oba-ui -type f \( -name "*.yml" -o -name "*.yaml" \) -exec yamllint -d "{extends: relaxed, rules: {line-length: {max: 160}}}" {} \;
find oba-ui -type f \( -iname "*.xml" ! -iname pom.xml \) -exec xmllint --noout {} \;
cd oba-ui && npm ci && npm install
cd oba-ui && npm run lint
lint-developer-portal-ui:
find developer-portal-ui -type f -name "*.json" -not -path "developer-portal-ui/node_modules/*" -exec jsonlint -q {} \; # lint all json
find developer-portal-ui -type f \( -name "*.yml" -o -name "*.yaml" \) -exec yamllint -d "{extends: relaxed, rules: {line-length: {max: 160}}}" {} \;
find developer-portal-ui -type f \( -iname "*.xml" ! -iname pom.xml \) -exec xmllint --noout {} \;
cd developer-portal-ui && npm ci && npm install
cd developer-portal-ui && npm run lint
lint-tpp-rest-server:
find tpp-app -type f -name "*.json" -exec jsonlint -q {} \; # lint all json
find tpp-app -type f \( -name "*.yml" -o -name "*.yaml" \) -exec yamllint -d "{extends: relaxed, rules: {line-length: {max: 160}}}" {} \;
find tpp-app -type f \( -iname "*.xml" ! -iname pom.xml \) -exec xmllint --noout {} \;
lint-admin-rest-server:
find admin-app -type f -name "*.json" -exec jsonlint -q {} \; # lint all json
find admin-app -type f \( -name "*.yml" -o -name "*.yaml" \) -exec yamllint -d "{extends: relaxed, rules: {line-length: {max: 160}}}" {} \;
find admin-app -type f \( -iname "*.xml" ! -iname pom.xml \) -exec xmllint --noout {} \;
lint-online-banking:
find online-banking -type f -name "*.json" -exec jsonlint -q {} \; # lint all json
find online-banking -type f \( -name "*.yml" -o -name "*.yaml" \) -exec yamllint -d "{extends: relaxed, rules: {line-length: {max: 160}}}" {} \;
find online-banking -type f \( -iname "*.xml" ! -iname pom.xml \) -exec xmllint --noout {} \;
lint-docker-compose:
docker-compose -f docker-compose.yml config -q
mvn -ntp --settings scripts/mvn-release-settings.xml validate
yamllint -d "{extends: relaxed, rules: {line-length: {max: 160}}}" bank-profile/*.yml
lint-pmd-cpd-report:
mvn -ntp --settings scripts/mvn-release-settings.xml -Dmaven.test.skip=true package pmd:pmd pmd:cpd
## Run section ##
run: ## Run services from Docker Hub without building:
docker-compose pull && docker-compose up
start: ## Run everything with docker-compose build dockerimages without building applications
docker-compose -f docker-compose.yml up
all: lint-all build-ui-services build-java-services unit-tests-all-frontend unit-tests-backend ## Run everything with docker-compose after building
docker-compose -f docker-compose.yml up
## Build section ##
build-java-services: ## Build java services
mvn -ntp --settings scripts/mvn-release-settings.xml -DskipTests clean package -Dci.build.number=Build\:${CI_PIPELINE_ID}
build-ui-services: npm-install-tpp-ui npm-install-admin-ui npm-install-oba-ui npm-install-developer-portal-ui ## Build ui services
npm-install-tpp-ui: tpp-ui/package.json tpp-ui/package-lock.json ## Install TPP-UI NPM dependencies
cd tpp-ui && npm ci && npm install && npm run build
npm-install-admin-ui: admin-ui/package.json admin-ui/package-lock.json ## Install Admin-UI NPM dependencies
cd admin-ui && npm ci && npm install && npm run build
npm-install-oba-ui: oba-ui/package.json oba-ui/package-lock.json ## Install OBA-UI NPM dependencies
cd oba-ui && npm ci && npm install && npm run build
npm-install-developer-portal-ui: developer-portal-ui/package.json developer-portal-ui/package-lock.json ## Install DEV-PORTAL-UI NPM dependencies
cd developer-portal-ui && npm ci && npm install && npm run build
## Unit tests section
unit-tests-all-frontend: unit-tests-oba-ui unit-tests-tpp-ui unit-tests-developer-portal-ui
unit-tests-oba-ui:
cd oba-ui && npm ci && npm install && npm run test-ci
unit-tests-tpp-ui:
cd tpp-ui && npm ci && npm install && npm run test-ci
unit-tests-developer-portal-ui:
cd developer-portal-ui && npm ci && npm install && npm run test-ci
unit-tests-admin-ui:
cd admin-ui && npm ci && npm install && npm run test-ci
unit-tests-backend:
mvn -ntp --settings scripts/mvn-release-settings.xml -DskipITs --fail-at-end clean install
## Build arc42
build-arc-42: arc42/images/generated $(ARC42_SRC) docs/arc42/modelbank-arc42.adoc developer-portal-ui/package.json ## Generate arc42 html documentation
cd docs/arc42 && asciidoctor -a acc-version=$(VERSION) modelbank-arc42.adoc
arc42/images/generated: $(PLANTUML_SRC) ## Generate images from .puml files
# Note: Because plantuml doesnt update the images/generated timestamp we need to touch it afterwards
cd docs/arc42 && mkdir -p images/generated && plantuml -o "../images/generated" diagrams/*.puml && touch images/generated
## Clean section ##
clean: clean-java-services clean-ui-services ## Clean everything
clean-java-services: ## Clean services temp files
mvn clean
clean-ui-services: ## Clean UI temp files
cd tpp-ui && rm -rf dist
cd admin-ui && rm -rf dist
cd oba-ui && rm -rf dist
cd developer-portal-ui && rm -rf dist
## Check section ##
check: ## Check required dependencies ("@:" hides nothing to be done for...)
@: $(foreach exec,$(DEPENDENCIES),\
$(if $(shell command -v $(exec) 2> /dev/null ),$(info (OK) $(exec) is installed),$(info (FAIL) $(exec) is missing)))
## Help section ##
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_\-\/\. ]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)