11name : Test Azure OpenAI response
22
33on :
4- workflow_dispatch :
4+ workflow_dispatch : # run only when you click “Run workflow”
55
66jobs :
77 response-test :
8- name : Run & validate responses-basic-aoai-v1.py
98 runs-on : ubuntu-latest
10- environment : responses
9+ environment : responses # pulls in the secrets already in that env
1110
1211 steps :
1312 - name : ⬇️ Check out repo
@@ -26,25 +25,26 @@ jobs:
2625 # ───────────── CORE TEST STEP ─────────────
2726 - name : 🧪 Run script & build report
2827 id : test
28+ shell : python # <<< everything below is pure Python
2929 env :
3030 AZURE_OPENAI_API_KEY : ${{ secrets.AZURE_OPENAI_API_KEY }}
3131 AZURE_OPENAI_V1_API_ENDPOINT : ${{ secrets.AZURE_OPENAI_V1_API_ENDPOINT }}
3232 AZURE_OPENAI_API_MODEL : ${{ secrets.AZURE_OPENAI_API_MODEL }}
3333 run : |
34- python - <<'PY'
35- import datetime, json, os, subprocess, sys, pathlib
34+ import datetime, json, pathlib, subprocess, sys
3635
37- # Execute the existing script and capture its stdout / exit code
36+ # run the existing file and capture its stdout / exit code
3837 proc = subprocess.run(
3938 [sys.executable, "responses-basic-aoai-v1.py"],
4039 capture_output=True, text=True
4140 )
42- output = proc.stdout.strip()
43- error_code = proc.returncode
44- passed = bool(output) and error_code == 0 # tweak this test however you like
41+ output = proc.stdout.strip()
42+ error_code = proc.returncode
43+ passed = bool(output) and error_code == 0 # tweak if you need stricter logic
4544
4645 result = {
47- "run_timestamp_utc": datetime.datetime.utcnow().isoformat(timespec="seconds") + "Z",
46+ "run_timestamp_utc": datetime.datetime.utcnow()
47+ .isoformat(timespec="seconds") + "Z",
4848 "output": output,
4949 "pass": passed,
5050 "error_code": error_code,
@@ -54,14 +54,13 @@ jobs:
5454 json.dumps(result, indent=2), encoding="utf-8"
5555 )
5656
57- # Exit non‑zero if the test failed so the job goes red
57+ # Fail the job if the test failed
5858 if not passed:
5959 sys.exit(error_code or 1)
60- PY
6160
6261 # ───────────── UPLOAD REPORT ─────────────
6362 - name : 📤 Upload test artifact
64- if : always() # run even if the previous step failed
63+ if : always() # still run even if the step above failed
6564 uses : actions/upload-artifact@v4
6665 with :
6766 name : aoai-response-test
0 commit comments