Skip to content

Fixed Coderabbit Validation Check #3361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
142 changes: 74 additions & 68 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ jobs:
run: |
python .github/workflows/scripts/biome_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}


- name: Run Code Coverage Disable Check
run: |
python .github/workflows/scripts/code_coverage_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
Expand Down Expand Up @@ -116,75 +115,82 @@ jobs:
needs: [Code-Quality-Checks]
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- id: changed_files
name: Get changed files
uses: tj-actions/[email protected]
with:
files: |
.coderabbit.yaml
Caddyfile
codegen.ts
Dockerfile*
docker-compose*
drizzle_migrations/**
.dockerignore
.env.sample
.env_test
eslint.config.mjs
envFiles/**
.gitignore
init-mongo.sh
.prettierignore
.prettierrc.json
.pylintrc
.github/**
biome.jsonc
drizzle_migrations/**
renovate.json
requirements.txt
schema.graphql
CODEOWNERS
LICENSE
tsconfig.json
vitest.config.ts
pnpm-lock.yaml
package.json
package-lock.json
.nojekyll
docs/docusaurus.config.ts
docs/sidebar*
setup.ts
src/graphql/types/Mutation/**
src/graphql/types/Query/**
tsconfig.build.json
vite.config.mts
CNAME
CODE_OF_CONDUCT.md
CODE_STYLE.md
CONTRIBUTING.md
DOCUMENTATION.md
INSTALLATION.md
ISSUE_GUIDELINES.md
PR_GUIDELINES.md
README.md
- env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
if: steps.changed_files.outputs.any_changed == 'true' || steps.changed_files.outputs.any_deleted == 'true'
name: Show changed files
run: |
echo "Unauthorized changes were made in the following files:"
for FILE in ${CHANGED_FILES}; do
echo "$FILE"
done
echo "To override this, apply the 'ignore-sensitive-files-pr' label"
exit 1
- name: Checkout this repository
uses: actions/[email protected]
- id: changed_files
name: Get changed files
uses: tj-actions/[email protected]
with:
files: |
.coderabbit.yaml
Caddyfile
codegen.ts
Dockerfile*
docker-compose*
drizzle_migrations/**
.dockerignore
.env.sample
.env_test
eslint.config.mjs
envFiles/**
.gitignore
init-mongo.sh
.prettierignore
.prettierrc.json
.pylintrc
.github/**
biome.jsonc
drizzle_migrations/**
renovate.json
requirements.txt
schema.graphql
CODEOWNERS
LICENSE
tsconfig.json
vitest.config.ts
pnpm-lock.yaml
package.json
package-lock.json
.nojekyll
docs/docusaurus.config.ts
docs/sidebar*
setup.ts
src/graphql/types/Mutation/**
src/graphql/types/Query/**
tsconfig.build.json
vite.config.mts
CNAME
CODE_OF_CONDUCT.md
CODE_STYLE.md
CONTRIBUTING.md
DOCUMENTATION.md
INSTALLATION.md
ISSUE_GUIDELINES.md
PR_GUIDELINES.md
README.md
- env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
if: steps.changed_files.outputs.any_changed == 'true' || steps.changed_files.outputs.any_deleted == 'true'
name: Show changed files
run: |
echo "Unauthorized changes were made in the following files:"
for FILE in ${CHANGED_FILES}; do
echo "$FILE"
done
echo "To override this, apply the 'ignore-sensitive-files-pr' label"
exit 1

Run-Tests:
name: Run tests for talawa api
runs-on: ubuntu-latest
needs: [Code-Quality-Checks, python_checks, check_type_errors, check_drizzle_migrations, check_gql_tada]
needs:
[
Code-Quality-Checks,
python_checks,
check_type_errors,
check_drizzle_migrations,
check_gql_tada,
]
env:
CODECOV_UNIQUE_NAME: ${{github.workflow}}-${{github.ref_name}}
steps:
Expand Down Expand Up @@ -252,6 +258,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}

Python-Compliance:
name: Check Python Code Style
Expand Down Expand Up @@ -303,7 +310,6 @@ jobs:
source venv/bin/activate
python .github/workflows/scripts/check_docstrings.py --directories .github


# Import-Sample-Data:
# name: Import Sample Data
# runs-on: ubuntu-latest
Expand Down
97 changes: 70 additions & 27 deletions .github/workflows/scripts/validate-coderabbit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,80 @@

echo "Step 1: Fetching all PR reviews..."

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
}
check_approval() {

latest_reviews=$(echo "$response" | jq -c '[.[]] | group_by(.user.login) | map(max_by(.submitted_at))') || {
echo "Error: Failed to process reviews JSON"
exit 1
}
echo "Debug: PR_NUMBER=$PR_NUMBER"
echo "Debug: GITHUB_REPOSITORY=$GITHUB_REPOSITORY"
echo "Debug: GITHUB_SHA=$GITHUB_SHA"
echo ""

if [ "$latest_reviews" = "null" ] || [ -z "$latest_reviews" ]; then
echo "Error: Invalid reviews data"
exit 1
fi

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')
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
}

if [[ "$approval_state" =~ ^[0-9]+$ ]] && [[ $approval_state -gt 0 ]]; then
echo "Success: PR approved by CodeRabbit.ai."
else
echo "Debug: Raw API response from GitHub:"
echo "$response"
echo ""
echo "ERROR:"

latest_reviews=$(echo "$response" | jq -c '[.[]]')

if [ "$latest_reviews" = "null" ] || [ -z "$latest_reviews" ]; then
echo "Error: Invalid reviews data"
exit 1
fi

echo "Debug: Latest reviews JSON:"
echo "$latest_reviews"
echo ""
echo "1) This PR is not approved by CodeRabbit.ai."
echo "2) In the 'Add a comment' section at the bottom"
echo " of the PR web page, add a comment with the"
echo " statement below to restart a review"

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 "Debug: Found $approval_state approvals from 'coderabbitai[bot]' for commit ID $GITHUB_SHA."
echo ""
echo " @coderabbitai full review"
echo ""
exit 1
fi

# If approval_state is > 0, we have at least one matching approval
if [[ "$approval_state" =~ ^[0-9]+$ ]] && [[ $approval_state -gt 0 ]]; then
echo "Success: PR approved by CodeRabbit.ai for commit $GITHUB_SHA."
return 0
else
return 1
fi
}

# Number of times to retry and how many seconds to wait between retries
MAX_RETRIES=10
RETRY_DELAY=30
attempt=1

while [ $attempt -le $MAX_RETRIES ]; do
if check_approval; then
break
fi

if [ $attempt -eq $MAX_RETRIES ]; then
echo "ERROR: Approval not found for commit $GITHUB_SHA after $attempt attempts."
echo ""
echo "1) This PR is not approved by CodeRabbit.ai for the latest commit."
echo "2) If you need to re-trigger CodeRabbit.ai, comment the following on the PR:"
echo ""
echo " @coderabbitai full review"
echo ""
exit 1
fi

echo "Attempt $attempt failed, retrying in $RETRY_DELAY seconds..."
sleep $RETRY_DELAY
attempt=$((attempt + 1))
done

echo "Step 3: PR approved by CodeRabbit.ai. Proceeding with the workflow..."
exit 0

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

> **createServer**(`options`?): `Promise`\<`FastifyInstance`\<`Server`\<*typeof* `IncomingMessage`, *typeof* `ServerResponse`\>, `IncomingMessage`, `ServerResponse`\<`IncomingMessage`\>, `FastifyBaseLogger`, `TypeBoxTypeProvider`\>\>

Defined in: src/createServer.ts:29
Defined in: [src/createServer.ts:29](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/createServer.ts#L29)

This function is used to set up the fastify server.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **advertisementAttachmentMimeTypeEnum**: `ZodEnum`\<\[`"image/avif"`, `"image/jpeg"`, `"image/png"`, `"image/webp"`, `"video/mp4"`, `"video/webm"`\]\>

Defined in: src/drizzle/enums/advertisementAttachmentMimeType.ts:8
Defined in: [src/drizzle/enums/advertisementAttachmentMimeType.ts:8](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/advertisementAttachmentMimeType.ts#L8)

Possible variants of the type of an attachement of an advertisement.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **advertisementTypeEnum**: `ZodEnum`\<\[`"banner"`, `"menu"`, `"pop_up"`\]\>

Defined in: src/drizzle/enums/advertisementType.ts:6
Defined in: [src/drizzle/enums/advertisementType.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/advertisementType.ts#L6)

Possible variants of the type of an advertisement.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **agendaItemTypeEnum**: `ZodEnum`\<\[`"general"`, `"note"`, `"scripture"`, `"song"`\]\>

Defined in: src/drizzle/enums/agendaItemType.ts:6
Defined in: [src/drizzle/enums/agendaItemType.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/agendaItemType.ts#L6)

Possible variants of the type of an agenda item.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **chatMembershipRoleEnum**: `ZodEnum`\<\[`"administrator"`, `"regular"`\]\>

Defined in: src/drizzle/enums/chatMembershipRole.ts:6
Defined in: [src/drizzle/enums/chatMembershipRole.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/chatMembershipRole.ts#L6)

Possible variants of the role assigned to a user within a chat.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **commentVoteTypeEnum**: `ZodEnum`\<\[`"down_vote"`, `"up_vote"`\]\>

Defined in: src/drizzle/enums/commentVoteType.ts:6
Defined in: [src/drizzle/enums/commentVoteType.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/commentVoteType.ts#L6)

Possible variants of the type of of a vote on a comment.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **eventAttachmentMimeTypeEnum**: `ZodEnum`\<\[`"image/avif"`, `"image/jpeg"`, `"image/png"`, `"image/webp"`, `"video/mp4"`, `"video/webm"`\]\>

Defined in: src/drizzle/enums/eventAttachmentMimeType.ts:8
Defined in: [src/drizzle/enums/eventAttachmentMimeType.ts:8](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/eventAttachmentMimeType.ts#L8)

Possible variants of the type of an attachement of an event.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **familyMembershipRoleEnum**: `ZodEnum`\<\[`"adult"`, `"child"`, `"head_of_household"`, `"spouse"`\]\>

Defined in: src/drizzle/enums/familyMembershipRole.ts:6
Defined in: [src/drizzle/enums/familyMembershipRole.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/familyMembershipRole.ts#L6)

Possible variants of the role of a user in a family(if applicable).
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **imageMimeTypeEnum**: `ZodEnum`\<\[`"image/avif"`, `"image/jpeg"`, `"image/png"`, `"image/webp"`\]\>

Defined in: src/drizzle/enums/imageMimeType.ts:6
Defined in: [src/drizzle/enums/imageMimeType.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/imageMimeType.ts#L6)

Possible variants of the type of an image.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **iso3166Alpha2CountryCodeEnum**: `ZodEnum`\<\[`"ad"`, `"ae"`, `"af"`, `"ag"`, `"ai"`, `"al"`, `"am"`, `"ao"`, `"aq"`, `"ar"`, `"as"`, `"at"`, `"au"`, `"aw"`, `"ax"`, `"az"`, `"ba"`, `"bb"`, `"bd"`, `"be"`, `"bf"`, `"bg"`, `"bh"`, `"bi"`, `"bj"`, `"bl"`, `"bm"`, `"bn"`, `"bo"`\]\>

Defined in: src/drizzle/enums/iso3166Alpha2CountryCode.ts:6
Defined in: [src/drizzle/enums/iso3166Alpha2CountryCode.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/iso3166Alpha2CountryCode.ts#L6)

Possible variants of the two-letter country code defined in ISO 3166-1, part of the ISO 3166 standard published by the International Organization for Standardization (ISO), to represent countries, dependent territories, and special areas of geographical interest. More information at this link: [https://en.wikipedia.org/wiki/List\_of\_ISO\_3166\_country\_codes](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes).
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **iso4217CurrencyCodeEnum**: `ZodEnum`\<\[`"AED"`, `"AFN"`, `"ALL"`, `"AMD"`, `"ANG"`, `"AOA"`, `"ARS"`, `"AUD"`, `"AWG"`, `"AZN"`, `"BAM"`, `"BBD"`, `"BDT"`, `"BGN"`, `"BHD"`, `"BIF"`, `"BMD"`, `"BND"`, `"BOB"`, `"BOV"`, `"BRL"`, `"BSD"`, `"BTN"`, `"BWP"`, `"BYN"`\]\>

Defined in: src/drizzle/enums/iso4217CurrencyCode.ts:6
Defined in: [src/drizzle/enums/iso4217CurrencyCode.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/iso4217CurrencyCode.ts#L6)

Possible variants of the currency code defined in ISO 4217 standard published by the International Organization for Standardization (ISO) which defines alpha codes and numeric codes for the representation of currencies and provides information about the relationships between individual currencies and their minor units. More information at this link: [https://en.wikipedia.org/wiki/ISO\_4217#Active\_codes\_(list\_one)](https://en.wikipedia.org/wiki/ISO_4217#Active_codes_(list_one)).
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **iso639Set1LanguageCodeEnum**: `ZodEnum`\<\[`"aa"`, `"ab"`, `"ae"`, `"af"`, `"ak"`, `"am"`, `"an"`, `"ar"`, `"as"`, `"av"`, `"ay"`, `"az"`, `"ba"`, `"be"`, `"bg"`, `"bi"`, `"bm"`, `"bn"`, `"bo"`, `"br"`, `"bs"`, `"ca"`, `"ce"`, `"ch"`, `"co"`, `"cr"`, `"cs"`, `"cu"`, `"cv"`\]\>

Defined in: src/drizzle/enums/iso639Set1LanguageCode.ts:6
Defined in: [src/drizzle/enums/iso639Set1LanguageCode.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/iso639Set1LanguageCode.ts#L6)

Possible variants of the two-letter language code defined in ISO 639-1, part of the ISO 639 standard published by the International Organization for Standardization (ISO), to represent natural languages. More information at this link: [https://en.wikipedia.org/wiki/List\_of\_ISO\_639\_language\_codes](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes).
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **organizationMembershipRoleEnum**: `ZodEnum`\<\[`"administrator"`, `"regular"`\]\>

Defined in: src/drizzle/enums/organizationMembershipRole.ts:6
Defined in: [src/drizzle/enums/organizationMembershipRole.ts:6](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/organizationMembershipRole.ts#L6)

Possible variants of the role assigned to a user within an organization.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

> `const` **postAttachmentMimeTypeEnum**: `ZodEnum`\<\[`"image/avif"`, `"image/jpeg"`, `"image/png"`, `"image/webp"`, `"video/mp4"`, `"video/webm"`\]\>

Defined in: src/drizzle/enums/postAttachmentMimeType.ts:8
Defined in: [src/drizzle/enums/postAttachmentMimeType.ts:8](https://github.com/syedali237/talawa-api/blob/2d0d513d5268a339b8dac6b4711f8e71e79fc0e4/src/drizzle/enums/postAttachmentMimeType.ts#L8)

Possible variants of the type of an attachement of a post.
Loading
Loading