Files
ghidra-cli/.github/workflows/test.yml
T
Alexander KiselevandClaude Opus 4.6 876cdbd3cc ci: add diagnostic output for project directory contents after setup
Lists all files in the projects directory after import+analyze+stop
to debug why macOS cache is only 919 bytes while Ubuntu saves 5.6MB.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 15:30:52 -08:00

354 lines
11 KiB
YAML

name: Test
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
# Job 1: Unit tests and CLI tests (no Ghidra needed) - ~2 min
unit-and-cli:
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --verbose
- name: Build test fixture
run: rustc --edition 2021 -o tests/fixtures/sample_binary tests/fixtures/sample_binary.rs
- name: Run unit tests
run: cargo test --lib --verbose
- name: Run CLI tests
run: cargo test --test e2e --test output_format_integration --verbose
# Job 2: Ghidra setup - installs Ghidra and creates test projects to seed caches.
# This runs once per OS, then test jobs use the cached artifacts.
ghidra-setup:
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Cache Ghidra installation and config
id: ghidra-cache
uses: actions/cache@v4
with:
path: |
~/.local/share/ghidra-cli
~/.config/ghidra-cli
~/Library/Application Support/ghidra-cli
~/Library/Preferences/ghidra-cli
~/AppData/Local/ghidra-cli
~/AppData/Roaming/ghidra-cli
key: ghidra-${{ matrix.os }}-v5
- name: Cache Ghidra projects
id: project-cache
uses: actions/cache@v4
with:
path: |
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
- name: Build test fixture
run: rustc --edition 2021 -o tests/fixtures/sample_binary tests/fixtures/sample_binary.rs
- name: Setup Ghidra (skip if cached)
run: |
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..."
cargo run -- setup
fi
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create test project (skip if cached)
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
echo "=== Project directory contents ==="
if [ -d "$HOME/Library/Caches/ghidra-cli/projects" ]; then
find "$HOME/Library/Caches/ghidra-cli/projects" -type f -exec ls -la {} \; 2>/dev/null || true
du -sh "$HOME/Library/Caches/ghidra-cli/projects" 2>/dev/null || true
fi
if [ -d "$HOME/.cache/ghidra-cli/projects" ]; then
find "$HOME/.cache/ghidra-cli/projects" -type f -exec ls -la {} \; 2>/dev/null || true
du -sh "$HOME/.cache/ghidra-cli/projects" 2>/dev/null || true
fi
if [ -d "$HOME/AppData/Local/ghidra-cli/projects" ]; then
find "$HOME/AppData/Local/ghidra-cli/projects" -type f 2>/dev/null | head -20 || true
du -sh "$HOME/AppData/Local/ghidra-cli/projects" 2>/dev/null || true
fi
shell: bash
timeout-minutes: 20
# Job 3: Read-only integration tests (one bridge)
readonly-integration:
needs: ghidra-setup
if: ${{ !cancelled() }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Restore Ghidra installation and config
uses: actions/cache@v4
with:
path: |
~/.local/share/ghidra-cli
~/.config/ghidra-cli
~/Library/Application Support/ghidra-cli
~/Library/Preferences/ghidra-cli
~/AppData/Local/ghidra-cli
~/AppData/Roaming/ghidra-cli
key: ghidra-${{ matrix.os }}-v5
- name: Restore Ghidra projects
uses: actions/cache@v4
with:
path: |
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
- name: Build test fixture
run: rustc --edition 2021 -o tests/fixtures/sample_binary tests/fixtures/sample_binary.rs
- name: Setup Ghidra (fallback if cache missed)
run: |
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..."
cargo run -- setup
fi
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run read-only integration tests
run: cargo test --test readonly_tests --test command_tests --verbose -- --nocapture
timeout-minutes: 80
env:
RUST_LOG: info
# Job 4: Mutation tests (parallel with job 3)
mutation-integration:
needs: ghidra-setup
if: ${{ !cancelled() }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Restore Ghidra installation and config
uses: actions/cache@v4
with:
path: |
~/.local/share/ghidra-cli
~/.config/ghidra-cli
~/Library/Application Support/ghidra-cli
~/Library/Preferences/ghidra-cli
~/AppData/Local/ghidra-cli
~/AppData/Roaming/ghidra-cli
key: ghidra-${{ matrix.os }}-v5
- name: Restore Ghidra projects
uses: actions/cache@v4
with:
path: |
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
- name: Build test fixture
run: rustc --edition 2021 -o tests/fixtures/sample_binary tests/fixtures/sample_binary.rs
- name: Setup Ghidra (fallback if cache missed)
run: |
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..."
cargo run -- setup
fi
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run mutation integration tests
run: cargo test --test comment_tests --test symbol_tests --test patch_tests --test type_tests --test script_tests --verbose -- --nocapture
timeout-minutes: 80
env:
RUST_LOG: info
# Job 5: Infrastructure tests (parallel with jobs 3+4)
infrastructure:
needs: ghidra-setup
if: ${{ !cancelled() }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Restore Ghidra installation and config
uses: actions/cache@v4
with:
path: |
~/.local/share/ghidra-cli
~/.config/ghidra-cli
~/Library/Application Support/ghidra-cli
~/Library/Preferences/ghidra-cli
~/AppData/Local/ghidra-cli
~/AppData/Roaming/ghidra-cli
key: ghidra-${{ matrix.os }}-v5
- name: Restore Ghidra projects
uses: actions/cache@v4
with:
path: |
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
- name: Build test fixture
run: rustc --edition 2021 -o tests/fixtures/sample_binary tests/fixtures/sample_binary.rs
- name: Setup Ghidra (fallback if cache missed)
run: |
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..."
cargo run -- setup
fi
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run infrastructure tests
run: cargo test --test daemon_tests --test reliability_tests --test project_tests --verbose -- --nocapture
timeout-minutes: 80
env:
RUST_LOG: info