Skip to content

Commit 328841d

Browse files
committed
extended logging in unittests for more overview
1 parent 0d04d47 commit 328841d

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

.github/actions/unittest-on-build/action.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,42 @@ runs:
5555
5656
# Set the timezone to Germany (Central European Time)
5757
export TZ=Europe/Berlin
58+
59+
# Source color functions
60+
source ./includes/colors.sh
61+
62+
# Track last log position to avoid duplicate output
63+
LAST_LOG_LINES=0
5864
5965
while ! docker logs palworld-dedicated-server 2>&1 | grep -q "Setting breakpad minidump AppID"; do
6066
CURRENT_TIME=$(date +%s)
6167
ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
6268
6369
if [ $ELAPSED_TIME -gt $TIMEOUT_SECONDS ]; then
6470
echo "Timeout reached. Server failed to start within $TIMEOUT_SECONDS seconds."
65-
printf "\e[0;32m%s\e[0m\n" "*****Container LOGS*****"
71+
es "*****Final Container LOGS*****"
6672
docker logs palworld-dedicated-server
6773
exit 1
6874
fi
6975
70-
echo "$(date '+%H:%M:%S') - Waiting for server to start..."
76+
# Show current status with warning color
77+
ew ">>> $(date '+%H:%M:%S') - Waiting for server to start... (${ELAPSED_TIME}s elapsed)"
78+
# Get current log lines count and show new logs if any
79+
CURRENT_LOG_LINES=$(docker logs palworld-dedicated-server 2>&1 | wc -l)
80+
if [ $CURRENT_LOG_LINES -gt $LAST_LOG_LINES ]; then
81+
es ">>> Recent container logs"
82+
es "╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮"
83+
docker logs palworld-dedicated-server 2>&1 | tail -n +$((LAST_LOG_LINES + 1)) | head -n $((CURRENT_LOG_LINES - LAST_LOG_LINES))
84+
es "╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯"
85+
LAST_LOG_LINES=$CURRENT_LOG_LINES
86+
fi
87+
88+
echo "---"
7189
sleep 5
7290
done
73-
echo "Server successfully started"
74-
printf "\e[0;32m%s\e[0m\n" "*****Container LOGS*****"
91+
92+
echo "Server successfully started in $ELAPSED_TIME seconds"
93+
es "*****Final Container LOGS*****"
7594
docker logs palworld-dedicated-server
7695
7796

.github/workflows/unittest-on-pr.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,43 @@ jobs:
6464
# Set the timezone to Germany (Central European Time)
6565
export TZ=Europe/Berlin
6666
67+
# Source color functions
68+
source ./includes/colors.sh
69+
70+
# Track last log position to avoid duplicate output
71+
LAST_LOG_LINES=0
72+
6773
while ! docker logs palworld-dedicated-server 2>&1 | grep -q "Setting breakpad minidump AppID"; do
6874
CURRENT_TIME=$(date +%s)
6975
ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
7076
7177
if [ $ELAPSED_TIME -gt $TIMEOUT_SECONDS ]; then
7278
echo "Timeout reached. Server failed to start within $TIMEOUT_SECONDS seconds."
73-
printf "\e[0;32m%s\e[0m\n" "*****Container LOGS*****"
79+
es "*****Final Container LOGS*****"
7480
docker logs palworld-dedicated-server
7581
exit 1
7682
fi
7783
78-
echo "$(date '+%H:%M:%S') - Waiting for server to start..."
84+
# Show current status with warning color
85+
ew ">>> $(date '+%H:%M:%S') - Waiting for server to start... (${ELAPSED_TIME}s elapsed)"
86+
# Get current log lines count and show new logs if any
87+
CURRENT_LOG_LINES=$(docker logs palworld-dedicated-server 2>&1 | wc -l)
88+
if [ $CURRENT_LOG_LINES -gt $LAST_LOG_LINES ]; then
89+
es ">>> Recent container logs"
90+
es "╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮"
91+
docker logs palworld-dedicated-server 2>&1 | tail -n +$((LAST_LOG_LINES + 1)) | head -n $((CURRENT_LOG_LINES - LAST_LOG_LINES))
92+
es "╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯"
93+
LAST_LOG_LINES=$CURRENT_LOG_LINES
94+
fi
95+
96+
echo "---"
7997
sleep 5
8098
done
81-
echo "Server successfully started"
82-
printf "\e[0;32m%s\e[0m\n" "*****Container LOGS*****"
99+
100+
echo "Server successfully started in $ELAPSED_TIME seconds"
101+
es "*****Final Container LOGS*****"
83102
docker logs palworld-dedicated-server
84103
85-
86104
- name: Test if port 8766, 27015 and 27016 are listening
87105
run: |
88106
nc -z -u -v 127.0.0.1 8211 || exit 2

0 commit comments

Comments
 (0)