-
-
Notifications
You must be signed in to change notification settings - Fork 811
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
#2970:autodoc-generate #3151
#2970:autodoc-generate #3151
Conversation
WalkthroughThe pull request introduces changes to two configuration files: Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/pull-request.yml (2)
534-555
: Consider additional TypeDoc configuration options.The TypeDoc configuration is good, but consider adding these options for better documentation:
--validation.invalidLink true
: Ensures all documentation links are valid--validation.notExported true
: Warns about non-exported memberstypedoc \ --out docs/docs/auto-docs \ --plugin typedoc-plugin-markdown \ --theme markdown \ --tsconfig tsconfig.json \ --excludePrivate \ --excludeProtected \ --excludeExternals \ --hideGenerator \ --gitRevision ${{ github.head_ref }} \ --categorizeByGroup true \ --entryPointStrategy expand \ --entryPoints "src/**/*.ts" "src/**/*.tsx" \ --exclude "**/*.{test,spec,stories}.{ts,tsx}" \ --exclude "**/__tests__/**" \ --exclude "**/__mocks__/**" \ --exclude "**/node_modules/**" \ - --cleanOutputDir true + --cleanOutputDir true \ + --validation.invalidLink true \ + --validation.notExported true🧰 Tools
🪛 actionlint (1.7.4)
535-535: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details
(expression)
506-506
: Fix YAML formatting: Remove trailing spaces.There are trailing spaces on multiple lines that should be removed to comply with YAML best practices.
Also applies to: 560-560, 566-566, 572-572, 589-589, 592-592
🧰 Tools
🪛 yamllint (1.35.1)
[error] 506-506: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.eslintrc.json
(1 hunks).github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
535-535: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details
(expression)
582-582: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details
(expression)
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 506-506: trailing spaces
(trailing-spaces)
[error] 560-560: trailing spaces
(trailing-spaces)
[error] 566-566: trailing spaces
(trailing-spaces)
[error] 572-572: trailing spaces
(trailing-spaces)
[error] 589-589: trailing spaces
(trailing-spaces)
[error] 592-592: trailing spaces
(trailing-spaces)
🔇 Additional comments (2)
.eslintrc.json (1)
155-156
: LGTM! Appropriate addition to ignore patterns.The addition of "docs/docs/**" to ignorePatterns is correct as it prevents ESLint from linting auto-generated documentation files, which is a standard practice.
.github/workflows/pull-request.yml (1)
507-511
: LGTM! Well-structured job dependencies.The job dependencies are correctly configured to ensure documentation is generated only after all quality checks and tests pass.
.github/workflows/pull-request.yml
Outdated
- name: Setup Git Config | ||
run: | | ||
git config user.name "GitHub Actions Bot" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
|
||
- name: Check and Commit Documentation | ||
run: | | ||
# Check if there are any changes | ||
if [[ -n "$(git status --porcelain)" ]]; then | ||
# Add all changes | ||
git add docs/docs/auto-docs | ||
git add docs/docs/user-guide | ||
git add docs/docs/developer-guide | ||
|
||
# Commit changes | ||
git commit -m "docs: update auto-generated documentation [skip ci]" | ||
|
||
# Push changes | ||
git push origin ${{ github.head_ref }} | ||
else | ||
echo "No changes to commit" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address security concerns in git operations.
The direct use of github.head_ref
in scripts poses a potential security risk. Pass it through an environment variable instead.
- name: Check and Commit Documentation
+ env:
+ HEAD_REF: ${{ github.head_ref }}
run: |
# Check if there are any changes
if [[ -n "$(git status --porcelain)" ]]; then
# Add all changes
git add docs/docs/auto-docs
git add docs/docs/user-guide
git add docs/docs/developer-guide
# Commit changes
git commit -m "docs: update auto-generated documentation [skip ci]"
# Push changes
- git push origin ${{ github.head_ref }}
+ git push origin "$HEAD_REF"
else
echo "No changes to commit"
fi
Also apply this change to the documentation generation step:
- name: Generate Documentation
+ env:
+ HEAD_REF: ${{ github.head_ref }}
run: |
# Generate the documentation
typedoc \
--out docs/docs/auto-docs \
--plugin typedoc-plugin-markdown \
--theme markdown \
--tsconfig tsconfig.json \
--excludePrivate \
--excludeProtected \
--excludeExternals \
--hideGenerator \
- --gitRevision ${{ github.head_ref }} \
+ --gitRevision "$HEAD_REF" \
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- name: Setup Git Config | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Check and Commit Documentation | |
run: | | |
# Check if there are any changes | |
if [[ -n "$(git status --porcelain)" ]]; then | |
# Add all changes | |
git add docs/docs/auto-docs | |
git add docs/docs/user-guide | |
git add docs/docs/developer-guide | |
# Commit changes | |
git commit -m "docs: update auto-generated documentation [skip ci]" | |
# Push changes | |
git push origin ${{ github.head_ref }} | |
else | |
echo "No changes to commit" | |
fi | |
- name: Setup Git Config | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Check and Commit Documentation | |
env: | |
HEAD_REF: ${{ github.head_ref }} | |
run: | | |
# Check if there are any changes | |
if [[ -n "$(git status --porcelain)" ]]; then | |
# Add all changes | |
git add docs/docs/auto-docs | |
git add docs/docs/user-guide | |
git add docs/docs/developer-guide | |
# Commit changes | |
git commit -m "docs: update auto-generated documentation [skip ci]" | |
# Push changes | |
git push origin "$HEAD_REF" | |
else | |
echo "No changes to commit" | |
fi |
🧰 Tools
🪛 actionlint (1.7.4)
582-582: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details
(expression)
🪛 yamllint (1.35.1)
[error] 589-589: trailing spaces
(trailing-spaces)
[error] 592-592: trailing spaces
(trailing-spaces)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #3151 +/- ##
=====================================================
+ Coverage 20.10% 89.65% +69.55%
=====================================================
Files 301 322 +21
Lines 7685 8452 +767
Branches 1678 1841 +163
=====================================================
+ Hits 1545 7578 +6033
+ Misses 6044 646 -5398
- Partials 96 228 +132 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
.github/workflows/pull-request.yml (1)
579-595
:⚠️ Potential issueAddress security concerns in git operations.
The direct use of git commands without proper input sanitization could pose a security risk.
Apply these changes to improve security:
- name: Check and Commit Documentation + env: + GIT_AUTHOR_NAME: "GitHub Actions Bot" + GIT_AUTHOR_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com" run: | # Check if there are any changes if [[ -n "$(git status --porcelain)" ]]; then # Add all changes git add docs/docs/auto-docs git add docs/docs/user-guide git add docs/docs/developer-guide # Commit changes - git commit -m "docs: update auto-generated documentation [skip ci]" + git -c user.name="$GIT_AUTHOR_NAME" -c user.email="$GIT_AUTHOR_EMAIL" \ + commit -m "docs: update auto-generated documentation [skip ci]" # Push changes - git push + git push origin HEAD:${GITHUB_HEAD_REF:?} else echo "No changes to commit" fiThis change:
- Uses environment variables for Git author information
- Uses single Git command with temporary config
- Adds error checking for GITHUB_HEAD_REF
- Explicitly specifies the push target
🧰 Tools
🪛 yamllint (1.35.1)
[error] 587-587: trailing spaces
(trailing-spaces)
[error] 590-590: trailing spaces
(trailing-spaces)
🧹 Nitpick comments (3)
.github/workflows/pull-request.yml (3)
522-526
: Consider using local package installation.Instead of installing TypeDoc globally, consider installing it as a dev dependency in your project. This ensures version consistency across different environments and developers.
- - name: Install dependencies - run: | - npm ci - npm install -g typedoc typedoc-plugin-markdown + - name: Install dependencies + run: | + npm ci + npm install --save-dev typedoc typedoc-plugin-markdown
527-532
: Optimize directory creation commands.You can create multiple directories with a single
mkdir -p
command.- - name: Create documentation directory - run: | - mkdir -p docs/docs/auto-docs - mkdir -p docs/docs/user-guide - mkdir -p docs/docs/developer-guide/reference + - name: Create documentation directory + run: | + mkdir -p docs/docs/{auto-docs,user-guide,developer-guide/reference}
554-573
: Remove trailing spaces in markdown content.Fix the trailing spaces in the markdown content to maintain consistency.
- echo "# User Guide - + echo "# User Guide + This section contains the user guide for Talawa Admin. " > docs/docs/user-guide/intro.md - echo "# Developer Guide - + echo "# Developer Guide + This section contains the developer guide for Talawa Admin. " > docs/docs/developer-guide/intro.md - echo "# API Reference - + echo "# API Reference + This section contains the auto-generated API documentation for Talawa Admin. " > docs/docs/developer-guide/reference/README.md🧰 Tools
🪛 yamllint (1.35.1)
[error] 558-558: trailing spaces
(trailing-spaces)
[error] 564-564: trailing spaces
(trailing-spaces)
[error] 570-570: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 506-506: trailing spaces
(trailing-spaces)
[error] 558-558: trailing spaces
(trailing-spaces)
[error] 564-564: trailing spaces
(trailing-spaces)
[error] 570-570: trailing spaces
(trailing-spaces)
[error] 587-587: trailing spaces
(trailing-spaces)
[error] 590-590: trailing spaces
(trailing-spaces)
🔇 Additional comments (2)
.github/workflows/pull-request.yml (2)
507-511
: LGTM! Job configuration is well structured.The job dependencies ensure documentation is only generated after all critical checks pass.
533-553
: LGTM! TypeDoc configuration is comprehensive.The configuration properly excludes test files, mocks, and node_modules while maintaining a clean output directory.
Please fix the conflicting file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
.github/workflows/pull-request.yml (1)
571-587
:⚠️ Potential issueEnhance git operations security and error handling.
The git operations need better error handling and security measures.
This is a duplicate of a previous security concern. Apply these changes:
- name: Check and Commit Documentation + env: + HEAD_REF: ${{ github.head_ref }} run: | + set -e # Exit on any error + # Check if there are any changes if [[ -n "$(git status --porcelain)" ]]; then # Add all changes git add docs/docs/auto-docs git add docs/docs/user-guide git add docs/docs/developer-guide # Commit changes git commit -m "docs: update auto-generated documentation [skip ci]" # Push changes - git push + git push origin "$HEAD_REF" else echo "No changes to commit" fi🧰 Tools
🪛 yamllint (1.35.1)
[error] 579-579: trailing spaces
(trailing-spaces)
[error] 582-582: trailing spaces
(trailing-spaces)
🧹 Nitpick comments (1)
.github/workflows/pull-request.yml (1)
566-570
: Move Git configuration to environment variables.For better security and maintainability, move Git configuration to environment variables.
Apply these changes:
- name: Setup Git Config + env: + GIT_USER_NAME: "GitHub Actions Bot" + GIT_USER_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com" run: | - git config user.name "GitHub Actions Bot" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config user.name "$GIT_USER_NAME" + git config user.email "$GIT_USER_EMAIL"
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/pull-request.yml
(1 hunks).husky/pre-commit
(0 hunks)
💤 Files with no reviewable changes (1)
- .husky/pre-commit
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
463-463: shellcheck reported issue in this script: SC2181:style:11:8: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 463-463: trailing spaces
(trailing-spaces)
[error] 467-467: trailing spaces
(trailing-spaces)
[error] 470-470: trailing spaces
(trailing-spaces)
[error] 473-473: trailing spaces
(trailing-spaces)
[error] 482-482: trailing spaces
(trailing-spaces)
[error] 498-498: trailing spaces
(trailing-spaces)
[error] 550-550: trailing spaces
(trailing-spaces)
[error] 556-556: trailing spaces
(trailing-spaces)
[error] 562-562: trailing spaces
(trailing-spaces)
[error] 579-579: trailing spaces
(trailing-spaces)
[error] 582-582: trailing spaces
(trailing-spaces)
- name: Generate Documentation | ||
run: | | ||
# Generate the documentation | ||
typedoc \ | ||
--out docs/docs/auto-docs \ | ||
--plugin typedoc-plugin-markdown \ | ||
--theme markdown \ | ||
--tsconfig tsconfig.json \ | ||
--excludePrivate \ | ||
--excludeProtected \ | ||
--excludeExternals \ | ||
--hideGenerator \ | ||
--categorizeByGroup true \ | ||
--entryPointStrategy expand \ | ||
--entryPoints "src/**/*.ts" "src/**/*.tsx" \ | ||
--exclude "**/*.{test,spec,stories}.{ts,tsx}" \ | ||
--exclude "**/__tests__/**" \ | ||
--exclude "**/__mocks__/**" \ | ||
--exclude "**/node_modules/**" \ | ||
--cleanOutputDir true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling to documentation generation.
The TypeDoc command needs error handling and validation of the output.
Apply these changes:
- name: Generate Documentation
run: |
+ set -e # Exit on any error
+
# Generate the documentation
- typedoc \
+ if ! typedoc \
--out docs/docs/auto-docs \
--plugin typedoc-plugin-markdown \
--theme markdown \
--tsconfig tsconfig.json \
--excludePrivate \
--excludeProtected \
--excludeExternals \
--hideGenerator \
--categorizeByGroup true \
--entryPointStrategy expand \
--entryPoints "src/**/*.ts" "src/**/*.tsx" \
--exclude "**/*.{test,spec,stories}.{ts,tsx}" \
--exclude "**/__tests__/**" \
--exclude "**/__mocks__/**" \
--exclude "**/node_modules/**" \
- --cleanOutputDir true
+ --cleanOutputDir true; then
+ echo "Documentation generation failed"
+ exit 1
+ fi
+
+ # Verify documentation was generated
+ if [ ! -d "docs/docs/auto-docs" ] || [ -z "$(ls -A docs/docs/auto-docs)" ]; then
+ echo "Documentation directory is empty or missing"
+ exit 1
+ fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- name: Generate Documentation | |
run: | | |
# Generate the documentation | |
typedoc \ | |
--out docs/docs/auto-docs \ | |
--plugin typedoc-plugin-markdown \ | |
--theme markdown \ | |
--tsconfig tsconfig.json \ | |
--excludePrivate \ | |
--excludeProtected \ | |
--excludeExternals \ | |
--hideGenerator \ | |
--categorizeByGroup true \ | |
--entryPointStrategy expand \ | |
--entryPoints "src/**/*.ts" "src/**/*.tsx" \ | |
--exclude "**/*.{test,spec,stories}.{ts,tsx}" \ | |
--exclude "**/__tests__/**" \ | |
--exclude "**/__mocks__/**" \ | |
--exclude "**/node_modules/**" \ | |
--cleanOutputDir true | |
- name: Generate Documentation | |
run: | | |
set -e # Exit on any error | |
# Generate the documentation | |
if ! typedoc \ | |
--out docs/docs/auto-docs \ | |
--plugin typedoc-plugin-markdown \ | |
--theme markdown \ | |
--tsconfig tsconfig.json \ | |
--excludePrivate \ | |
--excludeProtected \ | |
--excludeExternals \ | |
--hideGenerator \ | |
--categorizeByGroup true \ | |
--entryPointStrategy expand \ | |
--entryPoints "src/**/*.ts" "src/**/*.tsx" \ | |
--exclude "**/*.{test,spec,stories}.{ts,tsx}" \ | |
--exclude "**/__tests__/**" \ | |
--exclude "**/__mocks__/**" \ | |
--exclude "**/node_modules/**" \ | |
--cleanOutputDir true; then | |
echo "Documentation generation failed" | |
exit 1 | |
fi | |
# Verify documentation was generated | |
if [ ! -d "docs/docs/auto-docs" ] || [ -z "$(ls -A docs/docs/auto-docs)" ]; then | |
echo "Documentation directory is empty or missing" | |
exit 1 | |
fi |
Merge-Conflict-Check: | ||
name: Check for Merge Conflicts | ||
runs-on: ubuntu-latest | ||
if: github.actor != 'dependabot[bot]' | ||
needs: [Code-Quality-Checks] | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check Mergeable Status via API | ||
run: | | ||
PR_NUMBER=${{ github.event.pull_request.number }} | ||
max_retries=3 | ||
retry_delay=5 | ||
|
||
for ((i=1; i<=max_retries; i++)); do | ||
echo "Attempt $i of $max_retries" | ||
|
||
response=$(curl -s -f -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER") | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Failed to call GitHub API" | ||
if [ $i -eq $max_retries ]; then | ||
exit 1 | ||
fi | ||
sleep $retry_delay | ||
continue | ||
fi | ||
|
||
mergeable=$(echo "$response" | jq -r '.mergeable') | ||
if [ "$mergeable" == "true" ]; then | ||
echo "No conflicts detected." | ||
exit 0 | ||
elif [ "$mergeable" == "false" ]; then | ||
echo "Merge conflicts detected." | ||
exit 1 | ||
else | ||
echo "Mergeable status unknown." | ||
if [ $i -eq $max_retries ]; then | ||
exit 1 | ||
fi | ||
sleep $retry_delay | ||
fi | ||
done | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance robustness and security of the merge conflict check.
The implementation needs several improvements:
- Add timeout to curl command to prevent hanging.
- Move retry configuration to environment variables.
- Use direct exit code checking for better error handling.
Apply these changes:
Merge-Conflict-Check:
name: Check for Merge Conflicts
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
needs: [Code-Quality-Checks]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Check Mergeable Status via API
+ env:
+ MAX_RETRIES: 3
+ RETRY_DELAY: 5
+ CURL_TIMEOUT: 10
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
- max_retries=3
- retry_delay=5
- for ((i=1; i<=max_retries; i++)); do
+ for ((i=1; i<=$MAX_RETRIES; i++)); do
- echo "Attempt $i of $max_retries"
+ echo "Attempt $i of $MAX_RETRIES"
- response=$(curl -s -f -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
+ if ! response=$(curl -s -f --max-time $CURL_TIMEOUT -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER")
- if [ $? -ne 0 ]; then
+ then
echo "Failed to call GitHub API"
- if [ $i -eq $max_retries ]; then
+ if [ $i -eq $MAX_RETRIES ]; then
exit 1
fi
- sleep $retry_delay
+ sleep $RETRY_DELAY
continue
fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Merge-Conflict-Check: | |
name: Check for Merge Conflicts | |
runs-on: ubuntu-latest | |
if: github.actor != 'dependabot[bot]' | |
needs: [Code-Quality-Checks] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Check Mergeable Status via API | |
run: | | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
max_retries=3 | |
retry_delay=5 | |
for ((i=1; i<=max_retries; i++)); do | |
echo "Attempt $i of $max_retries" | |
response=$(curl -s -f -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER") | |
if [ $? -ne 0 ]; then | |
echo "Failed to call GitHub API" | |
if [ $i -eq $max_retries ]; then | |
exit 1 | |
fi | |
sleep $retry_delay | |
continue | |
fi | |
mergeable=$(echo "$response" | jq -r '.mergeable') | |
if [ "$mergeable" == "true" ]; then | |
echo "No conflicts detected." | |
exit 0 | |
elif [ "$mergeable" == "false" ]; then | |
echo "Merge conflicts detected." | |
exit 1 | |
else | |
echo "Mergeable status unknown." | |
if [ $i -eq $max_retries ]; then | |
exit 1 | |
fi | |
sleep $retry_delay | |
fi | |
done | |
Merge-Conflict-Check: | |
name: Check for Merge Conflicts | |
runs-on: ubuntu-latest | |
if: github.actor != 'dependabot[bot]' | |
needs: [Code-Quality-Checks] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Check Mergeable Status via API | |
env: | |
MAX_RETRIES: 3 | |
RETRY_DELAY: 5 | |
CURL_TIMEOUT: 10 | |
run: | | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
for ((i=1; i<=$MAX_RETRIES; i++)); do | |
echo "Attempt $i of $MAX_RETRIES" | |
if ! response=$(curl -s -f --max-time $CURL_TIMEOUT -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER") | |
then | |
echo "Failed to call GitHub API" | |
if [ $i -eq $MAX_RETRIES ]; then | |
exit 1 | |
fi | |
sleep $RETRY_DELAY | |
continue | |
fi | |
mergeable=$(echo "$response" | jq -r '.mergeable') | |
if [ "$mergeable" == "true" ]; then | |
echo "No conflicts detected." | |
exit 0 | |
elif [ "$mergeable" == "false" ]; then | |
echo "Merge conflicts detected." | |
exit 1 | |
else | |
echo "Mergeable status unknown." | |
if [ $i -eq $max_retries ]; then | |
exit 1 | |
fi | |
sleep $retry_delay | |
fi | |
done |
🧰 Tools
🪛 actionlint (1.7.4)
463-463: shellcheck reported issue in this script: SC2181:style:11:8: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
🪛 yamllint (1.35.1)
[error] 463-463: trailing spaces
(trailing-spaces)
[error] 467-467: trailing spaces
(trailing-spaces)
[error] 470-470: trailing spaces
(trailing-spaces)
[error] 473-473: trailing spaces
(trailing-spaces)
[error] 482-482: trailing spaces
(trailing-spaces)
[error] 498-498: trailing spaces
(trailing-spaces)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/pull-request.yml (1)
547-566
: Enhance placeholder documentation content.The placeholder documentation could be more informative and structured.
Consider enhancing the placeholder content:
# User Guide -This section contains the user guide for Talawa Admin. +This section will contain comprehensive guides for: +- Getting started with Talawa Admin +- Managing organizations and events +- User management and permissions +- Common workflows and troubleshooting # Developer Guide -This section contains the developer guide for Talawa Admin. +This section will cover: +- Architecture overview +- Development setup +- Contributing guidelines +- Testing and deployment # API Reference -This section contains the auto-generated API documentation for Talawa Admin. +This section provides: +- Auto-generated API documentation +- Component references +- Type definitions +- Integration examples🧰 Tools
🪛 yamllint (1.35.1)
[error] 551-551: trailing spaces
(trailing-spaces)
[error] 557-557: trailing spaces
(trailing-spaces)
[error] 563-563: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
463-463: shellcheck reported issue in this script: SC2181:style:11:8: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
573-573: "github.event.pull_request.head.ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details
(expression)
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 463-463: trailing spaces
(trailing-spaces)
[error] 467-467: trailing spaces
(trailing-spaces)
[error] 470-470: trailing spaces
(trailing-spaces)
[error] 473-473: trailing spaces
(trailing-spaces)
[error] 482-482: trailing spaces
(trailing-spaces)
[error] 498-498: trailing spaces
(trailing-spaces)
[error] 551-551: trailing spaces
(trailing-spaces)
[error] 557-557: trailing spaces
(trailing-spaces)
[error] 563-563: trailing spaces
(trailing-spaces)
[error] 580-580: trailing spaces
(trailing-spaces)
[error] 583-583: trailing spaces
(trailing-spaces)
🔇 Additional comments (2)
.github/workflows/pull-request.yml (2)
453-498
: Enhance security and robustness of merge conflict check.The implementation needs several improvements for better security and reliability.
This is a duplicate of a previous review comment. Please refer to the existing feedback for the recommended changes, which include:
- Adding timeout to curl command
- Moving retry configuration to environment variables
- Using direct exit code checking
- Improving security by avoiding direct token usage
🧰 Tools
🪛 actionlint (1.7.4)
463-463: shellcheck reported issue in this script: SC2181:style:11:8: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
🪛 yamllint (1.35.1)
[error] 463-463: trailing spaces
(trailing-spaces)
[error] 467-467: trailing spaces
(trailing-spaces)
[error] 470-470: trailing spaces
(trailing-spaces)
[error] 473-473: trailing spaces
(trailing-spaces)
[error] 482-482: trailing spaces
(trailing-spaces)
[error] 498-498: trailing spaces
(trailing-spaces)
526-545
: Add error handling to documentation generation.The TypeDoc command needs error handling and validation of the output.
This is a duplicate of a previous review comment. Please refer to the existing feedback for the recommended changes, which include:
- Adding error handling with
set -e
- Adding validation of the output directory
- Improving the TypeDoc command execution
.github/workflows/pull-request.yml
Outdated
- name: Check and Commit Documentation | ||
run: | | ||
# Check if there are any changes | ||
if [[ -n "$(git status --porcelain)" ]]; then | ||
# Add all changes | ||
git add docs/docs/auto-docs | ||
git add docs/docs/user-guide | ||
git add docs/docs/developer-guide | ||
|
||
# Commit changes | ||
git commit -m "docs: update auto-generated documentation [skip ci]" | ||
|
||
# Push changes | ||
git push origin HEAD:${{ github.event.pull_request.head.ref }} | ||
else | ||
echo "No changes to commit" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address security concerns in git operations.
The direct use of github.event.pull_request.head.ref
in scripts poses a potential security risk.
Pass it through an environment variable instead:
- name: Check and Commit Documentation
+ env:
+ HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
# Check if there are any changes
if [[ -n "$(git status --porcelain)" ]]; then
# Add all changes
git add docs/docs/auto-docs
git add docs/docs/user-guide
git add docs/docs/developer-guide
# Commit changes
git commit -m "docs: update auto-generated documentation [skip ci]"
# Push changes
- git push origin HEAD:${{ github.event.pull_request.head.ref }}
+ git push origin "HEAD:$HEAD_REF"
fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- name: Check and Commit Documentation | |
run: | | |
# Check if there are any changes | |
if [[ -n "$(git status --porcelain)" ]]; then | |
# Add all changes | |
git add docs/docs/auto-docs | |
git add docs/docs/user-guide | |
git add docs/docs/developer-guide | |
# Commit changes | |
git commit -m "docs: update auto-generated documentation [skip ci]" | |
# Push changes | |
git push origin HEAD:${{ github.event.pull_request.head.ref }} | |
else | |
echo "No changes to commit" | |
fi | |
- name: Check and Commit Documentation | |
env: | |
HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
run: | | |
# Check if there are any changes | |
if [[ -n "$(git status --porcelain)" ]]; then | |
# Add all changes | |
git add docs/docs/auto-docs | |
git add docs/docs/user-guide | |
git add docs/docs/developer-guide | |
# Commit changes | |
git commit -m "docs: update auto-generated documentation [skip ci]" | |
# Push changes | |
git push origin "HEAD:$HEAD_REF" | |
else | |
echo "No changes to commit" | |
fi |
🧰 Tools
🪛 actionlint (1.7.4)
573-573: "github.event.pull_request.head.ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details
(expression)
🪛 yamllint (1.35.1)
[error] 580-580: trailing spaces
(trailing-spaces)
[error] 583-583: trailing spaces
(trailing-spaces)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/pull-request.yml (1)
546-565
: Enhance placeholder documentation structure.The placeholder documentation could be more informative and structured.
Consider adding more sections to the placeholder documentation:
- name: Create placeholder documentation run: | # Create User Guide placeholder echo "# User Guide - This section contains the user guide for Talawa Admin. + This section contains the comprehensive user guide for Talawa Admin. + + ## Getting Started + - Installation + - Configuration + - First Steps + + ## Features + - Core Functionality + - Advanced Usage " > docs/docs/user-guide/intro.md # Create Developer Guide placeholder echo "# Developer Guide - This section contains the developer guide for Talawa Admin. + This section contains the technical documentation for Talawa Admin developers. + + ## Development Setup + - Prerequisites + - Local Development + - Testing + + ## Contributing + - Code Style + - Pull Request Process " > docs/docs/developer-guide/intro.md🧰 Tools
🪛 yamllint (1.35.1)
[error] 550-550: trailing spaces
(trailing-spaces)
[error] 556-556: trailing spaces
(trailing-spaces)
[error] 562-562: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
463-463: shellcheck reported issue in this script: SC2181:style:11:8: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 463-463: trailing spaces
(trailing-spaces)
[error] 467-467: trailing spaces
(trailing-spaces)
[error] 470-470: trailing spaces
(trailing-spaces)
[error] 473-473: trailing spaces
(trailing-spaces)
[error] 482-482: trailing spaces
(trailing-spaces)
[error] 498-498: trailing spaces
(trailing-spaces)
[error] 550-550: trailing spaces
(trailing-spaces)
[error] 556-556: trailing spaces
(trailing-spaces)
[error] 562-562: trailing spaces
(trailing-spaces)
[error] 579-579: trailing spaces
(trailing-spaces)
[error] 582-582: trailing spaces
(trailing-spaces)
🔇 Additional comments (2)
.github/workflows/pull-request.yml (2)
525-544
: 🛠️ Refactor suggestionAdd error handling to documentation generation.
The TypeDoc command needs error handling and validation of the output.
Apply these changes:
- name: Generate Documentation run: | + set -e # Exit on any error + # Generate the documentation - typedoc \ + if ! typedoc \ --out docs/docs/auto-docs \ --plugin typedoc-plugin-markdown \ --theme markdown \ --tsconfig tsconfig.json \ --excludePrivate \ --excludeProtected \ --excludeExternals \ --hideGenerator \ --categorizeByGroup true \ --entryPointStrategy expand \ --entryPoints "src/**/*.ts" "src/**/*.tsx" \ --exclude "**/*.{test,spec,stories}.{ts,tsx}" \ --exclude "**/__tests__/**" \ --exclude "**/__mocks__/**" \ --exclude "**/node_modules/**" \ - --cleanOutputDir true + --cleanOutputDir true; then + echo "Documentation generation failed" + exit 1 + fi + + # Verify documentation was generated + if [ ! -d "docs/docs/auto-docs" ] || [ -z "$(ls -A docs/docs/auto-docs)" ]; then + echo "Documentation directory is empty or missing" + exit 1 + fiLikely invalid or redundant comment.
453-498
: 🛠️ Refactor suggestionEnhance robustness and security of the merge conflict check.
The implementation needs several improvements:
- Add timeout to curl command to prevent hanging
- Move retry configuration to environment variables
- Use direct exit code checking for better error handling
- Pass GitHub token securely
Apply these changes:
Merge-Conflict-Check: name: Check for Merge Conflicts runs-on: ubuntu-latest if: github.actor != 'dependabot[bot]' needs: [Code-Quality-Checks] steps: - name: Checkout Code uses: actions/checkout@v4 - name: Check Mergeable Status via API + env: + MAX_RETRIES: 3 + RETRY_DELAY: 5 + CURL_TIMEOUT: 10 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PR_NUMBER=${{ github.event.pull_request.number }} - max_retries=3 - retry_delay=5 - for ((i=1; i<=max_retries; i++)); do + for ((i=1; i<=$MAX_RETRIES; i++)); do - echo "Attempt $i of $max_retries" + echo "Attempt $i of $MAX_RETRIES" - response=$(curl -s -f -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + if ! response=$(curl -s -f --max-time $CURL_TIMEOUT -H "Authorization: Bearer $GH_TOKEN" \ "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER") - if [ $? -ne 0 ]; then + then echo "Failed to call GitHub API" - if [ $i -eq $max_retries ]; then + if [ $i -eq $MAX_RETRIES ]; then exit 1 fi - sleep $retry_delay + sleep $RETRY_DELAY continue fiLikely invalid or redundant comment.
🧰 Tools
🪛 actionlint (1.7.4)
463-463: shellcheck reported issue in this script: SC2181:style:11:8: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
🪛 yamllint (1.35.1)
[error] 463-463: trailing spaces
(trailing-spaces)
[error] 467-467: trailing spaces
(trailing-spaces)
[error] 470-470: trailing spaces
(trailing-spaces)
[error] 473-473: trailing spaces
(trailing-spaces)
[error] 482-482: trailing spaces
(trailing-spaces)
[error] 498-498: trailing spaces
(trailing-spaces)
- name: Check and Commit Documentation | ||
run: | | ||
# Check if there are any changes | ||
if [[ -n "$(git status --porcelain)" ]]; then | ||
# Add all changes | ||
git add docs/docs/auto-docs | ||
git add docs/docs/user-guide | ||
git add docs/docs/developer-guide | ||
|
||
# Commit changes | ||
git commit -m "docs: update auto-generated documentation [skip ci]" | ||
|
||
# Push changes | ||
git push | ||
else | ||
echo "No changes to commit" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Address security concerns in git operations.
The git operations need proper error handling and secure token usage.
Apply these changes:
- name: Check and Commit Documentation
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
+ set -e # Exit on any error
+
# Check if there are any changes
if [[ -n "$(git status --porcelain)" ]]; then
# Add all changes
git add docs/docs/auto-docs
git add docs/docs/user-guide
git add docs/docs/developer-guide
# Commit changes
git commit -m "docs: update auto-generated documentation [skip ci]"
# Push changes
- git push
+ if ! git push https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:${GITHUB_REF}; then
+ echo "Failed to push changes"
+ exit 1
+ fi
else
echo "No changes to commit"
fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- name: Check and Commit Documentation | |
run: | | |
# Check if there are any changes | |
if [[ -n "$(git status --porcelain)" ]]; then | |
# Add all changes | |
git add docs/docs/auto-docs | |
git add docs/docs/user-guide | |
git add docs/docs/developer-guide | |
# Commit changes | |
git commit -m "docs: update auto-generated documentation [skip ci]" | |
# Push changes | |
git push | |
else | |
echo "No changes to commit" | |
fi | |
- name: Check and Commit Documentation | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -e # Exit on any error | |
# Check if there are any changes | |
if [[ -n "$(git status --porcelain)" ]]; then | |
# Add all changes | |
git add docs/docs/auto-docs | |
git add docs/docs/user-guide | |
git add docs/docs/developer-guide | |
# Commit changes | |
git commit -m "docs: update auto-generated documentation [skip ci]" | |
# Push changes | |
if ! git push https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:${GITHUB_REF}; then | |
echo "Failed to push changes" | |
exit 1 | |
fi | |
else | |
echo "No changes to commit" | |
fi |
🧰 Tools
🪛 yamllint (1.35.1)
[error] 579-579: trailing spaces
(trailing-spaces)
[error] 582-582: trailing spaces
(trailing-spaces)
What kind of change does this PR introduce?
This PR solves the second part of #2970 - Ensure the autogenerated markdown based on the code base's comments is added to the site in an intuitive way. The GitHub action that does this can be found here: .github/workflows/pull-request.yml
Fixes #2970
Did you add tests for your changes?
No
If relevant, did you update the documentation?
NOT manually, Docs will be auto-generate by github-workflows
Summary
Documentation is structured into two parts- autogenerated documentation which is done by .github/workflows/pull-request.yml and save it in correct docs/auto-docs directory and manual documentation which is done by removing default docusaurus files and making 2 placeholders (user-guide and developer guide). This documentation section is accessible through general navbar item.
Does this PR introduce a breaking change?
No
Other information
generate-doc job has been added to .github/workflows/pull-request.yml
Have you read the contributing guide?
Yes
Summary by CodeRabbit
docs/docs
directory.pdf.buffer
to aUint8Array
in the TableRow component.