Skip to content

Commit 94d04cc

Browse files
authored
Update run-java.sh
Signed-off-by: SimiHunjan <simi.hunjan.k@gmail.com>
1 parent 3e6d20f commit 94d04cc

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

.github/scripts/run-java.sh

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,40 @@ if [[ -z "${OPERATOR_ID:-}" || -z "${OPERATOR_KEY:-}" ]]; then
77
exit 2
88
fi
99

10-
./gradlew -q run --stacktrace | tee java-output.txt
10+
OUTFILE="java-output.txt"
11+
: > "$OUTFILE" # truncate/create
12+
13+
echo "=== Java Examples Runner ===" | tee -a "$OUTFILE"
14+
echo "Timestamp (UTC): $(date -u +'%Y-%m-%d %H:%M:%SZ')" | tee -a "$OUTFILE"
15+
echo "Network: ${HEDERA_NETWORK:-<unset>}" | tee -a "$OUTFILE"
16+
echo "Mirror: ${MIRROR_NODE_URL:-<unset>}" | tee -a "$OUTFILE"
17+
echo "" | tee -a "$OUTFILE"
18+
19+
# If you pass an example FQN as an argument, run just that one:
20+
# ./.github/scripts/run-java.sh examples.CreateAccountDemo
21+
if [[ $# -gt 0 ]]; then
22+
FQN="$1"
23+
echo "▶️ Running single example: $FQN" | tee -a "$OUTFILE"
24+
set +e
25+
./gradlew -q runExample -PexampleClass="$FQN" --stacktrace --console=plain | tee -a "$OUTFILE"
26+
STATUS=${PIPESTATUS[0]}
27+
set -e
28+
exit $STATUS
29+
fi
30+
31+
# Otherwise run ALL discovered examples
32+
echo "▶️ Running all examples…" | tee -a "$OUTFILE"
33+
set +e
34+
./gradlew -q runAllExamples --stacktrace --console=plain | tee -a "$OUTFILE"
35+
STATUS=${PIPESTATUS[0]}
36+
set -e
37+
38+
if [[ $STATUS -ne 0 ]]; then
39+
echo "" | tee -a "$OUTFILE"
40+
echo "❌ One or more examples failed." | tee -a "$OUTFILE"
41+
else
42+
echo "" | tee -a "$OUTFILE"
43+
echo "✅ All examples passed." | tee -a "$OUTFILE"
44+
fi
45+
46+
exit $STATUS

0 commit comments

Comments
 (0)