|
| 1 | +name: Test AOAI Responses API |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + response-test: |
| 8 | + name: Run & validate responses-basic-aoai-v1.py |
| 9 | + runs-on: ubuntu-latest |
| 10 | + environment: responses |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: ⬇️ Check out repo |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: 🐍 Set up Python |
| 17 | + uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: '3.11' |
| 20 | + |
| 21 | + - name: 📦 Install dependencies |
| 22 | + run: | |
| 23 | + python -m pip install --upgrade pip |
| 24 | + pip install openai python-dotenv |
| 25 | +
|
| 26 | + # ───────────── CORE TEST STEP ───────────── |
| 27 | + - name: 🧪 Run script & build report |
| 28 | + id: test |
| 29 | + env: |
| 30 | + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} |
| 31 | + AZURE_OPENAI_V1_API_ENDPOINT: ${{ secrets.AZURE_OPENAI_V1_API_ENDPOINT }} |
| 32 | + AZURE_OPENAI_API_MODEL: ${{ secrets.AZURE_OPENAI_API_MODEL }} |
| 33 | + run: | |
| 34 | + python - <<'PY' |
| 35 | +import datetime, json, os, subprocess, sys, textwrap, shlex, pathlib |
| 36 | + |
| 37 | +# Execute the existing script and capture its stdout / exit code |
| 38 | +proc = subprocess.run( |
| 39 | + [sys.executable, "responses-basic-aoai-v1.py"], |
| 40 | + capture_output=True, text=True |
| 41 | +) |
| 42 | +output = proc.stdout.strip() |
| 43 | +error_code = proc.returncode |
| 44 | +passed = bool(output) and error_code == 0 # tweak this test however you like |
| 45 | + |
| 46 | +result = { |
| 47 | + "run_timestamp_utc": datetime.datetime.utcnow().isoformat(timespec="seconds") + "Z", |
| 48 | + "output": output, |
| 49 | + "pass": passed, |
| 50 | + "error_code": error_code, |
| 51 | +} |
| 52 | + |
| 53 | +path = pathlib.Path("aoai_test_result.json") |
| 54 | +path.write_text(json.dumps(result, indent=2), encoding="utf-8") |
| 55 | + |
| 56 | +# Surface the “pass” status to later steps |
| 57 | +print(f"pass={passed}", file=sys.stderr) |
| 58 | +# Exit non‑zero only if you want the job to fail on an invalid response: |
| 59 | +if not passed: |
| 60 | + sys.exit(error_code or 1) |
| 61 | +PY |
| 62 | + |
| 63 | + # ───────────── UPLOAD REPORT ───────────── |
| 64 | + - name: 📤 Upload test artifact |
| 65 | + if: always() # run even if the previous step failed |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: aoai-response-test |
| 69 | + path: aoai_test_result.json |
0 commit comments