steps:
- label: ":qodex: smoke"
key: qodex-smoke
timeout_in_minutes: 30
plugins:
- docker#v5.11.0:
image: alpine:3.20
environment:
- QODEX_API_KEY
- QODEX_PROJECT
command:
- sh
- -lc
- |
apk add --no-cache curl jq
ENV_NAME=staging
if [ "$$BUILDKITE_BRANCH" = "main" ]; then ENV_NAME=prod; fi
RESPONSE=$$(curl -fsS -X POST \
"https://agents.qodex.ai/api/projects/$$QODEX_PROJECT/webhooks/trigger" \
-H "Authorization: Bearer $$QODEX_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"environment\":\"$$ENV_NAME\",\"tags\":[\"smoke\"]}")
RUN_ID=$$(echo "$$RESPONSE" | jq -r .testRunId)
if [ -z "$$RUN_ID" ] || [ "$$RUN_ID" = "null" ]; then
echo "Failed to start run. Response: $$RESPONSE"
exit 1
fi
DEADLINE=$$(( $$(date +%s) + 1500 ))
while [ "$$(date +%s)" -lt "$$DEADLINE" ]; do
STATUS=$$(curl -fsS \
"https://agents.qodex.ai/api/projects/$$QODEX_PROJECT/test-runs/$$RUN_ID" \
-H "Authorization: Bearer $$QODEX_API_KEY" | jq -r .status)
echo "status=$$STATUS"
case "$$STATUS" in
completed) exit 0 ;;
failed) exit 1 ;;
*) sleep 10 ;;
esac
done
echo "Timed out waiting for Qodex run $$RUN_ID"
exit 1