-
-
Notifications
You must be signed in to change notification settings - Fork 807
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
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -255,6 +255,14 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Run the tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: npm run test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- 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 commentThe 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:
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:
📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Start the development server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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:
Test-Application
: Run tests locally (existing)Docker-Check
: Run Docker validation (new)This separation will: