Skip to content

feat(release): smoke test を ARK_PORT 固定 + readiness probe 方式に変更#197

Merged
shomatan merged 1 commit into
mainfrom
feat/release-smoke-fixed-port
May 13, 2026
Merged

feat(release): smoke test を ARK_PORT 固定 + readiness probe 方式に変更#197
shomatan merged 1 commit into
mainfrom
feat/release-smoke-fixed-port

Conversation

@shomatan
Copy link
Copy Markdown
Collaborator

概要

issue #181 対応。release.yml の Smoke test .app bootstrap は、起動した .app の stdout から
Ark server running on http://localhost:<port> を grep してポートを抽出し、その値を curl
渡していた。codex review で「依存 binary や app stdout に紛れた偽 URL で runner 内の別 listen
process に curl してしまう抜けがある」と [P2] 指摘あり (PR #182)。

ログ依存の port 抽出を撤廃し、ARK_PORT外側から固定 する assertive な方式に変更。

変更

packages/desktop/src/main.ts

  • Electron bootstrap で ARK_PORT 環境変数があれば固定ポートで listen、未指定なら従来の動的取得
  • ARK_PORT は CI smoke test だけでなくリバースプロキシ前提など外部固定ポート全用途の公開設定
  • 厳密バリデーション: /^[1-9][0-9]*$/ + 1..65535 のみ許容、不正値は silent fallback せず throw で fail-fast
    • 空文字 / 先頭 0 / 指数表記 (1e3) / 16 進表記 (0x50) / 小数 (1.5) を全て弾く
    • Number() 単独だと 1e31000 として通すため、Number.isInteger の前にパターンチェックを置く

.github/workflows/release.yml Smoke test .app bootstrap step

  • env.ARK_PORT="4042" を追加し .app の listen ポートを workflow 側から固定
  • 起動前に lsofARK_PORT が既に listen 中でないことを assert (runner image 側の競合を可視化)
  • readiness probe を「stdout grep」→「curl http://localhost:${ARK_PORT}/ で HTTP 200 を要求」に変更 (TCP 接続だけ見ると 4xx/5xx も通るため codex [中] 指摘反映)
  • PID-port binding 検証: probe 200 を受けた後、lsof -iTCP:${ARK_PORT} -sTCP:LISTEN の listener PID が $PID の process group (Electron Helper / Renderer 含む) に属することを確認 (TOCTOU 経路で別 process が後から同 port を掴むケースを検知、codex [中] 指摘反映)
  • 旧 awk による grep / sanity check / PORT 変数の動的算出を撤廃
  • 下流 step の $PORT 参照を ${ARK_PORT} に統一 (旧名残の reassignment 削除)

codex review の反映履歴

ラウンド 指摘 反映
v1 [中] CI 専用 vs 製品経路、Number.isFinite 弱い、命名 コメント再フレーム + Number.isInteger
v2 [高] Number()1e3/0x50 を通す、[中] silent fallback パターンチェック先行 + 不正値 throw
v3 [中] HTTP 200 要求、空文字も fail、TOCTOU コメント readiness probe で 200 要求、空文字 throw、TOCTOU 残を明示
v4 [中] PID-port binding 未確認、[低] PORT 命名 listener PID を process group で検証、${ARK_PORT} 直参照に統一

関連

issue #181 対応。release.yml の Smoke test .app bootstrap が起動 stdout から
正規表現で localhost ポートを grep していたため、依存 binary や app stdout に
紛れた偽ログ経由で runner 内の別 listen process に curl してしまう抜けがあった
(codex review P5 で [P2] 指摘済み)。

## 変更

### packages/desktop/src/main.ts
- bootstrap 時に ARK_PORT 環境変数があればそれを採用し、なければ
  従来通り getAvailablePort() で動的取得
- 0 / 範囲外 / 非数値の場合は無視して動的取得にフォールバック (誤設定耐性)

### .github/workflows/release.yml
- Smoke test .app bootstrap step に env.ARK_PORT='4042' を追加して .app の
  listen ポートを workflow 側から固定
- 起動前に lsof で ARK_PORT が既に listen 中でないことを assert (runner image
  側で別 process が同 port を取っている場合に CI を fail させて可視化)
- readiness probe を「stdout から PORT を grep」→「ARK_PORT に curl」に変更し、
  TCP 接続成立を listen 開始と見なす assertive な方式に
- 旧 awk による grep / sanity check / PORT 変数の動的算出を撤廃
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Warning

Rate limit exceeded

@shomatan has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 37 minutes and 4 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5281d6f1-3917-477b-8186-d4a44a5dc03a

📥 Commits

Reviewing files that changed from the base of the PR and between b5ac3eb and fc4c40b.

📒 Files selected for processing (2)
  • .github/workflows/release.yml
  • packages/desktop/src/main.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/release-smoke-fixed-port

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@shomatan shomatan merged commit 501f8aa into main May 13, 2026
2 checks passed
@shomatan shomatan deleted the feat/release-smoke-fixed-port branch May 13, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant