Skip to content

test: シナリオの setup.sh 失敗時に出力末尾を CI ログへ残す - #172

Merged
okash1n merged 1 commit into
mainfrom
test/scenario-setup-diagnostics
Sep 8, 2026
Merged

test: シナリオの setup.sh 失敗時に出力末尾を CI ログへ残す#172
okash1n merged 1 commit into
mainfrom
test/scenario-setup-diagnostics

Conversation

@okash1n

@okash1n okash1n commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

概要

シナリオテストは run_setup / run_setup_update の出力を >/dev/null 2>&1 で捨てているため、setup.sh が失敗しても CI ログには「(setup failed)」か、|| rc=$? のない呼び出しでは set -e による runner の無言中断しか残らず、原因を追えない。

macOS ジョブの先頭シナリオで 2026-09-06〜08 に 3 回起きた一過性失敗(#170 attempt 1 の update-no-changes (setup failed)#171update-merge 無言中断と update-no-changes (setup failed)。いずれも step 開始から約 20 秒で setup.sh が非ゼロ終了し、再実行では通る)がこの状態で、現状は再実行でしか回復できていない。

変更

  • tests/helpers.sh: runner の元 stdout を fd 3 に複製し、setup.sh の出力を一時ファイルへ取ってから stdout に再生する。非ゼロ終了時は末尾 _TEST_SETUP_LOG_TAIL 行(既定 20)を fd 3 へ出す。呼び出し側の fd 1/2 リダイレクトや $(...) 取り込みは影響を受けない(成功時の挙動は出力がストリーミングではなく完了後の一括再生になる点だけが変わる)
  • tests/unit/test-helpers-run-setup.sh: 偽の setup.sh で、失敗時の tail 出力(fd 3)、成功時の無出力、run_setup_update の引数と $(...) 取り込み出力に tail が混ざらないことを検証

確認

  • SCENARIO_GROUP=core bash tests/run-scenarios.sh(brew bash 5.3): 14 PASS / 1 SKIP(bash4-noninteractive-unavailable、Bash 4+ 環境の既定)
  • 新規単体テスト 3/3 PASS(単体実行)
  • shellcheck -S warning/bin/bash -n(Bash 3.2): 指摘 0
  • 他グループと unit-tests は CI で検証

補足

この PR 自体は失敗の原因を直すものではなく、次に同じ失敗が起きたときに setup.sh の出力末尾が CI ログに残るようにするもの。原因が特定でき次第、別 PR で対処する。

https://claude.ai/code/session_01C9mrbbXQgV9fJ8Zy5UoEYc

シナリオテストは run_setup / run_setup_update の出力を >/dev/null 2>&1 で
捨てているため、setup.sh が失敗しても CI ログには「(setup failed)」か、
`|| rc=$?` のない呼び出しでは set -e による runner の無言中断しか残らず、
原因を追えなかった。macOS ジョブの先頭シナリオで 2026-09-06〜08 に 3 回
起きた一過性失敗(約 20 秒で setup.sh が非ゼロ終了)がこの状態で、
再実行でしか回復できていない。

- tests/helpers.sh: runner の元 stdout を fd 3 に複製し、setup.sh の出力を
  一時ファイルへ取ってから stdout に再生する。非ゼロ終了時は末尾
  _TEST_SETUP_LOG_TAIL 行(既定 20)を fd 3 へ出す。呼び出し側の fd 1/2
  リダイレクトや `$(...)` 取り込みは影響を受けない
- tests/unit/test-helpers-run-setup.sh: 偽の setup.sh で失敗時の tail 出力、
  成功時の無出力、run_setup_update の引数と取り込み出力の不変を検証

ローカル確認: SCENARIO_GROUP=core 14 PASS / 1 SKIP(bash4 既定)、
新規単体テスト 3/3、shellcheck、/bin/bash -n

Claude-Session: https://claude.ai/code/session_01C9mrbbXQgV9fJ8Zy5UoEYc
Copilot AI lite review requested due to automatic review settings September 8, 2026 04:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T04:57:07.524729Z bdcb3e0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

set -euo pipefail 下で mktemp/tail 周りが失敗すると診断出力を残す前に runner 自体が中断し得るため、失敗時に確実に「原因追跡に必要な出力」が残るようガードを入れたいです。

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

シナリオテストが run_setup / run_setup_update の出力を捨てているため、setup.sh 失敗時に原因が CI ログから追えない問題を、失敗時のみ stdout とは別経路でログ末尾を残す形で診断可能にする PR です。

Changes:

  • run_setup / run_setup_update を、setup.sh の結合出力を一旦一時ファイルに収集→完了後に stdout へ再生する方式に変更
  • setup.sh が非ゼロ終了した場合、ログ末尾 _TEST_SETUP_LOG_TAIL 行を runner の元 stdout を指す fd 3 に出力する診断を追加
  • 上記の挙動(失敗時 tail が fd 3 に出る/成功時 fd 3 は無出力/呼び出し側の出力キャプチャに混ざらない)を unit test で検証
File summaries
File Description
tests/helpers.sh setup.sh 出力の収集・再生と、失敗時の fd 3 への tail 出力を追加して CI ログ診断性を向上
tests/unit/test-helpers-run-setup.sh run_setup / run_setup_update の新しい診断挙動を fake setup.sh で検証する unit test を追加
Review details

Suppressed comments (1)

tests/helpers.sh:130

  • log="$(mktemp)" and the tail | sed pipeline can fail under set -euo pipefail (e.g., mktemp failure or an unexpected tail error), which would terminate the runner and skip returning the original setup.sh exit code. It’s safer to guard mktemp and ensure the tail formatting can’t abort the test run.
_run_setup_logged() {
  local log rc=0
  log="$(mktemp)"
  bash "$PROJECT_DIR/setup.sh" "$@" >"$log" 2>&1 || rc=$?
  if [[ "$rc" -ne 0 ]]; then
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/helpers.sh
Comment on lines +120 to +121
_TEST_SETUP_LOG_TAIL="${_TEST_SETUP_LOG_TAIL:-20}"

@okash1n
okash1n merged commit 14d13bc into main Sep 8, 2026
12 checks passed
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.

2 participants