|
| 1 | +# Fix CI Test Hang Issue |
| 2 | + |
| 3 | +**Created:** 2026-01-10 |
| 4 | +**Status:** In Progress |
| 5 | +**Priority:** High |
| 6 | +**Assigned Version:** v1.3.1 |
| 7 | + |
| 8 | +## Problem Statement |
| 9 | + |
| 10 | +Test fixtures validation hangs in GitHub Actions CI environment but works locally and in CI emulation. |
| 11 | + |
| 12 | +### Symptoms |
| 13 | +- ✅ Tests pass locally (macOS): 10/10 |
| 14 | +- ✅ Tests pass in CI emulation (`run-tests-ci-mode.sh`): 10/10 |
| 15 | +- ❌ Tests hang in GitHub Actions Ubuntu environment |
| 16 | +- ❌ Docker tests hang when running `check-performance.sh` |
| 17 | + |
| 18 | +### Current Workaround |
| 19 | +Temporarily disabled `validate-test-fixtures` job in `.github/workflows/ci.yml` (lines 123-181). |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Investigation Notes |
| 24 | + |
| 25 | +### What We Know |
| 26 | +1. **Local tests work** - All 10 tests pass on macOS with TTY |
| 27 | +2. **CI emulation works** - Tests pass with `setsid`/`script` TTY detachment |
| 28 | +3. **Docker hangs** - Tests hang when running in Ubuntu container |
| 29 | +4. **Pattern library manager suspected** - Likely cause of hang |
| 30 | + |
| 31 | +### What We've Tried |
| 32 | +1. ✅ Added `jq` dependency to CI |
| 33 | +2. ✅ Added TTY availability check in `check-performance.sh` |
| 34 | +3. ✅ Created CI emulator script |
| 35 | +4. ✅ Created Docker testing infrastructure |
| 36 | +5. ❌ Docker tests still hang |
| 37 | + |
| 38 | +### Likely Root Cause |
| 39 | +The pattern library manager (`pattern-library-manager.sh`) is being called during each test run and may be: |
| 40 | +- Waiting for input that never comes |
| 41 | +- Stuck in an infinite loop |
| 42 | +- Blocked on a file operation |
| 43 | +- Hanging on a subprocess |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Next Steps |
| 48 | + |
| 49 | +### Option 1: Skip Pattern Library Manager in Tests |
| 50 | +Add a flag to `check-performance.sh` to skip pattern library updates during testing: |
| 51 | + |
| 52 | +```bash |
| 53 | +# In check-performance.sh |
| 54 | +if [ "$SKIP_PATTERN_LIBRARY_UPDATE" = "true" ]; then |
| 55 | + # Skip pattern library manager |
| 56 | +else |
| 57 | + # Run pattern library manager |
| 58 | +fi |
| 59 | +``` |
| 60 | + |
| 61 | +Then in test script: |
| 62 | +```bash |
| 63 | +export SKIP_PATTERN_LIBRARY_UPDATE=true |
| 64 | +./bin/check-performance.sh --format json --paths "$fixture_file" --no-log |
| 65 | +``` |
| 66 | + |
| 67 | +### Option 2: Debug Pattern Library Manager |
| 68 | +Add trace logging to `pattern-library-manager.sh` to identify where it hangs: |
| 69 | +- Add `set -x` at the top |
| 70 | +- Log each major operation |
| 71 | +- Identify blocking operation |
| 72 | + |
| 73 | +### Option 3: Pre-generate Pattern Library |
| 74 | +Generate pattern library once before tests, then skip updates: |
| 75 | +```bash |
| 76 | +# Before tests |
| 77 | +./bin/pattern-library-manager.sh both |
| 78 | + |
| 79 | +# During tests |
| 80 | +export SKIP_PATTERN_LIBRARY_UPDATE=true |
| 81 | +./tests/run-fixture-tests.sh |
| 82 | +``` |
| 83 | + |
| 84 | +### Option 4: Timeout Pattern Library Manager |
| 85 | +Add timeout to pattern library manager call: |
| 86 | +```bash |
| 87 | +timeout 10 bash "$SCRIPT_DIR/pattern-library-manager.sh" both > /dev/null 2>&1 || true |
| 88 | +``` |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## Acceptance Criteria |
| 93 | + |
| 94 | +- [ ] Tests pass 10/10 in GitHub Actions CI |
| 95 | +- [ ] Tests complete in reasonable time (<5 minutes total) |
| 96 | +- [ ] No hangs or timeouts |
| 97 | +- [ ] JSON output is clean and valid |
| 98 | +- [ ] Pattern library is still updated (or acceptable to skip during tests) |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## Files to Modify |
| 103 | + |
| 104 | +| File | Change Needed | |
| 105 | +|------|---------------| |
| 106 | +| `dist/bin/check-performance.sh` | Add `SKIP_PATTERN_LIBRARY_UPDATE` flag support | |
| 107 | +| `dist/tests/run-fixture-tests.sh` | Set `SKIP_PATTERN_LIBRARY_UPDATE=true` | |
| 108 | +| `.github/workflows/ci.yml` | Re-enable `validate-test-fixtures` job | |
| 109 | +| `CHANGELOG.md` | Document fix | |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## Testing Plan |
| 114 | + |
| 115 | +1. **Local testing:** |
| 116 | + ```bash |
| 117 | + export SKIP_PATTERN_LIBRARY_UPDATE=true |
| 118 | + ./tests/run-fixture-tests.sh |
| 119 | + ``` |
| 120 | + |
| 121 | +2. **CI emulation:** |
| 122 | + ```bash |
| 123 | + export SKIP_PATTERN_LIBRARY_UPDATE=true |
| 124 | + ./tests/run-tests-ci-mode.sh |
| 125 | + ``` |
| 126 | + |
| 127 | +3. **Docker testing:** |
| 128 | + ```bash |
| 129 | + docker run --rm \ |
| 130 | + -v "$(pwd):/workspace" \ |
| 131 | + -w /workspace/dist \ |
| 132 | + -e CI=true \ |
| 133 | + -e SKIP_PATTERN_LIBRARY_UPDATE=true \ |
| 134 | + ubuntu:24.04 \ |
| 135 | + bash -c 'apt-get update >/dev/null 2>&1 && apt-get install -y jq perl >/dev/null 2>&1 && ./tests/run-fixture-tests.sh' |
| 136 | + ``` |
| 137 | + |
| 138 | +4. **GitHub Actions:** |
| 139 | + - Push to PR branch |
| 140 | + - Verify tests complete without hanging |
| 141 | + - Verify 10/10 tests pass |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +## Related |
| 146 | + |
| 147 | +- **CI Workflow:** `.github/workflows/ci.yml` |
| 148 | +- **Test Script:** `dist/tests/run-fixture-tests.sh` |
| 149 | +- **Core Scanner:** `dist/bin/check-performance.sh` |
| 150 | +- **Pattern Library Manager:** `dist/bin/pattern-library-manager.sh` |
| 151 | +- **Previous Fix:** `PROJECT/3-COMPLETED/CI-JSON-PARSING-FIX.md` |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +## Notes |
| 156 | + |
| 157 | +- Pattern library manager is useful for keeping patterns up-to-date |
| 158 | +- During testing, we don't need to regenerate the pattern library every time |
| 159 | +- Skipping pattern library updates during tests is acceptable |
| 160 | +- Pattern library can still be updated manually or during normal scans |
| 161 | + |
0 commit comments