fix: stop bridge before caching and validate .rep directory content

The ghidra-setup job left the bridge running after import+analyze,
so the Ghidra JVM hadn't flushed the project database to the .rep
directory when the post-job cache save ran. This resulted in caches
containing only the ~1KB .gpr file without any analysis data.

- Stop bridge after import+analyze in ghidra-setup (both workflows)
- Bump cache keys v2→v3 to invalidate broken empty caches
- Validate .rep has actual files, not just an empty directory

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Kiselev
2026-02-22 15:13:59 -08:00
co-authored by Claude Opus 4.6
parent d5f9a96df9
commit d9ee02902d
3 changed files with 18 additions and 8 deletions
+2 -1
View File
@@ -52,7 +52,7 @@ jobs:
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
@@ -78,6 +78,7 @@ jobs:
run: |
cargo run -- import tests/fixtures/sample_binary --project ci-test --program sample_binary || true
cargo run -- analyze --project ci-test --program sample_binary || true
cargo run -- stop --project ci-test || true
shell: bash
timeout-minutes: 20
+5 -4
View File
@@ -90,7 +90,7 @@ jobs:
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
@@ -116,6 +116,7 @@ jobs:
run: |
cargo run -- import tests/fixtures/sample_binary --project ci-test --program sample_binary || true
cargo run -- analyze --project ci-test --program sample_binary || true
cargo run -- stop --project ci-test || true
shell: bash
timeout-minutes: 20
@@ -164,7 +165,7 @@ jobs:
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
@@ -237,7 +238,7 @@ jobs:
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
@@ -310,7 +311,7 @@ jobs:
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
+11 -3
View File
@@ -57,13 +57,21 @@ pub fn ensure_test_project(project: &str, program: &str) {
let gpr_file = projects_dir.join(format!("{}.gpr", project));
let rep_dir = projects_dir.join(format!("{}.rep", project));
if gpr_file.exists() && rep_dir.exists() && rep_dir.is_dir() {
// Check that .rep has actual content (not just an empty directory).
// If the bridge wasn't stopped before caching, .rep may exist but be empty
// because Ghidra hadn't flushed the project database to disk.
let rep_has_content = rep_dir.is_dir()
&& std::fs::read_dir(&rep_dir)
.map(|mut entries| entries.next().is_some())
.unwrap_or(false);
if gpr_file.exists() && rep_has_content {
eprintln!("=== Using cached test project: {:?} ===", gpr_file);
return;
}
if gpr_file.exists() {
eprintln!("=== Project .gpr exists but .rep missing, re-importing ===");
if gpr_file.exists() && !rep_has_content {
eprintln!("=== Project .gpr exists but .rep missing or empty, re-importing ===");
}
eprintln!("=== Setting up test project (import + analyze) ===");