Skip to content

Commit 61842d8

Browse files
committed
fixup! ci(storyboard): extract reusable harness script for seller_agent.py storyboard
Fix two pre-PR blockers: - Resolve repo root from BASH_SOURCE[0] and cd into it so the script works from any caller directory (cross-repo callers don't need to cd first) - Track _TMPFILE in _cleanup so it is always removed on exit, not leaked Also simplify the storyboard run step: always write to a file first, then print to stdout if STORYBOARD_RESULT_PATH is unset, eliminating the tee+pipe ambiguity noted in review. https://claude.ai/code/session_01BdEqT6X8riNXLLCZUxUTMx
1 parent c30b372 commit 61842d8

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

scripts/ci/run_storyboard_reference_seller.sh

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@
1414
# ADCP_PORT Port for the seller agent (default: 3001)
1515
# STORYBOARD_RESULT_PATH Path for JSON result output; omit to write to stdout
1616
#
17-
# Run from the root of an adcp-client-python checkout.
17+
# Works from any working directory: the script resolves the repo root from
18+
# its own location (scripts/ci/) and changes into it before running.
1819
# Node.js (npm + adcp binary) and Python must be on PATH.
1920

2021
set -euo pipefail
2122

23+
# Resolve repo root and change into it so all relative paths work regardless
24+
# of the caller's working directory.
25+
_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26+
_REPO_ROOT="$(cd "${_SCRIPT_DIR}/../.." && pwd)"
27+
cd "${_REPO_ROOT}"
28+
2229
# --- Validate inputs ---
2330

2431
if [[ -z "${ADCP_SDK_VERSION:-}" && -z "${ADCP_SDK_TARBALL:-}" ]]; then
@@ -62,16 +69,18 @@ adcp --version
6269
# --- Install Python deps in an isolated venv ---
6370
# Uses the base package only — seller_agent.py does not need dev extras.
6471

65-
VENV_DIR=".ci-venv"
72+
VENV_DIR="${_REPO_ROOT}/.ci-venv"
6673
python -m venv "${VENV_DIR}"
6774
"${VENV_DIR}/bin/pip" install --quiet --upgrade pip
6875
"${VENV_DIR}/bin/pip" install --quiet -e .
6976

7077
# --- Boot seller agent with guaranteed cleanup on exit ---
7178

7279
AGENT_PID=""
80+
_TMPFILE=""
7381
_cleanup() {
7482
[[ -n "${AGENT_PID}" ]] && kill "${AGENT_PID}" 2>/dev/null || true
83+
[[ -n "${_TMPFILE}" ]] && rm -f "${_TMPFILE}" || true
7584
}
7685
trap _cleanup EXIT
7786

@@ -100,23 +109,24 @@ for i in $(seq 1 60); do
100109
done
101110

102111
# --- Run storyboard ---
112+
# Always write to a file so the assertion step can read it regardless of
113+
# whether STORYBOARD_RESULT_PATH is set. When unset, print to stdout after.
103114

104115
_RESULT_DEST="${STORYBOARD_RESULT_PATH:-}"
105116
if [[ -n "${_RESULT_DEST}" ]]; then
106-
adcp storyboard run \
107-
"http://127.0.0.1:${ADCP_PORT}/mcp" media_buy_seller \
108-
--json --allow-http \
109-
> "${_RESULT_DEST}"
110117
_ASSERT_FILE="${_RESULT_DEST}"
111118
else
112119
_TMPFILE="$(mktemp)"
113-
adcp storyboard run \
114-
"http://127.0.0.1:${ADCP_PORT}/mcp" media_buy_seller \
115-
--json --allow-http \
116-
| tee "${_TMPFILE}"
117120
_ASSERT_FILE="${_TMPFILE}"
118121
fi
119122

123+
adcp storyboard run \
124+
"http://127.0.0.1:${ADCP_PORT}/mcp" media_buy_seller \
125+
--json --allow-http \
126+
> "${_ASSERT_FILE}"
127+
128+
[[ -z "${_RESULT_DEST}" ]] && cat "${_ASSERT_FILE}"
129+
120130
# --- Assert result ---
121131

122132
"${VENV_DIR}/bin/python" - "${_ASSERT_FILE}" <<'PYEOF'

0 commit comments

Comments
 (0)