Skip to content

Commit 4d5e5f9

Browse files
claudecyberkaida
authored andcommitted
Add support for headless Ghidra and stdio MCP server
- Add pyghidra support - Add manual MCP server start - Add python package again - Add end to end tests - Test in docker container
1 parent 2756277 commit 4d5e5f9

40 files changed

+7193
-169
lines changed

.github/CI_WORKFLOWS.md

Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
# GitHub Actions CI Workflows
2+
3+
This document describes the CI/CD workflows for the ReVa project.
4+
5+
## Workflows Overview
6+
7+
### 1. `test-ghidra.yml` - Main Extension Tests
8+
9+
**Triggers**: Push/PR to main or develop branches
10+
11+
**What it does**:
12+
- Tests ReVa as a Ghidra extension (GUI mode)
13+
- Runs unit tests and integration tests
14+
- Tests on multiple Ghidra versions (11.4, 11.4.2, latest)
15+
- Includes lint checks and CodeQL security analysis
16+
17+
**Jobs**:
18+
- `test` - Runs gradle unit and integration tests
19+
- `lint` - Code compilation checks
20+
- `codeql` - Security vulnerability scanning
21+
22+
**Duration**: ~10-15 minutes per matrix job
23+
24+
### 2. `test-headless.yml` - Headless Mode Tests
25+
26+
**Triggers**:
27+
- Push/PR to main or develop (when headless files change)
28+
- Manual workflow dispatch
29+
30+
**What it does**:
31+
- Tests ReVa in headless Ghidra mode via pyghidra
32+
- Runs Python-based headless server tests
33+
- Tests on multiple OS (Ubuntu, macOS, Windows)
34+
- Tests on multiple Ghidra versions (11.4.2, latest)
35+
- Tests on multiple Python versions (3.9, 3.11, 3.12)
36+
37+
**Jobs**:
38+
- `test-headless` - Unix/Mac matrix testing
39+
- `test-headless-windows` - Windows-specific testing
40+
- `test-summary` - Aggregates results
41+
42+
**Duration**: ~5-8 minutes per matrix job
43+
44+
**Test Coverage**:
45+
1. Quick smoke test (start/stop/verify)
46+
2. Custom port configuration
47+
3. Configuration file loading
48+
4. Cross-platform compatibility
49+
50+
### 3. `publish-ghidra.yml` - Release Publishing
51+
52+
**Triggers**: Manual or release tags
53+
54+
**What it does**:
55+
- Builds and publishes release artifacts
56+
- Creates GitHub releases
57+
- Uploads extension zip files
58+
59+
**Duration**: ~5 minutes
60+
61+
### 4. `claude.yml` - Claude Code Integration
62+
63+
**Triggers**: Varies (project-specific)
64+
65+
**What it does**:
66+
- Claude Code specific automation
67+
- May include code review, documentation, etc.
68+
69+
## Test Matrix Strategy
70+
71+
### Main Extension Tests (`test-ghidra.yml`)
72+
73+
```
74+
Matrix:
75+
OS: ubuntu-latest
76+
Ghidra: [11.4, 11.4.2, latest]
77+
78+
Total: 3 jobs
79+
```
80+
81+
### Headless Mode Tests (`test-headless.yml`)
82+
83+
```
84+
Unix/Mac Matrix:
85+
OS: [ubuntu-latest, macos-latest]
86+
Ghidra: [11.4.2, latest]
87+
Python: [3.9, 3.11, 3.12]
88+
Excludes: (11.4.2 + older Python versions)
89+
90+
Total: 8 jobs (2 OS × 2 Ghidra × 2 Python combinations)
91+
92+
Windows:
93+
OS: windows-latest
94+
Ghidra: latest
95+
Python: 3.12
96+
97+
Total: 1 job
98+
99+
Grand Total: 9 jobs
100+
```
101+
102+
## Workflow Optimization
103+
104+
### Path Filtering
105+
106+
The headless workflow only runs when relevant files change:
107+
- `src/main/java/reva/headless/**`
108+
- `src/main/java/reva/plugin/config/**`
109+
- `scripts/**`
110+
- `config/**`
111+
- Configuration files
112+
113+
This reduces unnecessary CI runs when unrelated files change.
114+
115+
### Matrix Exclusions
116+
117+
The headless workflow excludes some combinations to reduce CI time:
118+
- Only tests older Python versions (3.9, 3.11) on latest Ghidra
119+
- Tests Python 3.12 on all Ghidra versions
120+
- Balances coverage vs. execution time
121+
122+
### Fail-Fast: Disabled
123+
124+
Both test workflows use `fail-fast: false` to ensure all matrix jobs complete even if some fail. This provides complete test coverage visibility.
125+
126+
## Running Workflows
127+
128+
### Automatic Triggers
129+
130+
Both workflows automatically run on:
131+
- Push to `main` or `develop` branches
132+
- Pull requests to `main` or `develop` branches
133+
134+
### Manual Triggers
135+
136+
The headless workflow can be manually triggered:
137+
138+
1. Go to Actions tab in GitHub
139+
2. Select "Test Headless Mode 🤖"
140+
3. Click "Run workflow"
141+
4. Select branch
142+
5. Click "Run workflow"
143+
144+
This is useful for:
145+
- Testing on feature branches
146+
- Debugging CI issues
147+
- Validating fixes
148+
149+
## Debugging Failed Tests
150+
151+
### View Test Results
152+
153+
1. Click on failed workflow run
154+
2. Click on failed job
155+
3. Expand failing step to see logs
156+
157+
### Download Artifacts
158+
159+
Failed runs upload artifacts:
160+
- Test results (XML/HTML)
161+
- Log files
162+
- Configuration files
163+
164+
Download via workflow run page → Artifacts section
165+
166+
### Common Issues
167+
168+
**Issue: PyGhidra import fails**
169+
```
170+
ImportError: No module named 'pyghidra'
171+
```
172+
**Solution**: Check pip install step completed successfully
173+
174+
**Issue: Ghidra not found**
175+
```
176+
GHIDRA_INSTALL_DIR not set
177+
```
178+
**Solution**: Check setup-ghidra action completed successfully
179+
180+
**Issue: Timeout**
181+
```
182+
Error: The operation was canceled.
183+
```
184+
**Solution**: Increase timeout or check for hanging processes
185+
186+
**Issue: Port already in use**
187+
```
188+
BindException: Address already in use
189+
```
190+
**Solution**: Tests should use different ports or proper cleanup
191+
192+
## Performance Benchmarks
193+
194+
### Expected Durations
195+
196+
| Workflow | Jobs | Avg Time/Job | Total Time (parallel) |
197+
|----------|------|--------------|----------------------|
198+
| test-ghidra.yml | 3 + lint + codeql | 12 min | ~15 min |
199+
| test-headless.yml | 9 | 6 min | ~8 min |
200+
| publish-ghidra.yml | 1 | 5 min | ~5 min |
201+
202+
### Parallelization
203+
204+
Both test workflows run matrix jobs in parallel, significantly reducing total CI time compared to sequential execution.
205+
206+
## CI/CD Best Practices
207+
208+
### For Contributors
209+
210+
1. **Run tests locally first** when possible
211+
```bash
212+
# Main tests
213+
gradle test
214+
gradle integrationTest
215+
216+
# Headless tests
217+
python scripts/test_headless_quick.py
218+
```
219+
220+
2. **Use draft PRs** for work in progress to avoid unnecessary CI runs
221+
222+
3. **Path filtering** means not all changes trigger all workflows
223+
224+
4. **Check CI status** before requesting review
225+
226+
### For Maintainers
227+
228+
1. **Review test results** before merging PRs
229+
230+
2. **Monitor CI performance** and adjust matrix if needed
231+
232+
3. **Update workflows** when:
233+
- New Ghidra version released
234+
- Python version EOL
235+
- Dependencies updated
236+
237+
4. **Keep documentation updated** when changing workflows
238+
239+
## Troubleshooting CI
240+
241+
### Workflow doesn't trigger
242+
243+
**Check**:
244+
- Branch name matches trigger pattern
245+
- File paths match path filter
246+
- Workflow file is valid YAML
247+
248+
### Tests pass locally but fail in CI
249+
250+
**Common causes**:
251+
- Environment differences (OS, versions)
252+
- Missing dependencies in CI
253+
- Timeout too short
254+
- Race conditions
255+
256+
**Debug**:
257+
1. Check workflow environment matches local
258+
2. Add debug logging to tests
259+
3. Increase timeouts
260+
4. Use workflow dispatch to test manually
261+
262+
### Long CI times
263+
264+
**Optimization options**:
265+
1. Reduce matrix size
266+
2. Add path filters
267+
3. Use caching for dependencies
268+
4. Increase parallelization
269+
270+
## Monitoring
271+
272+
### Workflow Status Badge
273+
274+
Add to README:
275+
```markdown
276+
![Test Headless Mode](https://github.com/your-org/reverse-engineering-assistant/actions/workflows/test-headless.yml/badge.svg)
277+
```
278+
279+
### Notifications
280+
281+
GitHub sends notifications on:
282+
- Workflow failures (to committer)
283+
- Status changes (if watching repo)
284+
285+
Configure in GitHub settings → Notifications
286+
287+
## Future Enhancements
288+
289+
Potential workflow improvements:
290+
291+
1. **Performance Tests**
292+
- Benchmark startup times
293+
- Memory usage profiling
294+
- API response times
295+
296+
2. **E2E Tests**
297+
- Full MCP client integration
298+
- Real binary analysis
299+
- Multi-tool workflows
300+
301+
3. **Docker Tests**
302+
- Build Docker image
303+
- Test container deployment
304+
- Docker Compose orchestration
305+
306+
4. **Coverage Reports**
307+
- JaCoCo for Java
308+
- Coverage.py for Python
309+
- Combined coverage metrics
310+
311+
5. **Automated Releases**
312+
- Version bumping
313+
- Changelog generation
314+
- Asset uploads
315+
316+
## References
317+
318+
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
319+
- [setup-ghidra Action](https://github.com/antoniovazquezblanco/setup-ghidra)
320+
- [Gradle Actions](https://github.com/gradle/actions)
321+
- [PyGhidra Documentation](https://github.com/dod-cyber-crime-center/pyghidra)

0 commit comments

Comments
 (0)