-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fixed pr workflow which ensures that talawa Api app starts in docker #2653
fixed pr workflow which ensures that talawa Api app starts in docker #2653
Conversation
WalkthroughThe changes in this pull request enhance the GitHub Actions workflow defined in Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
Warning Rate limit exceeded@rahulrana701 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 40 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 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.
Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.
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.
.github/workflows/pull-request.yml
Outdated
|
||
- name: Checks Talawa API app starts in Docker | ||
run: | | ||
if [[ "${{ runner.os }}" == "Linux" ]]; then | ||
bash sudo /usr/libexec/docker/cli-plugins/docker-compose -f docker-compose.dev.yaml up --build | ||
elif [[ "${{ runner.os }}" == "Windows" ]]; then | ||
docker-compose -f docker-compose.dev.yaml up --build | ||
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
Improve workflow structure to avoid resource conflicts
The current workflow runs both Docker containers and local development server in the same job, which could lead to port conflicts and redundant testing. Consider restructuring the workflow for better separation of concerns.
Suggestions:
- Split into separate jobs:
Test-Application
: Run tests locally (existing)Docker-Check
: Run Docker validation (new)
- Add job dependency:
Docker-Check: needs: [Test-Application] # ... Docker check implementation
This separation will:
- Prevent port conflicts
- Make the workflow more maintainable
- Provide clearer failure points
- Allow parallel execution if needed
.github/workflows/pull-request.yml
Outdated
- name: Checks Talawa API app starts in Docker | ||
run: | | ||
if [[ "${{ runner.os }}" == "Linux" ]]; then | ||
bash sudo /usr/libexec/docker/cli-plugins/docker-compose -f docker-compose.dev.yaml up --build | ||
elif [[ "${{ runner.os }}" == "Windows" ]]; then | ||
docker-compose -f docker-compose.dev.yaml up --build | ||
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.
Critical issues in Docker startup check implementation
The current implementation has several issues that need to be addressed:
- The Docker Compose command path is incorrect and non-standard
- Missing detached mode will cause the workflow to hang
- No health check to verify successful startup
- No timeout handling
- No cleanup of Docker resources
- Unnecessary Windows condition (GitHub Actions uses Ubuntu runners)
Replace the implementation with this more robust version:
- - name: Checks Talawa API app starts in Docker
- run: |
- if [[ "${{ runner.os }}" == "Linux" ]]; then
- bash sudo /usr/libexec/docker/cli-plugins/docker-compose -f docker-compose.dev.yaml up --build
- elif [[ "${{ runner.os }}" == "Windows" ]]; then
- docker-compose -f docker-compose.dev.yaml up --build
- fi
+ - name: Check if Talawa API starts in Docker
+ run: |
+ # Start containers in detached mode
+ docker-compose -f docker-compose.dev.yaml up -d --build
+
+ # Wait for the API to be healthy (max 60 seconds)
+ timeout=60
+ until curl -f http://localhost:4000/health || [ $timeout -eq 0 ]; do
+ echo "Waiting for API to start... ($timeout seconds remaining)"
+ sleep 1
+ ((timeout--))
+ done
+
+ if [ $timeout -eq 0 ]; then
+ echo "Error: API failed to start within timeout"
+ docker-compose -f docker-compose.dev.yaml logs
+ exit 1
+ fi
+
+ echo "API started successfully"
+
+ # Cleanup
+ docker-compose -f docker-compose.dev.yaml down -v
This implementation:
- Uses standard
docker-compose
command - Runs containers in detached mode
- Implements proper health check with timeout
- Shows container logs on failure
- Cleans up resources after check
📝 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: Checks Talawa API app starts in Docker | |
run: | | |
if [[ "${{ runner.os }}" == "Linux" ]]; then | |
bash sudo /usr/libexec/docker/cli-plugins/docker-compose -f docker-compose.dev.yaml up --build | |
elif [[ "${{ runner.os }}" == "Windows" ]]; then | |
docker-compose -f docker-compose.dev.yaml up --build | |
fi | |
- name: Check if Talawa API starts in Docker | |
run: | | |
# Start containers in detached mode | |
docker-compose -f docker-compose.dev.yaml up -d --build | |
# Wait for the API to be healthy (max 60 seconds) | |
timeout=60 | |
until curl -f http://localhost:4000/health || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Cleanup | |
docker-compose -f docker-compose.dev.yaml down -v |
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
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/pull-request.yml
299-299: "runs-on" section is missing in job "Docker-Check"
(syntax-check)
🪛 yamllint
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 301-301: trailing spaces
(trailing-spaces)
[error] 305-305: trailing spaces
(trailing-spaces)
[error] 312-312: trailing spaces
(trailing-spaces)
[error] 318-318: trailing spaces
(trailing-spaces)
[error] 320-320: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
- name: Check if Talawa API starts in Docker | ||
run: | | ||
docker-compose -f docker-compose.dev.yaml up -d --build | ||
|
||
timeout=60 | ||
until curl -f http://localhost:4000/health || [ $timeout -eq 0 ]; do | ||
echo "Waiting for API to start... ($timeout seconds remaining)" | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
if [ $timeout -eq 0 ]; then | ||
echo "Error: API failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
exit 1 | ||
fi | ||
|
||
echo "API started successfully" | ||
|
||
# Cleanup | ||
docker-compose -f docker-compose.dev.yaml down -v |
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 Docker check reliability
While the implementation is good, there are a few improvements needed:
- Add error handling for docker-compose commands
- Use environment variable for health check URL
- Ensure no port conflicts with Test-Application job
Apply this diff to enhance the implementation:
+ name: Check if Talawa API starts in Docker
run: |
+ # Ensure no containers are running
+ docker-compose -f docker-compose.dev.yaml down -v || true
+
+ # Start containers
docker-compose -f docker-compose.dev.yaml up -d --build
+ if [ $? -ne 0 ]; then
+ echo "Failed to start containers"
+ exit 1
+ fi
timeout=60
- until curl -f http://localhost:4000/health || [ $timeout -eq 0 ]; do
+ until curl -f "${HEALTH_CHECK_URL:-http://localhost:4000}/health" || [ $timeout -eq 0 ]; do
echo "Waiting for API to start... ($timeout seconds remaining)"
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: API failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs
+ docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
echo "API started successfully"
# Cleanup
docker-compose -f docker-compose.dev.yaml down -v
+ if [ $? -ne 0 ]; then
+ echo "Failed to cleanup containers"
+ exit 1
+ fi
Additionally, consider adding these environment variables to the job:
env:
HEALTH_CHECK_URL: http://localhost:4000
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }}
The COMPOSE_PROJECT_NAME
ensures unique container names per PR, preventing conflicts with other jobs.
🧰 Tools
🪛 yamllint
[error] 305-305: trailing spaces
(trailing-spaces)
[error] 312-312: trailing spaces
(trailing-spaces)
[error] 318-318: trailing spaces
(trailing-spaces)
[error] 320-320: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
Docker-Check: | ||
needs: Test-Application | ||
steps: |
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.
Add missing required "runs-on" field
The job definition is missing the required "runs-on" field which specifies the runner environment. This will cause the workflow to fail.
Apply this diff to fix the job definition:
Docker-Check:
needs: Test-Application
+ runs-on: ubuntu-latest
steps:
📝 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.
Docker-Check: | |
needs: Test-Application | |
steps: | |
Docker-Check: | |
needs: Test-Application | |
runs-on: ubuntu-latest | |
steps: |
🧰 Tools
🪛 actionlint
299-299: "runs-on" section is missing in job "Docker-Check"
(syntax-check)
🪛 yamllint
[error] 301-301: 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: 3
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/pull-request.yml
304-304: shellcheck reported issue in this script: SC2181:style:6:7: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
304-304: shellcheck reported issue in this script: SC2181:style:29:7: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
🪛 yamllint
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 320-320: trailing spaces
(trailing-spaces)
[error] 339-339: trailing spaces
(trailing-spaces)
🔇 Additional comments (1)
.github/workflows/pull-request.yml (1)
299-340
: Verify workflow execution order and failure handling
The job integration looks good, but let's verify the workflow execution order and failure handling.
✅ Verification successful
Workflow execution order and failure handling are correctly implemented
Docker-Check
job properly depends onTest-Application
.- Cleanup steps are executed in case of failure.
- Proper error handling with
exit 1
is in place.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify workflow execution order and failure handling
# Expected: Docker-Check job should run after Test-Application and handle failures correctly
# Check if Docker-Check depends on Test-Application
rg -A 5 "Docker-Check:" .github/workflows/pull-request.yml
# Check if cleanup is performed in case of failure
rg -A 10 "docker-compose.*down" .github/workflows/pull-request.yml
# Check for proper error handling
rg "exit 1" .github/workflows/pull-request.yml
Length of output: 1357
🧰 Tools
🪛 actionlint
304-304: shellcheck reported issue in this script: SC2181:style:6:7: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
304-304: shellcheck reported issue in this script: SC2181:style:29:7: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
🪛 yamllint
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 320-320: trailing spaces
(trailing-spaces)
[error] 339-339: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
- name: Check if Talawa API starts in Docker | ||
run: | | ||
# Ensure no containers are running | ||
docker-compose -f docker-compose.dev.yaml down -v || true | ||
|
||
# Start containers | ||
docker-compose -f docker-compose.dev.yaml up -d --build | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to start containers" | ||
exit 1 | ||
fi | ||
|
||
timeout=60 | ||
until curl -f "${HEALTH_CHECK_URL:-http://localhost:4000}/health" || [ $timeout -eq 0 ]; do | ||
echo "Waiting for API to start... ($timeout seconds remaining)" | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
if [ $timeout -eq 0 ]; then | ||
echo "Error: API failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "API started successfully" | ||
|
||
# Cleanup | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to cleanup containers" | ||
exit 1 | ||
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
Improve shell script robustness
While the implementation is good, there are some improvements needed:
- Use direct command checking instead of
$?
- Fix indentation inconsistencies
- Add error handling for curl command
Apply this diff:
- name: Check if Talawa API starts in Docker
run: |
# Ensure no containers are running
docker-compose -f docker-compose.dev.yaml down -v || true
# Start containers
- docker-compose -f docker-compose.dev.yaml up -d --build
- if [ $? -ne 0 ]; then
+ if ! docker-compose -f docker-compose.dev.yaml up -d --build; then
echo "Failed to start containers"
exit 1
fi
timeout=60
- until curl -f "${HEALTH_CHECK_URL:-http://localhost:4000}/health" || [ $timeout -eq 0 ]; do
+ until curl -sf "${HEALTH_CHECK_URL:-http://localhost:4000}/health" 2>/dev/null || [ $timeout -eq 0 ]; do
echo "Waiting for API to start... ($timeout seconds remaining)"
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: API failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
echo "API started successfully"
# Cleanup
- docker-compose -f docker-compose.dev.yaml down -v
- if [ $? -ne 0 ]; then
+ if ! docker-compose -f docker-compose.dev.yaml down -v; then
echo "Failed to cleanup containers"
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: Check if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Start containers | |
docker-compose -f docker-compose.dev.yaml up -d --build | |
if [ $? -ne 0 ]; then | |
echo "Failed to start containers" | |
exit 1 | |
fi | |
timeout=60 | |
until curl -f "${HEALTH_CHECK_URL:-http://localhost:4000}/health" || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Cleanup | |
docker-compose -f docker-compose.dev.yaml down -v | |
if [ $? -ne 0 ]; then | |
echo "Failed to cleanup containers" | |
exit 1 | |
fi | |
- name: Check if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
exit 1 | |
fi | |
timeout=60 | |
until curl -sf "${HEALTH_CHECK_URL:-http://localhost:4000}/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Cleanup | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Failed to cleanup containers" | |
exit 1 | |
fi |
🧰 Tools
🪛 actionlint
304-304: shellcheck reported issue in this script: SC2181:style:6:7: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
304-304: shellcheck reported issue in this script: SC2181:style:29:7: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?
(shellcheck)
🪛 yamllint
[error] 320-320: 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: 3
🧹 Outside diff range and nitpick comments (1)
.github/workflows/pull-request.yml (1)
298-337
: Remove trailing spacesThere are trailing spaces on several lines that should be removed:
- Line 298: Empty line with spaces
- Line 302: After
steps:
- Line 319: After
done
- Line 337: After
number }}
Remove trailing spaces to improve code cleanliness.
🧰 Tools
🪛 yamllint
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 319-319: trailing spaces
(trailing-spaces)
[error] 337-337: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 319-319: trailing spaces
(trailing-spaces)
[error] 337-337: trailing spaces
(trailing-spaces)
🔇 Additional comments (1)
.github/workflows/pull-request.yml (1)
299-337
: Verify Docker configuration and test data setup
Let's verify the Docker configuration and ensure test data setup is handled properly.
🧰 Tools
🪛 yamllint
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 319-319: trailing spaces
(trailing-spaces)
[error] 337-337: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
Docker-Check: | ||
needs: Test-Application | ||
runs-on: ubuntu-latest | ||
steps: |
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.
Add missing required steps
The job is missing critical setup steps:
- Repository checkout to access docker-compose files
- Node.js setup for environment consistency with other jobs
Add these steps before the Docker check:
Docker-Check:
needs: Test-Application
runs-on: ubuntu-latest
steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '22.x'
📝 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.
Docker-Check: | |
needs: Test-Application | |
runs-on: ubuntu-latest | |
steps: | |
Docker-Check: | |
needs: Test-Application | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22.x' |
🧰 Tools
🪛 yamllint
[error] 302-302: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
env: | ||
HEALTH_CHECK_URL: http://localhost:4000 | ||
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} |
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.
Add missing required environment variables
The Docker environment is missing critical variables that are required for the application to start properly. These variables are present in the Test-Application job but missing here.
Add these environment variables:
env:
HEALTH_CHECK_URL: http://localhost:4000
- COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }}
+ COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }}
+ MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db
+ REDIS_HOST: redis
+ REDIS_PORT: 6379
+ ACCESS_TOKEN_SECRET: ${{ env.ACCESS_TOKEN_SECRET }}
+ REFRESH_TOKEN_SECRET: ${{ env.REFRESH_TOKEN_SECRET }}
+ LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]"
+ COLORIZE_LOGS: "true"
+ LOG_LEVEL: "info"
Note: The MongoDB and Redis hostnames are changed to match the service names in docker-compose.
📝 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.
env: | |
HEALTH_CHECK_URL: http://localhost:4000 | |
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} | |
env: | |
HEALTH_CHECK_URL: http://localhost:4000 | |
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} | |
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db | |
REDIS_HOST: redis | |
REDIS_PORT: 6379 | |
ACCESS_TOKEN_SECRET: ${{ env.ACCESS_TOKEN_SECRET }} | |
REFRESH_TOKEN_SECRET: ${{ env.REFRESH_TOKEN_SECRET }} | |
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" | |
COLORIZE_LOGS: "true" | |
LOG_LEVEL: "info" |
🧰 Tools
🪛 yamllint
[error] 337-337: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
- name: Check if Talawa API starts in Docker | ||
run: | | ||
# Ensure no containers are running | ||
docker-compose -f docker-compose.dev.yaml down -v || true | ||
|
||
# Start containers | ||
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | ||
echo "Failed to start containers" | ||
exit 1 | ||
fi | ||
|
||
timeout=60 | ||
until curl -sf "${HEALTH_CHECK_URL:-http://localhost:4000}/health" 2>/dev/null || [ $timeout -eq 0 ]; do | ||
echo "Waiting for API to start... ($timeout seconds remaining)" | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
if [ $timeout -eq 0 ]; then | ||
echo "Error: API failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "API started successfully" | ||
|
||
# Cleanup | ||
if ! docker-compose -f docker-compose.dev.yaml down -v; then | ||
echo "Failed to cleanup containers" | ||
exit 1 | ||
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.
Enhance Docker health check implementation
The current implementation has several issues:
- No verification that required services (MongoDB, Redis) are running
- Health check might fail due to container networking
- Missing proper error handling and logging
Replace the implementation with this more robust version:
- name: Check if Talawa API starts in Docker
run: |
# Ensure no containers are running
docker-compose -f docker-compose.dev.yaml down -v || true
# Start containers
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then
echo "Failed to start containers"
docker-compose -f docker-compose.dev.yaml logs
exit 1
fi
# Wait for MongoDB and Redis to be ready
+ echo "Waiting for MongoDB..."
+ timeout=30
+ until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
+ sleep 1
+ ((timeout--))
+ done
+
+ echo "Waiting for Redis..."
+ timeout=30
+ until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
+ sleep 1
+ ((timeout--))
+ done
# Wait for API to be healthy
timeout=60
- until curl -sf "${HEALTH_CHECK_URL:-http://localhost:4000}/health" 2>/dev/null || [ $timeout -eq 0 ]; do
+ until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://localhost:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
echo "Waiting for API to start... ($timeout seconds remaining)"
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: API failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
echo "API started successfully"
# Cleanup
if ! docker-compose -f docker-compose.dev.yaml down -v; then
echo "Failed to cleanup containers"
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: Check if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
exit 1 | |
fi | |
timeout=60 | |
until curl -sf "${HEALTH_CHECK_URL:-http://localhost:4000}/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Cleanup | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Failed to cleanup containers" | |
exit 1 | |
fi | |
- name: Check if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
docker-compose -f docker-compose.dev.yaml logs | |
exit 1 | |
fi | |
# Wait for MongoDB and Redis to be ready | |
echo "Waiting for MongoDB..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
echo "Waiting for Redis..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
# Wait for API to be healthy | |
timeout=60 | |
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://localhost:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Cleanup | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Failed to cleanup containers" | |
exit 1 | |
fi |
🧰 Tools
🪛 yamllint
[error] 319-319: trailing spaces
(trailing-spaces)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2653 +/- ##
========================================
Coverage 97.74% 97.74%
========================================
Files 358 358
Lines 18114 18114
Branches 2600 2599 -1
========================================
Hits 17706 17706
Misses 404 404
Partials 4 4 ☔ 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: 3
🧹 Outside diff range and nitpick comments (1)
.github/workflows/pull-request.yml (1)
298-302
: Fix formatting issues in job definitionRemove trailing spaces from lines 298 and 302 to maintain consistent formatting.
- + Docker-Check: needs: Test-Application runs-on: ubuntu-latest - + steps:🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.3)
.github/workflows/pull-request.yml
309-309: "with" section should not be empty. please remove this section if it's unnecessary
(syntax-check)
310-310: unexpected key "node-version" for "step" section. expected one of "continue-on-error", "env", "id", "if", "name", "run", "shell", "timeout-minutes", "uses", "with", "working-directory"
(syntax-check)
366-366: context "env" is not allowed here. available contexts are "github", "inputs", "matrix", "needs", "secrets", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
(expression)
367-367: context "env" is not allowed here. available contexts are "github", "inputs", "matrix", "needs", "secrets", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
(expression)
🪛 yamllint (1.29.0-1)
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
[error] 337-337: trailing spaces
(trailing-spaces)
[error] 344-344: trailing spaces
(trailing-spaces)
[error] 370-370: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22.x' | ||
|
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.
Fix Node.js setup step syntax
The with
section has incorrect indentation and syntax.
- name: Set up Node.js
uses: actions/setup-node@v4
with:
- node-version: '22.x'
+ node-version: '22.x'
📝 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: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22.x' | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22.x' |
🧰 Tools
🪛 actionlint (1.7.3)
309-309: "with" section should not be empty. please remove this section if it's unnecessary
(syntax-check)
310-310: unexpected key "node-version" for "step" section. expected one of "continue-on-error", "env", "id", "if", "name", "run", "shell", "timeout-minutes", "uses", "with", "working-directory"
(syntax-check)
.github/workflows/pull-request.yml
Outdated
env: | ||
HEALTH_CHECK_URL: http://localhost:4000 | ||
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} | ||
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db | ||
REDIS_HOST: redis | ||
REDIS_PORT: 6379 | ||
ACCESS_TOKEN_SECRET: ${{ env.ACCESS_TOKEN_SECRET }} | ||
REFRESH_TOKEN_SECRET: ${{ env.REFRESH_TOKEN_SECRET }} | ||
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" | ||
COLORIZE_LOGS: "true" | ||
LOG_LEVEL: "info" |
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.
Fix environment variables configuration
- Replace
env
context withgithub
context for token secrets - Remove trailing spaces
env:
HEALTH_CHECK_URL: http://localhost:4000
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }}
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db
REDIS_HOST: redis
REDIS_PORT: 6379
- ACCESS_TOKEN_SECRET: ${{ env.ACCESS_TOKEN_SECRET }}
- REFRESH_TOKEN_SECRET: ${{ env.REFRESH_TOKEN_SECRET }}
+ ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }}
+ REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }}
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]"
COLORIZE_LOGS: "true"
- LOG_LEVEL: "info"
+ LOG_LEVEL: "info"
📝 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.
env: | |
HEALTH_CHECK_URL: http://localhost:4000 | |
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} | |
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db | |
REDIS_HOST: redis | |
REDIS_PORT: 6379 | |
ACCESS_TOKEN_SECRET: ${{ env.ACCESS_TOKEN_SECRET }} | |
REFRESH_TOKEN_SECRET: ${{ env.REFRESH_TOKEN_SECRET }} | |
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" | |
COLORIZE_LOGS: "true" | |
LOG_LEVEL: "info" | |
env: | |
HEALTH_CHECK_URL: http://localhost:4000 | |
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} | |
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db | |
REDIS_HOST: redis | |
REDIS_PORT: 6379 | |
ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }} | |
REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }} | |
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" | |
COLORIZE_LOGS: "true" | |
LOG_LEVEL: "info" |
🧰 Tools
🪛 actionlint (1.7.3)
366-366: context "env" is not allowed here. available contexts are "github", "inputs", "matrix", "needs", "secrets", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
(expression)
367-367: context "env" is not allowed here. available contexts are "github", "inputs", "matrix", "needs", "secrets", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
(expression)
🪛 yamllint (1.29.0-1)
[error] 370-370: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
- name: Check if Talawa API starts in Docker | ||
run: | | ||
# Ensure no containers are running | ||
docker-compose -f docker-compose.dev.yaml down -v || true | ||
|
||
# Start containers | ||
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | ||
echo "Failed to start containers" | ||
exit 1 | ||
fi | ||
|
||
# Wait for MongoDB and Redis to be ready | ||
echo "Waiting for MongoDB..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
echo "Waiting for Redis..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
# Wait for API to be healthy | ||
timeout=60 | ||
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://localhost:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | ||
echo "Waiting for API to start... ($timeout seconds remaining)" | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
if [ $timeout -eq 0 ]; then | ||
echo "Error: API failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "API started successfully" | ||
|
||
# Cleanup | ||
if ! docker-compose -f docker-compose.dev.yaml down -v; then | ||
echo "Failed to cleanup containers" | ||
exit 1 | ||
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
Enhance Docker health check implementation
The implementation needs improvements in error handling and container networking:
- Add timeout handling for MongoDB and Redis checks
- Use container DNS names instead of localhost
# Wait for MongoDB and Redis to be ready
echo "Waiting for MongoDB..."
timeout=30
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
- sleep 1
- ((timeout--))
+ sleep 1
+ ((timeout--))
done
+ if [ $timeout -eq 0 ]; then
+ echo "Error: MongoDB failed to start within timeout"
+ docker-compose -f docker-compose.dev.yaml logs mongodb
+ docker-compose -f docker-compose.dev.yaml down -v
+ exit 1
+ fi
echo "Waiting for Redis..."
timeout=30
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
- sleep 1
- ((timeout--))
+ sleep 1
+ ((timeout--))
done
+ if [ $timeout -eq 0 ]; then
+ echo "Error: Redis failed to start within timeout"
+ docker-compose -f docker-compose.dev.yaml logs redis
+ docker-compose -f docker-compose.dev.yaml down -v
+ exit 1
+ fi
# Wait for API to be healthy
timeout=60
- until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://localhost:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
+ until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://api:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
📝 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 if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
exit 1 | |
fi | |
# Wait for MongoDB and Redis to be ready | |
echo "Waiting for MongoDB..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
echo "Waiting for Redis..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
# Wait for API to be healthy | |
timeout=60 | |
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://localhost:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Cleanup | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Failed to cleanup containers" | |
exit 1 | |
fi | |
- name: Check if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
exit 1 | |
fi | |
# Wait for MongoDB and Redis to be ready | |
echo "Waiting for MongoDB..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: MongoDB failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs mongodb | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "Waiting for Redis..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: Redis failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs redis | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
# Wait for API to be healthy | |
timeout=60 | |
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://api:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Cleanup | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Failed to cleanup containers" | |
exit 1 | |
fi |
🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 337-337: trailing spaces
(trailing-spaces)
[error] 344-344: 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
🧹 Outside diff range and nitpick comments (3)
.github/workflows/pull-request.yml (3)
298-303
: Fix formatting issues in job configurationRemove trailing spaces from the following lines:
- Line 298: Empty line with trailing space
- Line 302: After
ubuntu-latest
- Line 303: Before
steps:
🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
304-310
: Add caching for node_modulesConsider adding caching for
node_modules
to improve workflow execution time. This is especially important since the job depends onTest-Application
which already has the cache.- name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '22.x' + + - name: Restore node_modules from cache + id: cache-npm + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + path: | + ~/.npm + node_modules + key: ${{ runner.os }}-docker-check-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-docker-check-${{ env.cache-name }}- + ${{ runner.os }}-docker-check- + ${{ runner.os }}-
372-382
: Fix environment variables configuration
- Remove trailing spaces from line 382
- Consider adding comments to document the purpose of each environment variable
- The
HEALTH_CHECK_URL
is not used in the script as it uses the container DNS nameenv: - HEALTH_CHECK_URL: http://localhost:4000 COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} + # MongoDB connection string using container DNS name MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db + # Redis connection details using container DNS names REDIS_HOST: redis REDIS_PORT: 6379 + # Dynamic secrets using repository name and commit SHA ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }} REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }} + # Application configuration LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" COLORIZE_LOGS: "true" - LOG_LEVEL: "info" + LOG_LEVEL: "info"🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 382-382: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint (1.29.0-1)
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
[error] 335-335: trailing spaces
(trailing-spaces)
[error] 349-349: trailing spaces
(trailing-spaces)
[error] 356-356: trailing spaces
(trailing-spaces)
[error] 382-382: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
- name: Check if Talawa API starts in Docker | ||
run: | | ||
# Ensure no containers are running | ||
docker-compose -f docker-compose.dev.yaml down -v || true | ||
|
||
# Start containers | ||
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | ||
echo "Failed to start containers" | ||
exit 1 | ||
fi | ||
|
||
# Wait for MongoDB and Redis to be ready | ||
echo "Waiting for MongoDB..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
if [ $timeout -eq 0 ]; then | ||
echo "Error: MongoDB failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs mongodb | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "Waiting for Redis..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
if [ $timeout -eq 0 ]; then | ||
echo "Error: Redis failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs redis | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
# Wait for API to be healthy | ||
timeout=60 | ||
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://api:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | ||
echo "Waiting for API to start... ($timeout seconds remaining)" | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
if [ $timeout -eq 0 ]; then | ||
echo "Error: API failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "API started successfully" | ||
|
||
# Cleanup | ||
if ! docker-compose -f docker-compose.dev.yaml down -v; then | ||
echo "Failed to cleanup containers" | ||
exit 1 | ||
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
Fix shell script implementation issues
- The shell script has inconsistent indentation which makes it harder to read
- Missing verification for docker-compose.dev.yaml
- Cleanup step could fail silently in some cases
- name: Check if Talawa API starts in Docker
run: |
# Ensure no containers are running
docker-compose -f docker-compose.dev.yaml down -v || true
+ # Verify docker-compose file exists
+ if [ ! -f "docker-compose.dev.yaml" ]; then
+ echo "Error: docker-compose.dev.yaml not found"
+ exit 1
+ fi
+
# Start containers
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then
echo "Failed to start containers"
exit 1
fi
# Wait for MongoDB and Redis to be ready
echo "Waiting for MongoDB..."
timeout=30
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: MongoDB failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs mongodb
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
echo "Waiting for Redis..."
timeout=30
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: Redis failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs redis
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
# Wait for API to be healthy
timeout=60
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://api:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
echo "Waiting for API to start... ($timeout seconds remaining)"
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: API failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
echo "API started successfully"
# Cleanup
- if ! docker-compose -f docker-compose.dev.yaml down -v; then
- echo "Failed to cleanup containers"
- exit 1
- fi
+ # Ensure cleanup runs even if the script fails
+ cleanup() {
+ echo "Cleaning up containers..."
+ if ! docker-compose -f docker-compose.dev.yaml down -v; then
+ echo "Warning: Failed to cleanup containers"
+ fi
+ }
+ trap cleanup EXIT
📝 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 if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
exit 1 | |
fi | |
# Wait for MongoDB and Redis to be ready | |
echo "Waiting for MongoDB..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: MongoDB failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs mongodb | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "Waiting for Redis..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: Redis failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs redis | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
# Wait for API to be healthy | |
timeout=60 | |
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://api:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Cleanup | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Failed to cleanup containers" | |
exit 1 | |
fi | |
- name: Check if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Verify docker-compose file exists | |
if [ ! -f "docker-compose.dev.yaml" ]; then | |
echo "Error: docker-compose.dev.yaml not found" | |
exit 1 | |
fi | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
exit 1 | |
fi | |
# Wait for MongoDB and Redis to be ready | |
echo "Waiting for MongoDB..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: MongoDB failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs mongodb | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "Waiting for Redis..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: Redis failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs redis | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
# Wait for API to be healthy | |
timeout=60 | |
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://api:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Cleanup | |
# Ensure cleanup runs even if the script fails | |
cleanup() { | |
echo "Cleaning up containers..." | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Warning: Failed to cleanup containers" | |
fi | |
} | |
trap cleanup EXIT |
🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 335-335: trailing spaces
(trailing-spaces)
[error] 349-349: trailing spaces
(trailing-spaces)
[error] 356-356: 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: 0
🧹 Outside diff range and nitpick comments (3)
.github/workflows/pull-request.yml (3)
298-311
: Fix formatting and optimize Node.js setup
- Remove trailing spaces on lines 298, 302, and 303
- Consider caching Node.js dependencies for faster builds
Add the cache step after Node.js setup:
- name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '22.x' + + - name: Cache Node.js dependencies + uses: actions/cache@v4 + with: + path: | + ~/.npm + node_modules + key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-docker-check-🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
375-385
: Add missing environment variables and fix formatting
- Remove trailing spaces on line 385
- Add missing environment variables for complete configuration
Add these environment variables:
env: HEALTH_CHECK_URL: http://localhost:4000 COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db REDIS_HOST: redis REDIS_PORT: 6379 ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }} REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }} LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" COLORIZE_LOGS: "true" - LOG_LEVEL: "info" + LOG_LEVEL: "info" + RECAPTCHA_SITE_KEY: ${{secrets.RECAPTCHA_SITE_KEY}} + RECAPTCHA_SECRET_KEY: ${{secrets.RECAPTCHA_SECRET_KEY}} + MAIL_USERNAME: ${{secrets.MAIL_USERNAME}} + MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}}🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 385-385: trailing spaces
(trailing-spaces)
299-386
: Overall implementation meets requirementsThe Docker-Check job successfully implements the PR objective of verifying that the Talawa API starts correctly in Docker. The implementation includes:
- Proper dependency on Test-Application job
- Robust health checks for all services
- Proper cleanup handling
- Appropriate environment configuration
Please address the suggested improvements in the previous comments for better reliability and maintainability.
Consider adding these enhancements in future PRs:
- Parallel execution of Test-Application and Docker-Check jobs
- Reusable workflow for Docker checks
- Artifact sharing between jobs for test results
🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
[error] 335-335: trailing spaces
(trailing-spaces)
[error] 349-349: trailing spaces
(trailing-spaces)
[error] 356-356: trailing spaces
(trailing-spaces)
[error] 385-385: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint (1.29.0-1)
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
[error] 335-335: trailing spaces
(trailing-spaces)
[error] 349-349: trailing spaces
(trailing-spaces)
[error] 356-356: trailing spaces
(trailing-spaces)
[error] 385-385: trailing spaces
(trailing-spaces)
🔇 Additional comments (1)
.github/workflows/pull-request.yml (1)
312-374
: LGTM with existing suggestions
The implementation is fundamentally sound. Please refer to the existing review comments for improvements in:
- Shell script robustness
- Error handling
- Container networking
🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 335-335: trailing spaces
(trailing-spaces)
[error] 349-349: trailing spaces
(trailing-spaces)
[error] 356-356: trailing spaces
(trailing-spaces)
Please make the requested changes so that coderabbit.ai approves |
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
🧹 Outside diff range and nitpick comments (3)
.github/workflows/pull-request.yml (3)
298-311
: Fix YAML formatting issuesThere are trailing spaces that need to be removed for better YAML formatting.
- - Docker-Check: - needs: Test-Application - runs-on: ubuntu-latest - - steps: + Docker-Check: + needs: Test-Application + runs-on: ubuntu-latest + steps:🧰 Tools
🪛 actionlint (1.7.4)
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
[error] 311-311: trailing spaces
(trailing-spaces)
322-384
: Enhance Docker health check implementationWhile the implementation is good, there are some improvements needed:
- Add verification for docker-compose file existence
- Improve error handling and logging
- Use consistent indentation in the script
- name: Check if Talawa API starts in Docker run: | # Ensure no containers are running docker-compose -f docker-compose.dev.yaml down -v || true + # Verify docker-compose file exists + if [ ! -f "docker-compose.dev.yaml" ]; then + echo "Error: docker-compose.dev.yaml not found" + exit 1 + fi + # Start containers if ! docker-compose -f docker-compose.dev.yaml up -d --build; then echo "Failed to start containers" + docker-compose -f docker-compose.dev.yaml logs exit 1 fi # Wait for MongoDB and Redis to be ready echo "Waiting for MongoDB..." timeout=30 - until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do - sleep 1 - ((timeout--)) + until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do + sleep 1 + ((timeout--)) done🧰 Tools
🪛 yamllint (1.35.1)
[error] 345-345: trailing spaces
(trailing-spaces)
[error] 359-359: trailing spaces
(trailing-spaces)
[error] 366-366: trailing spaces
(trailing-spaces)
385-399
: Fix trailing spaces in environment variablesThe environment variables configuration is good, but there are trailing spaces that should be removed.
env: HEALTH_CHECK_URL: http://localhost:4000 COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db REDIS_HOST: redis REDIS_PORT: 6379 ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }} REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }} LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" COLORIZE_LOGS: "true" LOG_LEVEL: "info" RECAPTCHA_SITE_KEY: ${{secrets.RECAPTCHA_SITE_KEY}} RECAPTCHA_SECRET_KEY: ${{secrets.RECAPTCHA_SECRET_KEY}} MAIL_USERNAME: ${{secrets.MAIL_USERNAME}} - MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}} + MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}}🧰 Tools
🪛 yamllint (1.35.1)
[error] 399-399: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
[error] 311-311: trailing spaces
(trailing-spaces)
[error] 312-312: syntax error: expected , but found ''
(syntax)
[error] 320-320: trailing spaces
(trailing-spaces)
[error] 345-345: trailing spaces
(trailing-spaces)
[error] 359-359: trailing spaces
(trailing-spaces)
[error] 366-366: trailing spaces
(trailing-spaces)
[error] 399-399: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
- name: Cache Node.js dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.npm | ||
node_modules | ||
key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-docker-check- | ||
|
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.
Fix cache step indentation
The cache step has incorrect indentation which could cause YAML parsing issues.
- - name: Cache Node.js dependencies
- uses: actions/cache@v4
- with:
- path: |
- ~/.npm
- node_modules
- key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }}
- restore-keys: |
- ${{ runner.os }}-docker-check-
+ - name: Cache Node.js dependencies
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.npm
+ node_modules
+ key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-docker-check-
📝 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: Cache Node.js dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.npm | |
node_modules | |
key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-docker-check- | |
- name: Cache Node.js dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.npm | |
node_modules | |
key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-docker-check- |
🧰 Tools
🪛 yamllint (1.35.1)
[error] 312-312: syntax error: expected , but found ''
(syntax)
[error] 320-320: 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: 0
🧹 Outside diff range and nitpick comments (1)
.github/workflows/pull-request.yml (1)
298-311
: Fix formatting issues in job definitionRemove trailing spaces from lines 302 and 303 to improve code cleanliness.
Docker-Check: needs: Test-Application - runs-on: ubuntu-latest - - steps: + runs-on: ubuntu-latest + steps:🧰 Tools
🪛 actionlint (1.7.4)
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
[error] 311-311: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
[error] 311-311: trailing spaces
(trailing-spaces)
[error] 312-312: syntax error: expected , but found ''
(syntax)
[error] 320-320: trailing spaces
(trailing-spaces)
[error] 345-345: trailing spaces
(trailing-spaces)
[error] 359-359: trailing spaces
(trailing-spaces)
[error] 366-366: trailing spaces
(trailing-spaces)
[error] 399-399: trailing spaces
(trailing-spaces)
🔇 Additional comments (4)
.github/workflows/pull-request.yml (4)
312-320
: Fix cache step indentation
The cache step has incorrect indentation which will cause YAML parsing errors.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 312-312: syntax error: expected , but found ''
(syntax)
[error] 320-320: trailing spaces
(trailing-spaces)
322-384
: Improve shell script implementation
The shell script needs improvements in error handling and file verification.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 345-345: trailing spaces
(trailing-spaces)
[error] 359-359: trailing spaces
(trailing-spaces)
[error] 366-366: trailing spaces
(trailing-spaces)
299-399
: Implementation achieves PR objectives
The Docker-Check job successfully implements the requirements from issue #2638:
- Verifies that Talawa API starts in Docker
- Fails if the app doesn't start correctly
- Includes proper health checks for all services
- Has robust error handling and cleanup
The implementation will prevent unstable code from being merged.
🧰 Tools
🪛 actionlint (1.7.4)
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 303-303: trailing spaces
(trailing-spaces)
[error] 311-311: trailing spaces
(trailing-spaces)
[error] 312-312: syntax error: expected , but found ''
(syntax)
[error] 320-320: trailing spaces
(trailing-spaces)
[error] 345-345: trailing spaces
(trailing-spaces)
[error] 359-359: trailing spaces
(trailing-spaces)
[error] 366-366: trailing spaces
(trailing-spaces)
[error] 399-399: trailing spaces
(trailing-spaces)
385-399
: Fix formatting and verify environment variables
- Remove trailing space from line 399
- Verify that all required environment variables are present for Docker environment
✅ Verification successful
Environment variables are correctly configured
The environment variables in the GitHub workflow file are properly configured and match the application's requirements. The verification shows:
-
All essential variables used in the codebase are present in the workflow:
- Database configuration (
MONGO_DB_URL
) - Redis configuration (
REDIS_HOST
,REDIS_PORT
) - Authentication secrets (
ACCESS_TOKEN_SECRET
,REFRESH_TOKEN_SECRET
) - Email configuration (
MAIL_USERNAME
,MAIL_PASSWORD
) - reCAPTCHA configuration (
RECAPTCHA_SITE_KEY
,RECAPTCHA_SECRET_KEY
) - Super admin configuration (
LAST_RESORT_SUPERADMIN_EMAIL
) - Logging configuration (
COLORIZE_LOGS
,LOG_LEVEL
)
- Database configuration (
-
The trailing space in line 399 is a minor formatting issue that doesn't affect functionality.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify environment variables in docker-compose.dev.yaml
# Check if docker-compose.dev.yaml exists and list required environment variables
if [ -f "docker-compose.dev.yaml" ]; then
echo "Required environment variables in docker-compose.dev.yaml:"
grep -E '^\s*-\s*\${.*}' docker-compose.dev.yaml
fi
Length of output: 214
Script:
#!/bin/bash
# Let's check for docker-compose files with different extensions
fd -e yml -e yaml docker-compose
# Then let's examine the content of these files for environment variables
echo "=== Checking environment variables in docker files ==="
for file in $(fd -e yml -e yaml docker-compose); do
echo "File: $file"
grep -E '^\s*environment:|^\s*env_file:|^\s*- \w+=' "$file" -A 5
done
# Also check for .env files that might list required variables
echo -e "\n=== Checking for .env files ==="
fd -g '.env*'
# Let's also check the main application code for environment usage
echo -e "\n=== Checking environment variables usage in code ==="
rg "process\.env\." -A 1
Length of output: 19248
🧰 Tools
🪛 yamllint (1.35.1)
[error] 399-399: 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
🧹 Outside diff range and nitpick comments (1)
.github/workflows/pull-request.yml (1)
391-406
: Environment variables configuration looks goodThe environment variables are properly configured with:
- Correct usage of GitHub context for secrets
- Proper container DNS names for database connections
- Appropriate token generation using repository name and SHA
Minor formatting issue: Remove trailing space in line 405.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 405-405: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 301-301: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 310-310: trailing spaces
(trailing-spaces)
[error] 311-311: syntax error: expected , but found ''
(syntax)
[error] 319-319: trailing spaces
(trailing-spaces)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 365-365: trailing spaces
(trailing-spaces)
[error] 372-372: trailing spaces
(trailing-spaces)
[error] 405-405: trailing spaces
(trailing-spaces)
🔇 Additional comments (2)
.github/workflows/pull-request.yml (2)
321-390
: 🛠️ Refactor suggestion
Enhance Docker health check implementation
The shell script needs improvements in error handling, container networking, and cleanup:
- Inconsistent indentation makes the script harder to read
- Health check should use container DNS names instead of localhost
- Missing proper error handling for service checks
- Cleanup could fail silently in some cases
Apply this diff to improve the implementation:
- name: Check if Talawa API starts in Docker
run: |
# Ensure no containers are running
docker-compose -f docker-compose.dev.yaml down -v || true
# Verify docker-compose file exists
if [ ! -f "docker-compose.dev.yaml" ]; then
echo "Error: docker-compose.dev.yaml not found"
exit 1
fi
# Start containers
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then
echo "Failed to start containers"
docker-compose -f docker-compose.dev.yaml logs
exit 1
fi
# Wait for MongoDB and Redis to be ready
echo "Waiting for MongoDB..."
timeout=30
- until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
+ until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongosh --quiet --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: MongoDB failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs mongodb
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
echo "Waiting for Redis..."
timeout=30
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: Redis failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs redis
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
# Wait for API to be healthy
timeout=60
- until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://localhost:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
+ until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://api:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
echo "Waiting for API to start... ($timeout seconds remaining)"
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: API failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
echo "API started successfully"
- # Cleanup
- if ! docker-compose -f docker-compose.dev.yaml down -v; then
- echo "Failed to cleanup containers"
- exit 1
- fi
+ # Ensure cleanup runs even if the script fails
+ cleanup() {
+ echo "Cleaning up containers..."
+ if ! docker-compose -f docker-compose.dev.yaml down -v; then
+ echo "Warning: Failed to cleanup containers"
+ fi
+ }
+ trap cleanup EXIT
Likely invalid or redundant comment.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 365-365: trailing spaces
(trailing-spaces)
[error] 372-372: trailing spaces
(trailing-spaces)
311-319
:
Fix YAML syntax errors in cache step
The cache step has incorrect indentation which will cause workflow failures.
Apply this diff to fix the indentation:
- - name: Cache Node.js dependencies
- uses: actions/cache@v4
- with:
- path: |
- ~/.npm
- node_modules
- key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }}
- restore-keys: |
- ${{ runner.os }}-docker-check-
+ - name: Cache Node.js dependencies
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.npm
+ node_modules
+ key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-docker-check-
Likely invalid or redundant comment.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 311-311: syntax error: expected , but found ''
(syntax)
[error] 319-319: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22.x' | ||
|
||
- name: Cache Node.js dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.npm | ||
node_modules | ||
key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-docker-check- | ||
|
||
- name: Check if Talawa API starts in Docker | ||
run: | | ||
# Ensure no containers are running | ||
docker-compose -f docker-compose.dev.yaml down -v || true | ||
|
||
# Verify docker-compose file exists | ||
if [ ! -f "docker-compose.dev.yaml" ]; then | ||
echo "Error: docker-compose.dev.yaml not found" | ||
exit 1 | ||
fi | ||
|
||
# Start containers | ||
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | ||
echo "Failed to start containers" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
exit 1 | ||
fi | ||
|
||
# Wait for MongoDB and Redis to be ready | ||
echo "Waiting for MongoDB..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
if [ $timeout -eq 0 ]; then | ||
echo "Error: MongoDB failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs mongodb | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "Waiting for Redis..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
if [ $timeout -eq 0 ]; then | ||
echo "Error: Redis failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs redis | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
# Wait for API to be healthy | ||
timeout=60 | ||
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://api:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | ||
echo "Waiting for API to start... ($timeout seconds remaining)" | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
if [ $timeout -eq 0 ]; then | ||
echo "Error: API failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "API started successfully" | ||
|
||
# Ensure cleanup runs even if the script fails | ||
cleanup() { | ||
echo "Cleaning up containers..." | ||
if ! docker-compose -f docker-compose.dev.yaml down -v; then | ||
echo "Warning: Failed to cleanup containers" | ||
fi | ||
} | ||
trap cleanup EXIT | ||
env: | ||
HEALTH_CHECK_URL: http://localhost:4000 | ||
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} | ||
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db | ||
REDIS_HOST: redis | ||
REDIS_PORT: 6379 | ||
ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }} | ||
REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }} | ||
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" | ||
COLORIZE_LOGS: "true" | ||
LOG_LEVEL: "info" | ||
RECAPTCHA_SITE_KEY: ${{secrets.RECAPTCHA_SITE_KEY}} | ||
RECAPTCHA_SECRET_KEY: ${{secrets.RECAPTCHA_SECRET_KEY}} | ||
MAIL_USERNAME: ${{secrets.MAIL_USERNAME}} | ||
MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}} | ||
|
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.
💡 Codebase verification
Docker configuration needs adjustments
The Docker configuration in the workflow doesn't align with the actual docker-compose.dev.yaml file:
- The workflow checks for service names
api
,mongodb
, andredis
, but the actual services are named:talawa-api-dev
(notapi
)mongodb
(correct)redis-stack-server
(notredis
)
- The health check URL in the workflow uses
http://api:4000
but should usehttp://talawa-api-dev:4000
- The Redis host environment variable in the workflow uses
redis
but should beredis-stack-server
🔗 Analysis chain
Verify Docker Compose configuration
The implementation successfully checks if Talawa API starts in Docker, but let's verify the Docker Compose configuration.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify Docker Compose configuration
# Check if docker-compose.dev.yaml exists and validate its syntax
if [ -f "docker-compose.dev.yaml" ]; then
echo "Validating docker-compose.dev.yaml..."
docker-compose -f docker-compose.dev.yaml config
else
echo "Error: docker-compose.dev.yaml not found"
exit 1
fi
# Check if required services are defined
echo "Checking required services..."
docker-compose -f docker-compose.dev.yaml config --services | grep -E '^(api|mongodb|redis)$'
Length of output: 548
Script:
#!/bin/bash
# Let's verify the Docker configuration by examining the docker-compose.dev.yaml file directly
if [ -f "docker-compose.dev.yaml" ]; then
echo "Content of docker-compose.dev.yaml:"
cat docker-compose.dev.yaml
else
echo "docker-compose.dev.yaml not found"
fi
# Also check if there are any other docker-compose files
echo -e "\nListing all docker-compose files:"
fd "docker-compose" --type f
Length of output: 1744
🧰 Tools
🪛 actionlint (1.7.4)
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
[error] 301-301: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 310-310: trailing spaces
(trailing-spaces)
[error] 311-311: syntax error: expected , but found ''
(syntax)
[error] 319-319: trailing spaces
(trailing-spaces)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 365-365: trailing spaces
(trailing-spaces)
[error] 372-372: trailing spaces
(trailing-spaces)
[error] 405-405: 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: 2
🧹 Outside diff range and nitpick comments (1)
.github/workflows/pull-request.yml (1)
391-406
: Fix trailing spaces in environment variablesThe environment variables section has trailing spaces that should be removed.
Apply this diff:
MAIL_USERNAME: ${{secrets.MAIL_USERNAME}} - MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}} + MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}}🧰 Tools
🪛 yamllint (1.35.1)
[error] 405-405: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 301-301: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 310-310: trailing spaces
(trailing-spaces)
[error] 311-311: syntax error: expected , but found ''
(syntax)
[warning] 314-314: wrong indentation: expected 9 but found 8
(indentation)
[error] 319-319: trailing spaces
(trailing-spaces)
[warning] 321-321: wrong indentation: expected 7 but found 6
(indentation)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 365-365: trailing spaces
(trailing-spaces)
[error] 372-372: trailing spaces
(trailing-spaces)
[error] 405-405: trailing spaces
(trailing-spaces)
🔇 Additional comments (2)
.github/workflows/pull-request.yml (2)
299-406
: Implementation meets requirements
The Docker check implementation successfully:
- Verifies if the Talawa API starts in Docker
- Implements proper timeout handling
- Includes cleanup mechanisms
- Sets required environment variables
After fixing the identified issues, this will effectively prevent unstable code from being merged.
🧰 Tools
🪛 actionlint (1.7.4)
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
[error] 301-301: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 310-310: trailing spaces
(trailing-spaces)
[error] 311-311: syntax error: expected , but found ''
(syntax)
[warning] 314-314: wrong indentation: expected 9 but found 8
(indentation)
[error] 319-319: trailing spaces
(trailing-spaces)
[warning] 321-321: wrong indentation: expected 7 but found 6
(indentation)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 365-365: trailing spaces
(trailing-spaces)
[error] 372-372: trailing spaces
(trailing-spaces)
[error] 405-405: trailing spaces
(trailing-spaces)
311-320
:
Fix cache step indentation and formatting
The cache step has incorrect indentation and trailing spaces:
Apply this diff:
- - name: Cache Node.js dependencies
- uses: actions/cache@v4
- with:
- path: |
- ~/.npm
- node_modules
- key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }}
- restore-keys: |
- ${{ runner.os }}-docker-check-
+ - name: Cache Node.js dependencies
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.npm
+ node_modules
+ key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-docker-check-
Likely invalid or redundant comment.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 311-311: syntax error: expected , but found ''
(syntax)
[warning] 314-314: wrong indentation: expected 9 but found 8
(indentation)
[error] 319-319: trailing spaces
(trailing-spaces)
|
||
Docker-Check: | ||
needs: Test-Application | ||
runs-on: ubuntu-latest | ||
steps: |
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.
Fix YAML syntax and formatting issues
The job definition has formatting issues that need to be fixed:
- Remove trailing spaces
- Fix indentation to match other jobs
Apply this diff:
-
- Docker-Check:
- needs: Test-Application
- runs-on: ubuntu-latest
- steps:
+ Docker-Check:
+ needs: Test-Application
+ runs-on: ubuntu-latest
+ steps:
📝 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.
Docker-Check: | |
needs: Test-Application | |
runs-on: ubuntu-latest | |
steps: | |
Docker-Check: | |
needs: Test-Application | |
runs-on: ubuntu-latest | |
steps: |
🧰 Tools
🪛 actionlint (1.7.4)
299-299: could not parse as YAML: yaml: line 299: did not find expected key
(syntax-check)
🪛 yamllint (1.35.1)
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 301-301: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
.github/workflows/pull-request.yml
Outdated
- name: Check if Talawa API starts in Docker | ||
run: | | ||
# Ensure no containers are running | ||
docker-compose -f docker-compose.dev.yaml down -v || true | ||
|
||
# Verify docker-compose file exists | ||
if [ ! -f "docker-compose.dev.yaml" ]; then | ||
echo "Error: docker-compose.dev.yaml not found" | ||
exit 1 | ||
fi | ||
|
||
# Start containers | ||
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | ||
echo "Failed to start containers" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
exit 1 | ||
fi | ||
|
||
# Wait for MongoDB and Redis to be ready | ||
echo "Waiting for MongoDB..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
if [ $timeout -eq 0 ]; then | ||
echo "Error: MongoDB failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs mongodb | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "Waiting for Redis..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
if [ $timeout -eq 0 ]; then | ||
echo "Error: Redis failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs redis | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
# Wait for TALAWA API to be healthy | ||
timeout=60 | ||
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://talawa-api-dev:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | ||
echo "Waiting for API to start... ($timeout seconds remaining)" | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
if [ $timeout -eq 0 ]; then | ||
echo "Error: API failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "API started successfully" | ||
|
||
# Ensure cleanup runs even if the script fails | ||
cleanup() { | ||
echo "Cleaning up containers..." | ||
if ! docker-compose -f docker-compose.dev.yaml down -v; then | ||
echo "Warning: Failed to cleanup containers" | ||
fi | ||
} | ||
trap cleanup EXIT |
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.
Fix Docker service names and health check configuration
The implementation needs to be adjusted to match the actual Docker Compose configuration:
- Service name
api
should betalawa-api-dev
- Service name
redis
should beredis-stack-server
- Health check URL should use correct service name
Apply this diff:
# Wait for Redis...
timeout=30
- until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
+ until docker-compose -f docker-compose.dev.yaml exec -T redis-stack-server redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: Redis failed to start within timeout"
- docker-compose -f docker-compose.dev.yaml logs redis
+ docker-compose -f docker-compose.dev.yaml logs redis-stack-server
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
# Wait for TALAWA API to be healthy
timeout=60
- until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://talawa-api-dev:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
+ until docker-compose -f docker-compose.dev.yaml exec -T talawa-api-dev curl -sf "http://talawa-api-dev:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
📝 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 if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Verify docker-compose file exists | |
if [ ! -f "docker-compose.dev.yaml" ]; then | |
echo "Error: docker-compose.dev.yaml not found" | |
exit 1 | |
fi | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
docker-compose -f docker-compose.dev.yaml logs | |
exit 1 | |
fi | |
# Wait for MongoDB and Redis to be ready | |
echo "Waiting for MongoDB..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: MongoDB failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs mongodb | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "Waiting for Redis..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: Redis failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs redis | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
# Wait for TALAWA API to be healthy | |
timeout=60 | |
until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://talawa-api-dev:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Ensure cleanup runs even if the script fails | |
cleanup() { | |
echo "Cleaning up containers..." | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Warning: Failed to cleanup containers" | |
fi | |
} | |
trap cleanup EXIT | |
- name: Check if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Verify docker-compose file exists | |
if [ ! -f "docker-compose.dev.yaml" ]; then | |
echo "Error: docker-compose.dev.yaml not found" | |
exit 1 | |
fi | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
docker-compose -f docker-compose.dev.yaml logs | |
exit 1 | |
fi | |
# Wait for MongoDB and Redis to be ready | |
echo "Waiting for MongoDB..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: MongoDB failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs mongodb | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "Waiting for Redis..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T redis-stack-server redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: Redis failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs redis-stack-server | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
# Wait for TALAWA API to be healthy | |
timeout=60 | |
until docker-compose -f docker-compose.dev.yaml exec -T talawa-api-dev curl -sf "http://talawa-api-dev:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Ensure cleanup runs even if the script fails | |
cleanup() { | |
echo "Cleaning up containers..." | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Warning: Failed to cleanup containers" | |
fi | |
} | |
trap cleanup EXIT |
🧰 Tools
🪛 yamllint (1.35.1)
[warning] 321-321: wrong indentation: expected 7 but found 6
(indentation)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 365-365: trailing spaces
(trailing-spaces)
[error] 372-372: 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: 2
🧹 Outside diff range and nitpick comments (2)
.github/workflows/pull-request.yml (2)
298-302
: Fix YAML formatting issues.Remove trailing spaces and fix indentation to match other jobs in the workflow.
- - Docker-Check: - needs: Test-Application - runs-on: ubuntu-latest - steps: + Docker-Check: + needs: Test-Application + runs-on: ubuntu-latest + steps:🧰 Tools
🪛 yamllint (1.35.1)
[error] 298-298: trailing spaces
(trailing-spaces)
[error] 301-301: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
312-319
: Fix cache step indentation.The
path
and other fields underwith
section need consistent indentation.- name: Cache Node.js dependencies uses: actions/cache@v4 with: - path: | - ~/.npm - node_modules - key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-docker-check- + path: | + ~/.npm + node_modules + key: ${{ runner.os }}-docker-check-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-docker-check-🧰 Tools
🪛 yamllint (1.35.1)
[warning] 314-314: wrong indentation: expected 10 but found 9
(indentation)
[error] 319-319: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 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] 298-298: trailing spaces
(trailing-spaces)
[error] 301-301: trailing spaces
(trailing-spaces)
[error] 302-302: trailing spaces
(trailing-spaces)
[error] 310-310: trailing spaces
(trailing-spaces)
[warning] 314-314: wrong indentation: expected 10 but found 9
(indentation)
[error] 319-319: trailing spaces
(trailing-spaces)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 365-365: trailing spaces
(trailing-spaces)
[error] 372-372: trailing spaces
(trailing-spaces)
[error] 405-405: trailing spaces
(trailing-spaces)
env: | ||
HEALTH_CHECK_URL: http://localhost:4000 | ||
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} | ||
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db | ||
REDIS_HOST: redis-stack-server | ||
REDIS_PORT: 6379 | ||
ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }} | ||
REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }} | ||
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" | ||
COLORIZE_LOGS: "true" | ||
LOG_LEVEL: "info" | ||
RECAPTCHA_SITE_KEY: ${{secrets.RECAPTCHA_SITE_KEY}} | ||
RECAPTCHA_SECRET_KEY: ${{secrets.RECAPTCHA_SECRET_KEY}} | ||
MAIL_USERNAME: ${{secrets.MAIL_USERNAME}} | ||
MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}} | ||
|
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
Fix environment variables configuration.
The environment variables need adjustments to match Docker service names:
env:
- HEALTH_CHECK_URL: http://localhost:4000
+ HEALTH_CHECK_URL: http://talawa-api-dev:4000
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }}
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db
- REDIS_HOST: redis
+ REDIS_HOST: redis-stack-server
REDIS_PORT: 6379
ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }}
REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }}
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]"
COLORIZE_LOGS: "true"
LOG_LEVEL: "info"
RECAPTCHA_SITE_KEY: ${{secrets.RECAPTCHA_SITE_KEY}}
RECAPTCHA_SECRET_KEY: ${{secrets.RECAPTCHA_SECRET_KEY}}
MAIL_USERNAME: ${{secrets.MAIL_USERNAME}}
- MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}}
+ MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}}
📝 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.
env: | |
HEALTH_CHECK_URL: http://localhost:4000 | |
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} | |
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db | |
REDIS_HOST: redis-stack-server | |
REDIS_PORT: 6379 | |
ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }} | |
REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }} | |
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" | |
COLORIZE_LOGS: "true" | |
LOG_LEVEL: "info" | |
RECAPTCHA_SITE_KEY: ${{secrets.RECAPTCHA_SITE_KEY}} | |
RECAPTCHA_SECRET_KEY: ${{secrets.RECAPTCHA_SECRET_KEY}} | |
MAIL_USERNAME: ${{secrets.MAIL_USERNAME}} | |
MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}} | |
env: | |
HEALTH_CHECK_URL: http://talawa-api-dev:4000 | |
COMPOSE_PROJECT_NAME: pr-${{ github.event.pull_request.number }} | |
MONGO_DB_URL: mongodb://mongodb:27017/talawa-test-db | |
REDIS_HOST: redis-stack-server | |
REDIS_PORT: 6379 | |
ACCESS_TOKEN_SECRET: ${{ github.event.repository.name }}_access_${{ github.sha }} | |
REFRESH_TOKEN_SECRET: ${{ github.event.repository.name }}_refresh_${{ github.sha }} | |
LAST_RESORT_SUPERADMIN_EMAIL: "[email protected]" | |
COLORIZE_LOGS: "true" | |
LOG_LEVEL: "info" | |
RECAPTCHA_SITE_KEY: ${{secrets.RECAPTCHA_SITE_KEY}} | |
RECAPTCHA_SECRET_KEY: ${{secrets.RECAPTCHA_SECRET_KEY}} | |
MAIL_USERNAME: ${{secrets.MAIL_USERNAME}} | |
MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}} |
🧰 Tools
🪛 yamllint (1.35.1)
[error] 405-405: trailing spaces
(trailing-spaces)
- name: Check if Talawa API starts in Docker | ||
run: | | ||
# Ensure no containers are running | ||
docker-compose -f docker-compose.dev.yaml down -v || true | ||
|
||
# Verify docker-compose file exists | ||
if [ ! -f "docker-compose.dev.yaml" ]; then | ||
echo "Error: docker-compose.dev.yaml not found" | ||
exit 1 | ||
fi | ||
|
||
# Start containers | ||
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | ||
echo "Failed to start containers" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
exit 1 | ||
fi | ||
|
||
# Wait for MongoDB and Redis to be ready | ||
echo "Waiting for MongoDB..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
if [ $timeout -eq 0 ]; then | ||
echo "Error: MongoDB failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs mongodb | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "Waiting for Redis..." | ||
timeout=30 | ||
until docker-compose -f docker-compose.dev.yaml exec -T redis-stack-server redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
if [ $timeout -eq 0 ]; then | ||
echo "Error: Redis failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs redis-stack-server | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
# Wait for TALAWA API to be healthy | ||
timeout=60 | ||
until docker-compose -f docker-compose.dev.yaml exec -T talawa-api-dev curl -sf "http://talawa-api-dev:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | ||
echo "Waiting for API to start... ($timeout seconds remaining)" | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
|
||
if [ $timeout -eq 0 ]; then | ||
echo "Error: API failed to start within timeout" | ||
docker-compose -f docker-compose.dev.yaml logs | ||
docker-compose -f docker-compose.dev.yaml down -v | ||
exit 1 | ||
fi | ||
|
||
echo "API started successfully" | ||
|
||
# Ensure cleanup runs even if the script fails | ||
cleanup() { | ||
echo "Cleaning up containers..." | ||
if ! docker-compose -f docker-compose.dev.yaml down -v; then | ||
echo "Warning: Failed to cleanup containers" | ||
fi | ||
} | ||
trap cleanup EXIT |
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 Docker health check implementation.
The implementation needs improvements:
- Service names should match docker-compose.dev.yaml
- Script indentation is inconsistent
- Add verification for docker-compose file contents
- name: Check if Talawa API starts in Docker
run: |
# Ensure no containers are running
docker-compose -f docker-compose.dev.yaml down -v || true
# Verify docker-compose file exists and validate contents
if [ ! -f "docker-compose.dev.yaml" ]; then
echo "Error: docker-compose.dev.yaml not found"
exit 1
fi
+ if ! docker-compose -f docker-compose.dev.yaml config > /dev/null; then
+ echo "Error: Invalid docker-compose.dev.yaml"
+ exit 1
+ fi
# Start containers
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then
echo "Failed to start containers"
docker-compose -f docker-compose.dev.yaml logs
exit 1
fi
# Wait for MongoDB and Redis to be ready
echo "Waiting for MongoDB..."
timeout=30
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: MongoDB failed to start within timeout"
docker-compose -f docker-compose.dev.yaml logs mongodb
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
echo "Waiting for Redis..."
timeout=30
- until docker-compose -f docker-compose.dev.yaml exec -T redis redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
+ until docker-compose -f docker-compose.dev.yaml exec -T redis-stack-server redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
sleep 1
((timeout--))
done
if [ $timeout -eq 0 ]; then
echo "Error: Redis failed to start within timeout"
- docker-compose -f docker-compose.dev.yaml logs redis
+ docker-compose -f docker-compose.dev.yaml logs redis-stack-server
docker-compose -f docker-compose.dev.yaml down -v
exit 1
fi
# Wait for API to be healthy
timeout=60
- until docker-compose -f docker-compose.dev.yaml exec -T api curl -sf "http://localhost:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
+ until docker-compose -f docker-compose.dev.yaml exec -T talawa-api-dev curl -sf "http://talawa-api-dev:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do
echo "Waiting for API to start... ($timeout seconds remaining)"
sleep 1
((timeout--))
done
📝 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 if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Verify docker-compose file exists | |
if [ ! -f "docker-compose.dev.yaml" ]; then | |
echo "Error: docker-compose.dev.yaml not found" | |
exit 1 | |
fi | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
docker-compose -f docker-compose.dev.yaml logs | |
exit 1 | |
fi | |
# Wait for MongoDB and Redis to be ready | |
echo "Waiting for MongoDB..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: MongoDB failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs mongodb | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "Waiting for Redis..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T redis-stack-server redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: Redis failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs redis-stack-server | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
# Wait for TALAWA API to be healthy | |
timeout=60 | |
until docker-compose -f docker-compose.dev.yaml exec -T talawa-api-dev curl -sf "http://talawa-api-dev:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: API failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "API started successfully" | |
# Ensure cleanup runs even if the script fails | |
cleanup() { | |
echo "Cleaning up containers..." | |
if ! docker-compose -f docker-compose.dev.yaml down -v; then | |
echo "Warning: Failed to cleanup containers" | |
fi | |
} | |
trap cleanup EXIT | |
- name: Check if Talawa API starts in Docker | |
run: | | |
# Ensure no containers are running | |
docker-compose -f docker-compose.dev.yaml down -v || true | |
# Verify docker-compose file exists and validate contents | |
if [ ! -f "docker-compose.dev.yaml" ]; then | |
echo "Error: docker-compose.dev.yaml not found" | |
exit 1 | |
fi | |
if ! docker-compose -f docker-compose.dev.yaml config > /dev/null; then | |
echo "Error: Invalid docker-compose.dev.yaml" | |
exit 1 | |
fi | |
# Start containers | |
if ! docker-compose -f docker-compose.dev.yaml up -d --build; then | |
echo "Failed to start containers" | |
docker-compose -f docker-compose.dev.yaml logs | |
exit 1 | |
fi | |
# Wait for MongoDB and Redis to be ready | |
echo "Waiting for MongoDB..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T mongodb mongo --eval "db.runCommand('ping').ok" >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: MongoDB failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs mongodb | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
echo "Waiting for Redis..." | |
timeout=30 | |
until docker-compose -f docker-compose.dev.yaml exec -T redis-stack-server redis-cli ping >/dev/null 2>&1 || [ $timeout -eq 0 ]; do | |
sleep 1 | |
((timeout--)) | |
done | |
if [ $timeout -eq 0 ]; then | |
echo "Error: Redis failed to start within timeout" | |
docker-compose -f docker-compose.dev.yaml logs redis-stack-server | |
docker-compose -f docker-compose.dev.yaml down -v | |
exit 1 | |
fi | |
# Wait for API to be healthy | |
timeout=60 | |
until docker-compose -f docker-compose.dev.yaml exec -T talawa-api-dev curl -sf "http://talawa-api-dev:4000/health" 2>/dev/null || [ $timeout -eq 0 ]; do | |
echo "Waiting for API to start... ($timeout seconds remaining)" | |
sleep 1 | |
((timeout--)) | |
done |
🧰 Tools
🪛 yamllint (1.35.1)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 365-365: trailing spaces
(trailing-spaces)
[error] 372-372: 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.
- Please ensure that CodeRabbit.ai approves the PR
- Make sure all tests pass
- Show that your work performs as expected by:
- Passing when the docker instance loads in the PR
- Failing when the instance fails to load in the PR.
This pull request did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please verify it has no conflicts with the develop branch and rebase if needed. Mention it now if you need help or give permission to other people to finish your work. |
Closing as abandoned |
What kind of change does this PR introduce?
refactoring
2638
Fixes #2638
If relevant, did you update the documentation?
Summary
This pr ensures that the pr workflow checks whether the talawa api app starts in docker and the workflow passes
Have you read the contributing guide?
Summary by CodeRabbit
New Features
Docker-Check
, to improve Docker container management during workflows.Improvements
Docker-Check
job.