Skip to content

Commit 1caf52c

Browse files
committed
try to get a thread dump when the CI fails
1 parent f0a650a commit 1caf52c

1 file changed

Lines changed: 41 additions & 6 deletions

File tree

.github/workflows/test.yml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,47 @@ jobs:
2121
java-version: 25
2222
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
2323
- name: Build & Test
24-
run: >-
25-
./gradlew
26-
--console=colored
27-
:operator:test
28-
--fail-fast
29-
-Dquarkus.test.profile=test-pg${{ matrix.postgres-version }}
24+
run: |
25+
# Create a directory for thread dumps
26+
mkdir -p thread-dumps
27+
28+
# Start a background process to take thread dumps every 15 seconds
29+
(
30+
count=1
31+
while true; do
32+
sleep 15
33+
dump_file="thread-dumps/dump-${count}-$(date +%s).txt"
34+
echo "Taking thread dump $count at $(date)" > "$dump_file"
35+
36+
# Find the Java PIDs and save their thread dumps to the file
37+
jps -q | while read -r pid; do
38+
echo "--- Thread dump for PID $pid ---" >> "$dump_file"
39+
jcmd "$pid" Thread.print >> "$dump_file" 2>&1 || true
40+
done
41+
42+
count=$((count+1))
43+
done
44+
) &
45+
DUMP_PID=$!
46+
47+
# Run the actual Gradle build
48+
./gradlew \
49+
--console=colored \
50+
:operator:test \
51+
--fail-fast \
52+
-Dquarkus.test.profile=test-pg${{ matrix.postgres-version }}
53+
54+
# Kill the background thread dump process once the build finishes successfully
55+
kill $DUMP_PID || true
3056
env:
3157
GITHUB_USER_NAME: ${{ github.actor }}
3258
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Upload Thread Dumps
61+
if: always() # Run this step even if the "Build & Test" step fails
62+
uses: actions/upload-artifact@v7
63+
with:
64+
name: thread-dumps-pg${{ matrix.postgres-version }}
65+
path: thread-dumps/
66+
retention-days: 7
67+
compression-level: 3

0 commit comments

Comments
 (0)