|
14 | 14 | # ADCP_PORT Port for the seller agent (default: 3001) |
15 | 15 | # STORYBOARD_RESULT_PATH Path for JSON result output; omit to write to stdout |
16 | 16 | # |
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. |
18 | 19 | # Node.js (npm + adcp binary) and Python must be on PATH. |
19 | 20 |
|
20 | 21 | set -euo pipefail |
21 | 22 |
|
| 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 | + |
22 | 29 | # --- Validate inputs --- |
23 | 30 |
|
24 | 31 | if [[ -z "${ADCP_SDK_VERSION:-}" && -z "${ADCP_SDK_TARBALL:-}" ]]; then |
@@ -62,16 +69,18 @@ adcp --version |
62 | 69 | # --- Install Python deps in an isolated venv --- |
63 | 70 | # Uses the base package only — seller_agent.py does not need dev extras. |
64 | 71 |
|
65 | | -VENV_DIR=".ci-venv" |
| 72 | +VENV_DIR="${_REPO_ROOT}/.ci-venv" |
66 | 73 | python -m venv "${VENV_DIR}" |
67 | 74 | "${VENV_DIR}/bin/pip" install --quiet --upgrade pip |
68 | 75 | "${VENV_DIR}/bin/pip" install --quiet -e . |
69 | 76 |
|
70 | 77 | # --- Boot seller agent with guaranteed cleanup on exit --- |
71 | 78 |
|
72 | 79 | AGENT_PID="" |
| 80 | +_TMPFILE="" |
73 | 81 | _cleanup() { |
74 | 82 | [[ -n "${AGENT_PID}" ]] && kill "${AGENT_PID}" 2>/dev/null || true |
| 83 | + [[ -n "${_TMPFILE}" ]] && rm -f "${_TMPFILE}" || true |
75 | 84 | } |
76 | 85 | trap _cleanup EXIT |
77 | 86 |
|
@@ -100,23 +109,24 @@ for i in $(seq 1 60); do |
100 | 109 | done |
101 | 110 |
|
102 | 111 | # --- 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. |
103 | 114 |
|
104 | 115 | _RESULT_DEST="${STORYBOARD_RESULT_PATH:-}" |
105 | 116 | 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}" |
110 | 117 | _ASSERT_FILE="${_RESULT_DEST}" |
111 | 118 | else |
112 | 119 | _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}" |
117 | 120 | _ASSERT_FILE="${_TMPFILE}" |
118 | 121 | fi |
119 | 122 |
|
| 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 | + |
120 | 130 | # --- Assert result --- |
121 | 131 |
|
122 | 132 | "${VENV_DIR}/bin/python" - "${_ASSERT_FILE}" <<'PYEOF' |
|
0 commit comments