Skip to content

Commit

Permalink
Removed debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
mandeepnh5 committed Dec 31, 2024
1 parent 62822f6 commit 9f3896a
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions .github/workflows/scripts/validate-coderabbit.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
#!/bin/bash

Check warning on line 1 in .github/workflows/scripts/validate-coderabbit.sh

View workflow job for this annotation

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
echo "Step 1: Fetching all PR reviews with pagination..."

all_reviews="[]"
echo "Step 1: Fetching all PR reviews..."


echo "Fetching page..."
response=$(curl -s -f -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews?per_page=1000") || {
echo "Error: Failed to fetch reviews from GitHub API"
exit 1
}


all_reviews=$(echo "$all_reviews" "$response" | jq -s 'add')

echo "Debug: Combined reviews from all pages:"
echo "$all_reviews" | jq '.'

reviews="$all_reviews"

echo "Step 2: Parsing the latest review by each user..."
latest_reviews=$(echo "$reviews" | jq -c '[.[]] | group_by(.user.login) | map(max_by(.submitted_at))') || {
latest_reviews=$(echo "$response" | jq -c '[.[]] | group_by(.user.login) | map(max_by(.submitted_at))') || {
echo "Error: Failed to process reviews JSON"
exit 1
}
Expand All @@ -30,17 +18,9 @@ if [ "$latest_reviews" = "null" ] || [ -z "$latest_reviews" ]; then
exit 1
fi

echo "Debug: Grouped latest reviews:"
echo "$latest_reviews" | jq '.'

echo "Step 3: Printing all latest review user logins and states:"
echo "$latest_reviews" | jq -r '.[] | "User: \(.user.login), State: \(.state)"'

echo "Step 4: Checking approval status of 'coderabbitai[bot]'..."
echo "Step 2: Checking approval status of 'coderabbitai[bot]'..."
approval_state=$(echo "$latest_reviews" | jq -r '[.[] | select(.user.login == "coderabbitai[bot]" and .state == "APPROVED")] | length')

echo "Approval count for CodeRabbit.ai: $approval_state"

if [[ "$approval_state" =~ ^[0-9]+$ ]] && [[ $approval_state -gt 0 ]]; then
echo "Success: PR approved by CodeRabbit.ai."
else
Expand Down

0 comments on commit 9f3896a

Please sign in to comment.