|
| 1 | +name: PR 2060 daemon readiness regression |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [sync/pr2060-20260928-e63fe2ec] |
| 6 | + paths: [.github/workflows/pinable-pr2060-daemon-ready.yml] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + validate: |
| 13 | + if: github.repository == 'PinableAgents/codegraph' |
| 14 | + runs-on: ubuntu-latest |
| 15 | + timeout-minutes: 15 |
| 16 | + permissions: |
| 17 | + contents: write |
| 18 | + env: |
| 19 | + CODEGRAPH_TELEMETRY: '0' |
| 20 | + REVIEW_SHA: d08dfc41c3c727322be0b03d08199ab975ae90a9 |
| 21 | + EXPECTED_TREE: 874358989ee9eea2a48e934f24f1f86aff9d06b2 |
| 22 | + FIX_BRANCH: sync/pr2060-daemon-ready-20260928 |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v6 |
| 25 | + with: |
| 26 | + ref: d08dfc41c3c727322be0b03d08199ab975ae90a9 |
| 27 | + fetch-depth: 0 |
| 28 | + persist-credentials: false |
| 29 | + - uses: actions/setup-node@v6 |
| 30 | + with: |
| 31 | + node-version: 22 |
| 32 | + cache: npm |
| 33 | + - name: Add the real attachment barrier used by the adjacent socket test |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + set -euo pipefail |
| 37 | + test "$(git rev-parse HEAD)" = "$REVIEW_SHA" |
| 38 | + test "$(git rev-parse HEAD:__tests__/mcp-daemon.test.ts)" = eac53516f7361c93c0603904f74d7dd9764d039c |
| 39 | + python3 - <<'PY' |
| 40 | + from pathlib import Path |
| 41 | + import hashlib |
| 42 | + p = Path('__tests__/mcp-daemon.test.ts') |
| 43 | + s = p.read_text() |
| 44 | + anchor = """ it.runIf(process.platform !== 'win32')('stops despite a socket still waiting for its client hello (#1963)', async () => { |
| 45 | + const server = spawnServer(tempDir); |
| 46 | + servers.push(server); |
| 47 | + sendInitialize(server.child, `file://${tempDir}`, 1); |
| 48 | + await waitFor(() => findResponse(server.stdout, 1), 10000); |
| 49 | + """ |
| 50 | + extra = """ // The proxy answers initialize locally and the pidfile precedes listen. |
| 51 | + // Wait for an actual daemon handshake before opening the raw client. |
| 52 | + await waitFor(() => server.stderr.some((l) => l.includes('Attached to shared daemon')), 10000); |
| 53 | + """ |
| 54 | + assert s.count(anchor) == 1, 'Test fixture changed; review rather than guessing' |
| 55 | + p.write_text(s.replace(anchor, anchor + extra)) |
| 56 | + assert hashlib.sha256(p.read_bytes()).hexdigest() == '0aa1b093180111ffae5e929ccf8b98a3ee040d03284efc26184025183b4a25a3' |
| 57 | + PY |
| 58 | + git diff --check |
| 59 | + git add __tests__/mcp-daemon.test.ts |
| 60 | + test "$(git write-tree)" = "$EXPECTED_TREE" |
| 61 | + - run: npm ci |
| 62 | + - name: Repeat the real raw-socket shutdown regression twenty times |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + set -euo pipefail |
| 66 | + for attempt in $(seq 1 20); do |
| 67 | + printf '\n=== daemon readiness regression %s / 20 ===\n' "$attempt" |
| 68 | + npm test -- __tests__/mcp-daemon.test.ts -t 'stops despite a socket still waiting for its client hello' --maxWorkers=1 --minWorkers=1 |
| 69 | + done 2>&1 | tee "$RUNNER_TEMP/daemon-readiness-stress.log" |
| 70 | + - name: Commit and push only the tested child on an isolated branch |
| 71 | + shell: bash |
| 72 | + env: |
| 73 | + GH_TOKEN: ${{ github.token }} |
| 74 | + run: | |
| 75 | + set -euo pipefail |
| 76 | + test "$(gh api repos/PinableAgents/codegraph/git/ref/heads/sync/pr2060-resolved-20260928 --jq .object.sha)" = "$REVIEW_SHA" |
| 77 | + git diff --quiet |
| 78 | + test "$(git write-tree)" = "$EXPECTED_TREE" |
| 79 | + test -z "$(git ls-files --others --exclude-standard)" |
| 80 | + git config user.name 'Pinable test regression' |
| 81 | + git config user.email 'noreply@pinable.cc' |
| 82 | + git switch -c "$FIX_BRANCH" |
| 83 | + git commit -m 'test: wait for daemon attachment before connecting a raw client' -m 'The proxy answers initialize before the daemon socket is listening, and daemon.pid is created before listen. Synchronize on the existing attachment signal rather than a guessed sleep. Preserve the real socket test, 1500ms shutdown bound, writer-lock assertion and platform conditions. Verified with 20 repetitions.' |
| 84 | + test "$(git show -s --format=%P HEAD)" = "$REVIEW_SHA" |
| 85 | + if git ls-remote --exit-code --heads origin "$FIX_BRANCH"; then |
| 86 | + echo 'Temporary fix branch already exists; refusing to overwrite it.' >&2 |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | + git -c credential.helper='!gh auth git-credential' push https://github.com/PinableAgents/codegraph.git "HEAD:refs/heads/$FIX_BRANCH" |
| 90 | + printf 'Test-only fix: `%s`\n\nFull current-head CI remains required before merging.\n' "$(git rev-parse HEAD)" >> "$GITHUB_STEP_SUMMARY" |
| 91 | + - uses: actions/upload-artifact@v4 |
| 92 | + if: always() |
| 93 | + with: |
| 94 | + name: pr2060-daemon-readiness-stress-log |
| 95 | + path: ${{ runner.temp }}/daemon-readiness-stress.log |
| 96 | + if-no-files-found: ignore |
| 97 | + retention-days: 7 |
0 commit comments