-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
263 lines (232 loc) · 8.84 KB
/
Makefile
File metadata and controls
263 lines (232 loc) · 8.84 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
# GOSS Makefile
# Provides version management and release automation
.PHONY: help version release snapshot build test itest itest-java clean push-snapshot-local push-release-local \
bump-patch bump-minor bump-major next-snapshot check-api format format-check \
run run-ssl stop status log
# Default target
help:
@echo "GOSS Build and Release Management"
@echo ""
@echo "Usage:"
@echo " make version Show versions of all bundles"
@echo " make release VERSION=x.y.z Create a new release (removes -SNAPSHOT)"
@echo " make snapshot VERSION=x.y.z Set version with -SNAPSHOT suffix"
@echo " make build Build all bundles"
@echo " make test Run tests"
@echo " make clean Clean build artifacts"
@echo " make format Format all Java files using Spotless"
@echo " make format-check Check formatting without making changes"
@echo ""
@echo "Version bumping:"
@echo " make check-api Analyze API changes and suggest version bump type"
@echo " make next-snapshot Bump patch version after release (e.g., 11.0.0 -> 11.0.1-SNAPSHOT)"
@echo " make bump-patch Same as next-snapshot"
@echo " make bump-minor Bump minor version (e.g., 11.0.0 -> 11.1.0-SNAPSHOT)"
@echo " make bump-major Bump major version (e.g., 11.0.0 -> 12.0.0-SNAPSHOT)"
@echo ""
@echo "Repository targets (local ../GOSS-Repository):"
@echo " make push-snapshot-local Push snapshot JARs to ../GOSS-Repository/snapshot/"
@echo " make push-release-local Push release JARs to ../GOSS-Repository/release/"
@echo " Add FORCE=1 to overwrite existing JARs (e.g., make push-release-local FORCE=1)"
@echo ""
@echo "Release workflow:"
@echo " 1. make version # Check current version"
@echo " 2. make release VERSION=11.0.0 # Set release version"
@echo " 3. make build && make test # Build and test"
@echo " 4. make push-release-local # Push to GOSS-Repository"
@echo " 5. git tag v11.0.0 && git push # Tag and push"
@echo " 6. make next-snapshot # Bump to next snapshot"
@echo ""
@echo "Integration testing:"
@echo " make itest Build, start GOSS, run Java + Python integration tests, stop GOSS"
@echo " make itest-java Build, start GOSS, run Java external server tests, stop GOSS"
@echo ""
@echo "Running:"
@echo " make run Build and run GOSS in the background (logs to log/goss.log)"
@echo " make run-ssl Build and run GOSS with SSL in the background"
@echo " make stop Stop the background GOSS process"
@echo " make status Check if GOSS is running"
@echo " make log Tail the GOSS log file"
@echo ""
@echo "Examples:"
@echo " make version"
@echo " make release VERSION=11.0.0"
@echo " make snapshot VERSION=11.1.0"
@echo " make build && make push-snapshot-local"
# Show all bundle versions
version:
@python3 scripts/version.py show
# Create a release (remove -SNAPSHOT suffix)
release:
ifndef VERSION
$(error VERSION is required. Usage: make release VERSION=x.y.z)
endif
@python3 scripts/version.py release $(VERSION)
# Set snapshot version
snapshot:
ifndef VERSION
$(error VERSION is required. Usage: make snapshot VERSION=x.y.z)
endif
@python3 scripts/version.py snapshot $(VERSION)
# Build all bundles (compile + package, no tests)
build:
./gradlew assemble
# Run tests (excludes OSGi integration tests which require a running framework; use 'make itest' for those)
test:
./gradlew test --continue
# Clean build artifacts
clean:
./gradlew clean
# Push snapshot JARs to local GOSS-Repository
push-snapshot-local:
@python3 push-to-local-goss-repository.py --snapshot $(if $(FORCE),--force,)
# Push release JARs to local GOSS-Repository (also releases to cnf/releaserepo)
push-release-local:
./gradlew release
@python3 push-to-local-goss-repository.py --release $(if $(FORCE),--force,)
# Version bumping commands
bump-patch:
@python3 scripts/version.py bump-patch
bump-minor:
@python3 scripts/version.py bump-minor
bump-major:
@python3 scripts/version.py bump-major
next-snapshot:
@python3 scripts/version.py next-snapshot
# API change detection
check-api:
@python3 scripts/check-api.py
# Code formatting targets (uses Spotless with Eclipse formatter)
format:
@echo "Formatting Java files..."
./gradlew spotlessApply
@echo "Formatting complete."
format-check:
@echo "Checking code formatting..."
./gradlew spotlessCheck
@echo "Format check complete."
# --- Integration test targets ---
ITESTS_DIR = pnnl.goss.core.itests
STOMP_PORT = 61618
GOSS_READY_TIMEOUT = 30
# Helper: start GOSS and wait for STOMP port
define start-goss
@mkdir -p $(LOG_DIR)
@if [ -f $(PID_FILE) ] && kill -0 $$(cat $(PID_FILE)) 2>/dev/null; then \
echo "Stopping existing GOSS (PID $$(cat $(PID_FILE)))..."; \
kill $$(cat $(PID_FILE)); \
rm -f $(PID_FILE); \
sleep 2; \
fi
@if [ -d $(DATA_DIR) ]; then \
echo "Cleaning stale KahaDB data..."; \
rm -rf $(DATA_DIR); \
fi
@echo "Starting GOSS for integration tests (logging to $(LOG_FILE))..."
@nohup java -jar $(SIMPLE_JAR) >> $(LOG_FILE) 2>&1 & echo $$! > $(PID_FILE)
@echo "Waiting for GOSS STOMP port $(STOMP_PORT)..."
@elapsed=0; \
while ! ss -tln 2>/dev/null | grep -q ":$(STOMP_PORT) " && [ $$elapsed -lt $(GOSS_READY_TIMEOUT) ]; do \
sleep 1; \
elapsed=$$((elapsed + 1)); \
printf "."; \
done; \
echo ""; \
if ! ss -tln 2>/dev/null | grep -q ":$(STOMP_PORT) "; then \
echo "ERROR: GOSS did not start within $(GOSS_READY_TIMEOUT)s"; \
echo "Last log lines:"; \
tail -20 $(LOG_FILE); \
kill $$(cat $(PID_FILE)) 2>/dev/null; rm -f $(PID_FILE); \
exit 1; \
fi
@echo "GOSS is ready (PID $$(cat $(PID_FILE)))"
endef
# Build GOSS, start it, run Java external server tests, then stop GOSS
itest-java: $(SIMPLE_JAR)
$(start-goss)
@echo ""
@echo "Running Java external server tests..."
@./gradlew :pnnl.goss.core.itests:testExternal --no-daemon; rc=$$?; \
echo ""; \
echo "Stopping GOSS..."; \
kill $$(cat $(PID_FILE)) 2>/dev/null; rm -f $(PID_FILE); \
exit $$rc
# Build GOSS, start it, run Java + Python integration tests, then stop GOSS
itest: $(SIMPLE_JAR)
$(start-goss)
@echo ""
@echo "Running Java external server tests..."
@./gradlew :pnnl.goss.core.itests:testExternal --no-daemon; java_rc=$$?; \
echo ""; \
echo "Running Python STOMP integration tests..."; \
cd $(ITESTS_DIR) && pixi run test-stomp-token; py_stomp_rc=$$?; cd ..; \
echo ""; \
echo "Running Python STOMP + WebSocket token auth tests..."; \
cd $(ITESTS_DIR) && pixi run test-token-auth; py_token_rc=$$?; cd ..; \
echo ""; \
echo "Stopping GOSS..."; \
kill $$(cat $(PID_FILE)) 2>/dev/null; rm -f $(PID_FILE); \
if [ $$java_rc -ne 0 ]; then exit $$java_rc; fi; \
if [ $$py_stomp_rc -ne 0 ]; then exit $$py_stomp_rc; fi; \
exit $$py_token_rc
# --- Runtime targets ---
RUNNER_DIR = pnnl.goss.core.runner
SIMPLE_JAR = $(RUNNER_DIR)/generated/executable/goss-simple-runner.jar
SSL_JAR = $(RUNNER_DIR)/generated/executable/goss-ssl-runner.jar
LOG_DIR = log
LOG_FILE = $(LOG_DIR)/goss.log
PID_FILE = $(LOG_DIR)/goss.pid
DATA_DIR = data/goss-broker
# Build (if needed) and run GOSS in the background
run: $(SIMPLE_JAR)
@mkdir -p $(LOG_DIR)
@if [ -f $(PID_FILE) ] && kill -0 $$(cat $(PID_FILE)) 2>/dev/null; then \
echo "GOSS is already running (PID $$(cat $(PID_FILE))). Use 'make stop' first."; \
exit 1; \
fi
@rm -f $(DATA_DIR)/KahaDB/lock
@echo "Starting GOSS (logging to $(LOG_FILE))..."
@nohup java -jar $(SIMPLE_JAR) >> $(LOG_FILE) 2>&1 & echo $$! > $(PID_FILE)
@echo "GOSS started (PID $$(cat $(PID_FILE)))"
# Build (if needed) and run GOSS with SSL in the background
run-ssl: $(SSL_JAR)
@mkdir -p $(LOG_DIR)
@if [ -f $(PID_FILE) ] && kill -0 $$(cat $(PID_FILE)) 2>/dev/null; then \
echo "GOSS is already running (PID $$(cat $(PID_FILE))). Use 'make stop' first."; \
exit 1; \
fi
@rm -f $(DATA_DIR)/KahaDB/lock
@echo "Starting GOSS with SSL (logging to $(LOG_FILE))..."
@nohup java -jar $(SSL_JAR) >> $(LOG_FILE) 2>&1 & echo $$! > $(PID_FILE)
@echo "GOSS started with SSL (PID $$(cat $(PID_FILE)))"
# Build the runner JARs if they don't exist
$(SIMPLE_JAR):
./gradlew :pnnl.goss.core.runner:createSimpleRunner
$(SSL_JAR):
./gradlew :pnnl.goss.core.runner:createSSLRunner
# Stop the background GOSS process
stop:
@if [ -f $(PID_FILE) ] && kill -0 $$(cat $(PID_FILE)) 2>/dev/null; then \
echo "Stopping GOSS (PID $$(cat $(PID_FILE)))..."; \
kill $$(cat $(PID_FILE)); \
rm -f $(PID_FILE); \
echo "GOSS stopped."; \
else \
echo "GOSS is not running."; \
rm -f $(PID_FILE); \
fi
# Check if GOSS is running
status:
@if [ -f $(PID_FILE) ] && kill -0 $$(cat $(PID_FILE)) 2>/dev/null; then \
echo "GOSS is running (PID $$(cat $(PID_FILE)))"; \
else \
echo "GOSS is not running."; \
rm -f $(PID_FILE); \
fi
# Tail the GOSS log
log:
@if [ -f $(LOG_FILE) ]; then \
tail -f $(LOG_FILE); \
else \
echo "No log file found at $(LOG_FILE)"; \
fi