mirror of
https://github.com/encounter/ghidra-cli.git
synced 2026-07-10 03:18:56 -07:00
another attempt at fixing the CI/CD issues
This commit is contained in:
@@ -43,7 +43,7 @@ jobs:
|
||||
~/Library/Preferences/ghidra-cli
|
||||
~/AppData/Local/ghidra-cli
|
||||
~/AppData/Roaming/ghidra-cli
|
||||
key: ghidra-${{ matrix.os }}-v4
|
||||
key: ghidra-${{ matrix.os }}-v5
|
||||
|
||||
- name: Cache Ghidra projects
|
||||
uses: actions/cache@v4
|
||||
@@ -62,7 +62,9 @@ jobs:
|
||||
|
||||
- name: Setup Ghidra
|
||||
run: |
|
||||
if cargo run -- doctor 2>&1 | grep -q "analyzeHeadless: OK"; then
|
||||
DOCTOR_OUTPUT=$(cargo run -- doctor 2>&1 || true)
|
||||
echo "$DOCTOR_OUTPUT"
|
||||
if echo "$DOCTOR_OUTPUT" | grep -q "analyzeHeadless: OK"; then
|
||||
echo "Ghidra already installed (cache hit), skipping setup"
|
||||
else
|
||||
echo "Ghidra not found, running setup..."
|
||||
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
~/Library/Preferences/ghidra-cli
|
||||
~/AppData/Local/ghidra-cli
|
||||
~/AppData/Roaming/ghidra-cli
|
||||
key: ghidra-${{ matrix.os }}-v4
|
||||
key: ghidra-${{ matrix.os }}-v5
|
||||
|
||||
- name: Cache Ghidra projects
|
||||
id: project-cache
|
||||
@@ -100,7 +100,9 @@ jobs:
|
||||
|
||||
- name: Setup Ghidra (skip if cached)
|
||||
run: |
|
||||
if cargo run -- doctor 2>&1 | grep -q "analyzeHeadless: OK"; then
|
||||
DOCTOR_OUTPUT=$(cargo run -- doctor 2>&1 || true)
|
||||
echo "$DOCTOR_OUTPUT"
|
||||
if echo "$DOCTOR_OUTPUT" | grep -q "analyzeHeadless: OK"; then
|
||||
echo "Ghidra already installed (cache hit), skipping setup"
|
||||
else
|
||||
echo "Ghidra not found, running setup..."
|
||||
@@ -153,7 +155,7 @@ jobs:
|
||||
~/Library/Preferences/ghidra-cli
|
||||
~/AppData/Local/ghidra-cli
|
||||
~/AppData/Roaming/ghidra-cli
|
||||
key: ghidra-${{ matrix.os }}-v4
|
||||
key: ghidra-${{ matrix.os }}-v5
|
||||
|
||||
- name: Restore Ghidra projects
|
||||
uses: actions/cache@v4
|
||||
@@ -172,7 +174,9 @@ jobs:
|
||||
|
||||
- name: Setup Ghidra (fallback if cache missed)
|
||||
run: |
|
||||
if cargo run -- doctor 2>&1 | grep -q "analyzeHeadless: OK"; then
|
||||
DOCTOR_OUTPUT=$(cargo run -- doctor 2>&1 || true)
|
||||
echo "$DOCTOR_OUTPUT"
|
||||
if echo "$DOCTOR_OUTPUT" | grep -q "analyzeHeadless: OK"; then
|
||||
echo "Ghidra already installed (cache hit)"
|
||||
else
|
||||
echo "Cache miss, running setup..."
|
||||
@@ -224,7 +228,7 @@ jobs:
|
||||
~/Library/Preferences/ghidra-cli
|
||||
~/AppData/Local/ghidra-cli
|
||||
~/AppData/Roaming/ghidra-cli
|
||||
key: ghidra-${{ matrix.os }}-v4
|
||||
key: ghidra-${{ matrix.os }}-v5
|
||||
|
||||
- name: Restore Ghidra projects
|
||||
uses: actions/cache@v4
|
||||
@@ -243,7 +247,9 @@ jobs:
|
||||
|
||||
- name: Setup Ghidra (fallback if cache missed)
|
||||
run: |
|
||||
if cargo run -- doctor 2>&1 | grep -q "analyzeHeadless: OK"; then
|
||||
DOCTOR_OUTPUT=$(cargo run -- doctor 2>&1 || true)
|
||||
echo "$DOCTOR_OUTPUT"
|
||||
if echo "$DOCTOR_OUTPUT" | grep -q "analyzeHeadless: OK"; then
|
||||
echo "Ghidra already installed (cache hit)"
|
||||
else
|
||||
echo "Cache miss, running setup..."
|
||||
@@ -295,7 +301,7 @@ jobs:
|
||||
~/Library/Preferences/ghidra-cli
|
||||
~/AppData/Local/ghidra-cli
|
||||
~/AppData/Roaming/ghidra-cli
|
||||
key: ghidra-${{ matrix.os }}-v4
|
||||
key: ghidra-${{ matrix.os }}-v5
|
||||
|
||||
- name: Restore Ghidra projects
|
||||
uses: actions/cache@v4
|
||||
@@ -314,7 +320,9 @@ jobs:
|
||||
|
||||
- name: Setup Ghidra (fallback if cache missed)
|
||||
run: |
|
||||
if cargo run -- doctor 2>&1 | grep -q "analyzeHeadless: OK"; then
|
||||
DOCTOR_OUTPUT=$(cargo run -- doctor 2>&1 || true)
|
||||
echo "$DOCTOR_OUTPUT"
|
||||
if echo "$DOCTOR_OUTPUT" | grep -q "analyzeHeadless: OK"; then
|
||||
echo "Ghidra already installed (cache hit)"
|
||||
else
|
||||
echo "Cache miss, running setup..."
|
||||
|
||||
+21
-8
@@ -123,6 +123,21 @@ pub fn ensure_test_project(project: &str, program: &str) {
|
||||
Err(e) => eprintln!("Analyze error: {}", e),
|
||||
}
|
||||
|
||||
// Step 3: Stop the bridge that import/analyze left running.
|
||||
// Without this, the first test reuses the leftover bridge (free pass),
|
||||
// but when it stops the bridge, subsequent tests must start fresh ones.
|
||||
// This inconsistency causes the first test to pass while others fail.
|
||||
eprintln!("Step 3: Stopping leftover bridge...");
|
||||
let stop_status = run_cli_with_timeout(
|
||||
&ghidra_bin,
|
||||
&["stop", "--project", project],
|
||||
Duration::from_secs(60),
|
||||
);
|
||||
match stop_status {
|
||||
Ok(status) => eprintln!("Bridge stop finished with status: {}", status),
|
||||
Err(e) => eprintln!("Bridge stop error (may be expected): {}", e),
|
||||
}
|
||||
|
||||
eprintln!("=== Test project setup complete ===");
|
||||
});
|
||||
}
|
||||
@@ -289,14 +304,12 @@ fn get_unique_data_dir() -> PathBuf {
|
||||
dir
|
||||
}
|
||||
|
||||
/// Run a CLI command with timeout, using Stdio::null() to avoid pipe inheritance.
|
||||
/// Run a CLI command with timeout.
|
||||
///
|
||||
/// On Windows, child processes inherit pipe handles from their parent. When the CLI
|
||||
/// spawns analyzeHeadless.bat (which spawns java.exe), the grandchild JVM inherits
|
||||
/// the pipe handles. Even after the CLI exits, the pipes remain open because the JVM
|
||||
/// holds the inherited handles, causing wait_with_output()/output() to block forever.
|
||||
///
|
||||
/// Using Stdio::null() avoids creating pipes entirely, so there are no handles to inherit.
|
||||
/// Stdout uses Stdio::null() to avoid pipe handle inheritance on Windows, where
|
||||
/// grandchild JVM processes inherit pipe handles and block wait_with_output() forever.
|
||||
/// Stderr uses Stdio::inherit() so errors are visible in CI logs (inheriting the parent
|
||||
/// fd doesn't create a pipe, so there's no blocking issue).
|
||||
pub fn run_cli_with_timeout(
|
||||
bin: &std::path::Path,
|
||||
args: &[&str],
|
||||
@@ -307,7 +320,7 @@ pub fn run_cli_with_timeout(
|
||||
let mut child = Command::new(bin)
|
||||
.args(args)
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.stderr(Stdio::inherit())
|
||||
.spawn()
|
||||
.context("Failed to spawn CLI command")?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user