Skip to content

Create test-aoai-response.yml #1

Create test-aoai-response.yml

Create test-aoai-response.yml #1

name: Test AOAI Responses API
on:
workflow_dispatch:
jobs:
response-test:
name: Run & validate responses-basic-aoai-v1.py
runs-on: ubuntu-latest
environment: responses
steps:
- name: ⬇️ Check out repo
uses: actions/checkout@v4
- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: 📦 Install dependencies
run: |
python -m pip install --upgrade pip
pip install openai python-dotenv
# ───────────── CORE TEST STEP ─────────────
- name: 🧪 Run script & build report
id: test
env:
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_V1_API_ENDPOINT: ${{ secrets.AZURE_OPENAI_V1_API_ENDPOINT }}
AZURE_OPENAI_API_MODEL: ${{ secrets.AZURE_OPENAI_API_MODEL }}
run: |
python - <<'PY'
import datetime, json, os, subprocess, sys, textwrap, shlex, pathlib

Check failure on line 35 in .github/workflows/test-aoai-response.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/test-aoai-response.yml

Invalid workflow file

You have an error in your yaml syntax on line 35
# Execute the existing script and capture its stdout / exit code
proc = subprocess.run(
[sys.executable, "responses-basic-aoai-v1.py"],
capture_output=True, text=True
)
output = proc.stdout.strip()
error_code = proc.returncode
passed = bool(output) and error_code == 0 # tweak this test however you like
result = {
"run_timestamp_utc": datetime.datetime.utcnow().isoformat(timespec="seconds") + "Z",
"output": output,
"pass": passed,
"error_code": error_code,
}
path = pathlib.Path("aoai_test_result.json")
path.write_text(json.dumps(result, indent=2), encoding="utf-8")
# Surface the “pass” status to later steps
print(f"pass={passed}", file=sys.stderr)
# Exit non‑zero only if you want the job to fail on an invalid response:
if not passed:
sys.exit(error_code or 1)
PY
# ───────────── UPLOAD REPORT ─────────────
- name: 📤 Upload test artifact
if: always() # run even if the previous step failed
uses: actions/upload-artifact@v4
with:
name: aoai-response-test
path: aoai_test_result.json