ci(smoke): add options to use OPENAI_API_KEY + model for live request; keep default parse-only mode

This commit is contained in:
James Peter
2025-09-05 19:15:06 +10:00
parent b0baa3bd3d
commit 3906ba74c3
+38 -4
View File
@@ -7,6 +7,15 @@ on:
description: "Additional flags to pass to 'code exec' (optional)"
default: ""
required: false
use_api:
description: "Use OPENAI_API_KEY secret (true = real API call)"
type: boolean
default: false
required: false
model:
description: "Model when use_api=true (e.g., gpt-4o-mini)"
default: "gpt-4o-mini"
required: false
permissions:
contents: read
@@ -34,18 +43,37 @@ jobs:
- name: Parse-only dry run with redirection (published package)
shell: bash
env:
# Intentionally blank: we only validate argument parsing, not a full model run
OPENAI_API_KEY: ""
run: |
set -euo pipefail
if [ "${{ github.event.inputs.use_api }}" = "true" ]; then
if [ -n "${{ secrets.OPENAI_API_KEY }}" ]; then
echo "Using OPENAI_API_KEY secret for live request" >&2
export OPENAI_API_KEY='${{ secrets.OPENAI_API_KEY }}'
MODEL_FLAG=( -m '${{ github.event.inputs.model }}' )
else
echo "use_api=true but no OPENAI_API_KEY secret configured; failing." >&2
exit 1
fi
else
# Intentionally blank: parse-only path
export OPENAI_API_KEY=""
MODEL_FLAG=()
fi
# We expect this to exit non-zero due to missing API key, but only AFTER clap parses args.
# So we treat any exit as success as long as stderr DOES NOT contain an arg‑parse error.
set +e
out=$(mktemp)
err=$(mktemp)
printf 'This is a smoke test for release notes generation.\n' | \
npx -y @just-every/code@latest exec --cd "$GITHUB_WORKSPACE" --full-auto --skip-git-repo-check ${{ github.event.inputs.extra_flags }} - \
npx -y @just-every/code@latest exec \
--cd "$GITHUB_WORKSPACE" \
--full-auto \
--skip-git-repo-check \
-c model_providers.openai.request_max_retries=0 \
-c model_providers.openai.stream_max_retries=0 \
-c model_providers.openai.stream_idle_timeout_ms=1 \
"${MODEL_FLAG[@]}" \
${{ github.event.inputs.extra_flags }} - \
> "$out" 2> "$err"
status=$?
set -e
@@ -54,6 +82,12 @@ jobs:
cat "$err" >&2
exit 1
fi
if [ "${{ github.event.inputs.use_api }}" = "true" ]; then
if grep -qiE "unauthorized|invalid api key|exceeded retry limit" "$err"; then
echo "Live API call failed (see stderr above)" >&2
exit 1
fi
fi
echo "CLI parsed arguments successfully (exit=$status)."
echo "stderr (first lines):"
sed -n '1,40p' "$err" || true