forked from gsantner/markor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
360 lines (305 loc) · 14.6 KB
/
Makefile
File metadata and controls
360 lines (305 loc) · 14.6 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# SPDX-FileCopyrightText: 2017-2025 Gregor Santner <gsantner AT mailbox DOT org>
# SPDX-FileCopyrightText: 2025-2026 Milos Vasic
# SPDX-License-Identifier: CC0-1.0
#
# Yole - Cross-platform text editor
# Build automation for Android, Desktop, Web, and container-based workflows
#
# Usage:
# make help - Show all available targets
# make build - Build Android APK (requires ANDROID_SDK_ROOT)
# make desktop - Run desktop application
# make web - Run web application in browser
# make test-shared - Run shared module tests (desktop JVM)
# make container-test - Run all tests inside a container
#
.PHONY: $(shell sed -n -e '/^$$/ { n ; /^[^ .\#][^ ]*:/ { s/:.*$$// ; p ; } ; }' $(MAKEFILE_LIST))
.NOTPARALLEL: clean
.DEFAULT_GOAL := help
####################################################################################
# Configuration
####################################################################################
DIST_DIR = dist
FLAVOR := $(or ${FLAVOR},${FLAVOR},Atest)
ANDROID_BUILD_TOOLS := $(shell test -n "$$ANDROID_SDK_ROOT" && find "$${ANDROID_SDK_ROOT}/build-tools" -iname "aapt" 2>/dev/null | sort -r | head -n1 | xargs dirname 2>/dev/null)
TOOL_SPELLCHECKING_ISPELL := $(shell command -v ispell 2> /dev/null)
# Container runtime: prefer podman, fall back to docker
CONTAINER_RUNTIME := $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null)
COMPOSE_CMD := $(shell command -v podman-compose 2>/dev/null || echo "$(CONTAINER_RUNTIME) compose")
####################################################################################
# Help
####################################################################################
# Show all available targets with descriptions
help:
@echo "Yole Build System"
@echo "================="
@echo ""
@echo "Cross-Platform Targets:"
@echo " make build Build Android APK (requires ANDROID_SDK_ROOT)"
@echo " make desktop Run desktop (JVM) application"
@echo " make web Run web (Wasm) application in browser"
@echo ""
@echo "Testing Targets:"
@echo " make test-shared Run shared module tests (desktop JVM, no Android SDK needed)"
@echo " make test-android Run Android unit tests (requires ANDROID_SDK_ROOT)"
@echo " make test Legacy: Run Android flavor tests (requires ANDROID_SDK_ROOT)"
@echo " make test-all Run all tests across all modules"
@echo " make coverage Run tests with Kover HTML coverage report"
@echo " make test-coverage Alias for coverage"
@echo ""
@echo "Container Targets (recommended for CI):"
@echo " make container-build Build the container image"
@echo " make container-test Run all tests inside a container"
@echo " make container-release Build release artifacts inside a container"
@echo " make container-shell Open an interactive shell in the build container"
@echo ""
@echo "Security Targets:"
@echo " make security Start SonarQube for code quality analysis"
@echo " make security-full Start full security stack (SonarQube + Snyk + Detekt)"
@echo " make security-scan Run Detekt static analysis"
@echo " make detekt Alias for security-scan"
@echo " make security-stop Stop all security services"
@echo ""
@echo "Code Quality Targets:"
@echo " make lint Run Android lint (requires ANDROID_SDK_ROOT)"
@echo " make spellcheck Spellcheck strings.xml with ispell"
@echo " make docs Generate Dokka HTML API documentation"
@echo " make dokka Alias for docs"
@echo ""
@echo "Android Device Targets (require ANDROID_SDK_ROOT):"
@echo " make install Install APK on connected device"
@echo " make run Launch app on connected device"
@echo ""
@echo "Submodule Targets:"
@echo " make challenge Run Challenges test suite (Go)"
@echo " make helixqa Run HelixQA orchestrated QA (all platforms)"
@echo " make helixqa-test Run HelixQA unit/integration tests"
@echo " make qa-all Run all QA: shared + challenges + HelixQA"
@echo ""
@echo "Utility Targets:"
@echo " make clean Clean build artifacts and caches"
@echo " make clean-deep Deep clean including Gradle caches"
@echo " make submodules Initialize and update git submodules"
@echo ""
@echo "Environment Variables:"
@echo " ANDROID_SDK_ROOT Path to Android SDK (required for Android targets)"
@echo " FLAVOR Build flavor (default: Atest)"
@echo ""
####################################################################################
# Internal helpers
####################################################################################
env-%:
@: $(if ${${*}},,$(error Environment variable $* not set))
$(DIST_DIR):
mkdir -p ${DIST_DIR}
.NOTPARALLEL: gradle gradle-analyze-log
# Run a Gradle command with logging (requires ANDROID_SDK_ROOT)
gradle: env-ANDROID_SDK_ROOT
mkdir -p $(DIST_DIR)/log/
chmod +x gradlew
./gradlew --no-daemon --parallel --stacktrace $A 2>&1 | tee "$(DIST_DIR)/log/gradle.log"
@echo "-----------------------------------------------------------------------------------"
# Run a Gradle command without requiring ANDROID_SDK_ROOT
gradle-no-sdk:
mkdir -p $(DIST_DIR)/log/
chmod +x gradlew
./gradlew --no-daemon --parallel --stacktrace $A 2>&1 | tee "$(DIST_DIR)/log/gradle.log"
@echo "-----------------------------------------------------------------------------------"
# Verify the last Gradle run was successful
gradle-analyze-log:
mv "$(DIST_DIR)/log/gradle.log" "$(DIST_DIR)/log/gradle$A.log"
cat "$(DIST_DIR)/log/gradle$A.log" | grep "BUILD " | tail -n1 | grep -q "BUILD SUCCESSFUL in"
# Run adb command (requires ANDROID_SDK_ROOT)
adb: env-ANDROID_SDK_ROOT
"${ANDROID_SDK_ROOT}/platform-tools/adb" $A 2>&1 | tee "$(DIST_DIR)/log/adb-$L.log"
# Run aapt command (requires ANDROID_SDK_ROOT)
aapt: env-ANDROID_SDK_ROOT
"${ANDROID_BUILD_TOOLS}/aapt" $A 2>&1 | grep -v 'application-label-' | tee "$(DIST_DIR)/log/aapt$L.log"
####################################################################################
# Cross-Platform Targets
####################################################################################
# Build Android debug APK
build: $(DIST_DIR)
rm -f $(DIST_DIR)/*.apk
$(MAKE) A="clean :androidApp:assembleDebug -x lint" gradle
find androidApp -type f -newermt '-300 seconds' -iname '*.apk' -not -iname '*unsigned.apk' | xargs cp -R -t $(DIST_DIR)/ 2>/dev/null || true
@echo "Build artifacts in $(DIST_DIR)/"
@echo "-----------------------------------------------------------------------------------"
# Run the desktop (JVM) application
desktop:
chmod +x gradlew
./gradlew --no-daemon :desktopApp:run
# Run the web (Wasm) application in the browser
web:
chmod +x gradlew
./gradlew --no-daemon :webApp:wasmJsBrowserRun
####################################################################################
# Testing Targets
####################################################################################
# Run shared module tests on desktop JVM (does not require Android SDK)
test-shared:
chmod +x gradlew
./gradlew --no-daemon :shared:desktopTest
@echo "-----------------------------------------------------------------------------------"
# Run Android unit tests (requires ANDROID_SDK_ROOT)
test-android:
$(MAKE) A=":androidApp:testDebugUnitTest -x lint" gradle
@echo "-----------------------------------------------------------------------------------"
# Run all tests (requires ANDROID_SDK_ROOT) - legacy Android flavor tests
test: $(DIST_DIR)
rm -Rf $(DIST_DIR)/tests
$(MAKE) A="test -x lint" gradle
@echo "-----------------------------------------------------------------------------------"
# Run all tests across all modules
test-all:
chmod +x gradlew
./gradlew --no-daemon test
@echo "-----------------------------------------------------------------------------------"
# Run tests with Kover HTML coverage report
coverage:
chmod +x gradlew
./gradlew --no-daemon test koverHtmlReport
@echo "Coverage report: shared/build/reports/kover/html/index.html"
@echo "-----------------------------------------------------------------------------------"
# Alias: test-coverage -> coverage
test-coverage: coverage
####################################################################################
# Container Targets
####################################################################################
# Build the container image for the build environment
container-build:
$(COMPOSE_CMD) build build
# Run all tests inside a container (consistent environment)
container-test:
$(COMPOSE_CMD) run --rm build ./docker/scripts/test-all.sh
# Build release artifacts inside a container
container-release:
$(COMPOSE_CMD) run --rm build ./docker/scripts/build.sh
# Open an interactive shell in the build container
container-shell:
$(COMPOSE_CMD) run --rm build bash
####################################################################################
# Security Targets
####################################################################################
# Start SonarQube for code quality analysis (http://localhost:9000)
security:
$(COMPOSE_CMD) --profile security up -d sonarqube
@echo "SonarQube starting at http://localhost:9000 (default: admin/admin)"
# Start full security stack (SonarQube + Snyk + Detekt)
security-full:
$(COMPOSE_CMD) --profile full up -d
@echo "Full security stack started"
# Run Detekt static analysis
security-scan:
chmod +x gradlew
./gradlew --no-daemon detekt
@echo "-----------------------------------------------------------------------------------"
# Alias: detekt -> security-scan
detekt: security-scan
# Stop all security services
security-stop:
$(COMPOSE_CMD) --profile full down
####################################################################################
# Code Quality Targets
####################################################################################
# Run Android lint checks (requires ANDROID_SDK_ROOT)
lint: $(DIST_DIR)
rm -Rf $(DIST_DIR)/lint
mkdir -p $(DIST_DIR)/lint/
$(MAKE) A="lintFlavorDefaultDebug" gradle
find androidApp -type f -iname 'lint-results-*' | grep -v 'intermediates' | xargs cp -R -t $(DIST_DIR)/lint 2>/dev/null || true
@echo "-----------------------------------------------------------------------------------"
# Spellcheck strings.xml using ispell
spellcheck: $(DIST_DIR)
mkdir -p "$(DIST_DIR)/lint/"
ifndef TOOL_SPELLCHECKING_ISPELL
@echo "Tool ispell (spellcheck) not found in PATH. Spellcheck skipped." > "$(DIST_DIR)/lint/stringsxml-spellcheck.txt"
else
@echo "Use ispell for spellchecking the original values/strings.xml"
find . -iname "strings.xml" -path "*/main*/values/*" | head -n1 | xargs cat \
| grep "<string name=" | sed 's@.*">@@' | sed 's@</string>@@' | sed 's@\\n@ @g' | sed 's@\\@@g' \
| ispell -W3 -a | grep ^\& | sed 's@[0-9]@@g' | sort | uniq | cut -d, -f1-4 \
| sed 's@^..@- @' | column -t -s: \
> "$(DIST_DIR)/lint/stringsxml-spellcheck.txt"
@echo "\nPotential words with bad spelling:"
endif
@cat "$(DIST_DIR)/lint/stringsxml-spellcheck.txt"
@echo "-----------------------------------------------------------------------------------"
# Generate API documentation with Dokka
docs:
chmod +x gradlew
./gradlew --no-daemon :shared:dokkaHtml
@echo "API docs: shared/build/dokka/html/index.html"
@echo "-----------------------------------------------------------------------------------"
# Alias: dokka -> docs
dokka: docs
####################################################################################
# Android Device Targets
####################################################################################
# Install APK on connected device via adb
install:
$(MAKE) A="install -r $(DIST_DIR)/*.apk" L="install" adb
# Launch app on connected device via adb
run:
$(MAKE) A="shell monkey -p $$(aapt dump badging $(DIST_DIR)/*.apk | grep package: | sed 's@.* name=@@' | sed 's@ .*@@' | xargs | head -n1) -c android.intent.category.LAUNCHER 1" L="run" adb
####################################################################################
# Submodule Targets
####################################################################################
# Run Challenges test suite (Go-based cross-platform challenges)
challenge:
cd Challenges && go test ./... -race -count=1
@echo "-----------------------------------------------------------------------------------"
# Run HelixQA orchestrated QA (main QA brain)
helixqa:
cd HelixQA && go run ./cmd/helixqa/ run \
--banks ../Challenges/banks/yole/,../HelixQA/banks/ \
--platform all \
--device emulator-5554 \
--package digital.vasic.yole.android \
--browser-url http://localhost:8080 \
--desktop-process java \
--output ../qa-results \
--report markdown \
--validate \
--record \
--tickets \
--verbose \
--timeout 45m
@echo "-----------------------------------------------------------------------------------"
# Run HelixQA unit tests
helixqa-test:
cd HelixQA && go test ./... -race -count=1
@echo "-----------------------------------------------------------------------------------"
# Validate evidence from automation runs via HelixQA
helixqa-validate:
bash automation/helixqa-validate.sh --platform all
@echo "-----------------------------------------------------------------------------------"
# Run full QA pipeline: unit tests + Go tests + automation + evidence validation
qa-all: test-shared challenge helixqa-test
bash automation/run-qa-all.sh --skip-unit --skip-build
@echo "-----------------------------------------------------------------------------------"
# Run full QA pipeline including builds
qa-full:
bash automation/run-qa-all.sh
@echo "-----------------------------------------------------------------------------------"
####################################################################################
# Utility Targets
####################################################################################
# Clean build artifacts
clean:
chmod +x gradlew
./gradlew --no-daemon clean 2>/dev/null || true
rm -Rf $(DIST_DIR) app/build androidApp/build shared/build desktopApp/build webApp/build .idea dist
find . -type f -iname "*.iml" -delete
mkdir -p $(DIST_DIR)
@echo "-----------------------------------------------------------------------------------"
# Deep clean including Gradle caches
clean-deep: clean
rm -Rf .gradle build
@echo "Deep clean complete (Gradle caches removed)"
@echo "-----------------------------------------------------------------------------------"
# Initialize and update git submodules
submodules:
git submodule update --init --recursive
@echo "Submodules initialized"
@echo "-----------------------------------------------------------------------------------"