ci: clarify 401 connectivity, add retry, skip merge-push review
All checks were successful
CodeAnt AI Review - Stage 1 / codeant-review (push) Successful in 2m9s

This commit is contained in:
WDI-Ideas
2026-03-30 03:16:09 +05:30
parent bc80675ddd
commit 64f313e9d0

View File

@@ -44,12 +44,28 @@ jobs:
echo "CLI version: $(codeant --version)" echo "CLI version: $(codeant --version)"
echo "=== API connectivity test ===" echo "=== API connectivity test ==="
HTTP_CODE=$(curl -s -o /tmp/api_response.txt -w "%{http_code}" \ HTTP_CODE=$(curl -sS -D /tmp/api_headers.txt -o /tmp/api_response.txt -w "%{http_code}" \
-H "Authorization: Bearer ${CODEANT_API_KEY:-}" \ -H "Authorization: Bearer ${CODEANT_API_KEY:-}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
https://service.codeant.ai/health 2>/dev/null || echo "CURL_FAILED") https://service.codeant.ai/health 2>/dev/null || echo "CURL_FAILED")
echo "HTTP status: $HTTP_CODE" echo "HTTP status: $HTTP_CODE"
echo "--- Response headers (first 20 lines) ---"
sed -n '1,20p' /tmp/api_headers.txt || true
echo "--- Response body (first 200 chars) ---"
head -c 200 /tmp/api_response.txt || true head -c 200 /tmp/api_response.txt || true
echo
if [ "$HTTP_CODE" = "200" ]; then
echo "Connectivity OK and endpoint accepted request."
elif [ "$HTTP_CODE" = "401" ]; then
echo "Connectivity OK (service reachable), but endpoint returned 401 Unauthorized."
echo "This usually means token/auth format for this endpoint is not accepted."
elif [ "$HTTP_CODE" = "CURL_FAILED" ]; then
echo "Connectivity FAILED (curl could not reach service.codeant.ai)."
exit 1
else
echo "Connectivity reached service but got unexpected status: $HTTP_CODE"
fi
env: env:
CODEANT_API_KEY: ${{ secrets.CODEANT_API_TOKEN }} CODEANT_API_KEY: ${{ secrets.CODEANT_API_TOKEN }}
@@ -66,28 +82,42 @@ jobs:
echo "==== FILES IN LAST COMMIT ====" echo "==== FILES IN LAST COMMIT ===="
git show --name-only --pretty="" HEAD git show --name-only --pretty="" HEAD
echo "==== IS MERGE COMMIT ====" echo "==== IS MERGE COMMIT ===="
PARENTS=$(git log -1 --format="%P" HEAD | wc -w) PARENTS=$(git log -1 --format="%P" HEAD | wc -w)
echo "Parent count: $PARENTS" echo "Parent count: $PARENTS"
if [ "$PARENTS" -gt 1 ]; then if [ "$PARENTS" -gt 1 ]; then
echo "HEAD is a merge commit" echo "HEAD is a merge commit"
git log --oneline HEAD~1..HEAD --first-parent || true git log --oneline HEAD~1..HEAD --first-parent || true
fi fi
- name: Run CodeAnt Review - name: Run CodeAnt Review
run: | run: |
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ] && [ -n "${GITHUB_BASE_REF}" ]; then if [ "${GITHUB_EVENT_NAME}" = "pull_request" ] && [ -n "${GITHUB_BASE_REF}" ]; then
echo "Running PR review against base branch: ${GITHUB_BASE_REF}" echo "Running PR review against base branch: ${GITHUB_BASE_REF}"
codeant review --base "${GITHUB_BASE_REF}" 2>&1 | tee review.txt || true for attempt in 1 2 3; do
echo "PR review attempt $attempt/3"
codeant review --base "${GITHUB_BASE_REF}" 2>&1 | tee review.txt || true
if ! grep -q "Unexpected token '<'" review.txt; then
break
fi
sleep $((attempt * 15))
done
else else
# For push to main: check if HEAD is a merge commit # For push to main: check if HEAD is a merge commit
PARENTS=$(git log -1 --format="%P" HEAD | wc -w) PARENTS=$(git log -1 --format="%P" HEAD | wc -w)
if [ "$PARENTS" -gt 1 ]; then if [ "$PARENTS" -gt 1 ]; then
# Merge commit: review everything brought in by the merge (HEAD vs first parent) # Merge commits often include very large diffs and are already reviewed on pull_request.
echo "Merge commit detected - reviewing changes vs HEAD~1" echo "Merge commit detected on push; skipping review here."
codeant review --base-commit HEAD~1 2>&1 | tee review.txt || true echo "PR workflow run is the source of truth for full review." | tee review.txt
else else
echo "Regular push - reviewing last commit" echo "Regular push - reviewing last commit"
codeant review --last-commit 2>&1 | tee review.txt || true for attempt in 1 2 3; do
echo "Push review attempt $attempt/3"
codeant review --last-commit 2>&1 | tee review.txt || true
if ! grep -q "Unexpected token '<'" review.txt; then
break
fi
sleep $((attempt * 15))
done
fi fi
fi fi