Skip to content

Commit 3b099b5

Browse files
committed
test
1 parent bd58053 commit 3b099b5

4 files changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: Thread dump on cancellation
2+
description: Capture JVM thread dumps after a job is cancelled.
3+
runs:
4+
using: node20
5+
main: main.js
6+
post: post.js
7+
post-if: cancelled()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Thread dump post-step registered.");
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { execSync } = require("child_process");
2+
3+
function run(command) {
4+
execSync(command, { stdio: "inherit", shell: "/bin/bash" });
5+
}
6+
7+
function dumpThreads() {
8+
run('echo "== Cancellation detected: capturing JVM thread dumps =="');
9+
run(
10+
[
11+
"set -euo pipefail",
12+
"pids=$(pgrep -f '[j]ava' || true)",
13+
'if [[ -z "${pids}" ]]; then echo "No Java processes found."; exit 0; fi',
14+
"if command -v jcmd >/dev/null 2>&1; then",
15+
" for pid in ${pids}; do",
16+
' echo "-- jcmd Thread.print for PID ${pid} --"',
17+
" jcmd \"${pid}\" Thread.print || true",
18+
" done",
19+
" exit 0",
20+
"fi",
21+
"if command -v jstack >/dev/null 2>&1; then",
22+
" for pid in ${pids}; do",
23+
' echo "-- jstack for PID ${pid} --"',
24+
" jstack \"${pid}\" || true",
25+
" done",
26+
" exit 0",
27+
"fi",
28+
"for pid in ${pids}; do",
29+
' echo "-- kill -QUIT ${pid} (no jcmd/jstack available) --"',
30+
" kill -QUIT \"${pid}\" || true",
31+
"done",
32+
].join("\n")
33+
);
34+
}
35+
36+
try {
37+
dumpThreads();
38+
} catch (error) {
39+
console.error("Thread dump post-step failed:", error);
40+
}

.github/workflows/pr-verify.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v4
19+
- name: Register JVM thread dump on cancel
20+
uses: ./.github/actions/thread-dump-post
1921
- name: Set up JDK
2022
uses: actions/setup-java@v4
2123
with:
@@ -34,6 +36,8 @@ jobs:
3436
runs-on: ubuntu-latest
3537
steps:
3638
- uses: actions/checkout@v4
39+
- name: Register JVM thread dump on cancel
40+
uses: ./.github/actions/thread-dump-post
3741
- name: Set up JDK
3842
uses: actions/setup-java@v4
3943
with:
@@ -53,6 +57,8 @@ jobs:
5357
jdk: [ 11, 25 ]
5458
steps:
5559
- uses: actions/checkout@v4
60+
- name: Register JVM thread dump on cancel
61+
uses: ./.github/actions/thread-dump-post
5662
- name: Set up JDK
5763
uses: actions/setup-java@v4
5864
with:
@@ -75,6 +81,8 @@ jobs:
7581
runs-on: ubuntu-latest
7682
steps:
7783
- uses: actions/checkout@v4
84+
- name: Register JVM thread dump on cancel
85+
uses: ./.github/actions/thread-dump-post
7886
- name: Set up JDK
7987
uses: actions/setup-java@v4
8088
with:
@@ -96,6 +104,8 @@ jobs:
96104
runs-on: ubuntu-latest
97105
steps:
98106
- uses: actions/checkout@v4
107+
- name: Register JVM thread dump on cancel
108+
uses: ./.github/actions/thread-dump-post
99109
- name: Set up JDK
100110
uses: actions/setup-java@v4
101111
with:
@@ -117,6 +127,8 @@ jobs:
117127
runs-on: ubuntu-latest
118128
steps:
119129
- uses: actions/checkout@v4
130+
- name: Register JVM thread dump on cancel
131+
uses: ./.github/actions/thread-dump-post
120132
- name: Set up JDK
121133
uses: actions/setup-java@v4
122134
with:
@@ -134,6 +146,8 @@ jobs:
134146
runs-on: ubuntu-latest
135147
steps:
136148
- uses: actions/checkout@v4
149+
- name: Register JVM thread dump on cancel
150+
uses: ./.github/actions/thread-dump-post
137151
- name: Set up JDK
138152
uses: actions/setup-java@v4
139153
with:
@@ -154,5 +168,7 @@ jobs:
154168
runs-on: ubuntu-latest
155169
steps:
156170
- uses: actions/checkout@v4
171+
- name: Register JVM thread dump on cancel
172+
uses: ./.github/actions/thread-dump-post
157173
- name: check copyright header present
158174
run: scripts/checkCopyrightPresent.sh

0 commit comments

Comments
 (0)