-
-
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
workflow which ensures that talawa Api app starts in docker #2759
Merged
palisadoes
merged 61 commits into
PalisadoesFoundation:develop
from
prayanshchh:api_fail_docker
Jan 1, 2025
Merged
Changes from 4 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
64bee20
added workflow
prayanshchh 4fa5812
Merge branch 'develop' into api_fail_docker
prayanshchh 6ca6131
syntax errors
prayanshchh 57ae541
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh cfec867
suggestion-1
prayanshchh 1544502
indentation 1
prayanshchh 0b6ef08
indentation 2
prayanshchh d8db396
Merge branch 'develop' into api_fail_docker
prayanshchh 4adec1f
removing unions file
prayanshchh 45b7fcc
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh 338a7b8
fixing tests
prayanshchh bb63fc2
Merge branch 'develop' into api_fail_docker
prayanshchh d540981
docker-compose issue
prayanshchh 5c54d6a
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh c942e2c
increasing timeout
prayanshchh fbbb7ea
test fix
prayanshchh 798b4f7
using mongosh
prayanshchh 05f9c97
idenation fix
prayanshchh 006092e
pwd variable fix, redi-stack-server fix
prayanshchh 1c57fba
health-check-api
prayanshchh 08c8d16
api fix
prayanshchh 548e83b
Merge branch 'develop' into api_fail_docker
prayanshchh a228c07
removing unnecessary files
prayanshchh 4c7280c
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh 67baf1b
fixing replic-set issues
prayanshchh 04ba4b2
Merge branch 'develop' into api_fail_docker
prayanshchh a22e41d
fixing workflow
prayanshchh e455a7c
identation
prayanshchh 01e8d37
indentaion fix
prayanshchh 22e66be
merge 2
prayanshchh 31a7dff
idenation fix 2
prayanshchh 1a53bab
correction mongo build
prayanshchh d62920f
suggestions
prayanshchh 5d8cdd9
fixing build error
prayanshchh cfcd134
error fix
prayanshchh a1425e0
error fix
prayanshchh cd44d42
ai suggestions
prayanshchh 9b300e1
added caddy service
prayanshchh 94fad12
suggestions
prayanshchh baaa36d
simpler config for replSet
prayanshchh a8a121d
Merge branch 'develop' into api_fail_docker
prayanshchh 5cf642a
env fix
prayanshchh ef036d7
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh 5e6a5e9
suggestion
prayanshchh 8c9d690
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh 481b979
final fix
prayanshchh 717ad62
suggestions
prayanshchh 5ccabab
Merge branch 'develop' into api_fail_docker
prayanshchh 4457277
last suggestions
prayanshchh 0dc1c72
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh 6cc3161
sytnax error
prayanshchh 626991c
line continuation
prayanshchh 75939ab
revert suggestions
prayanshchh e86129c
Merge branch 'develop' into api_fail_docker
prayanshchh 18d47a8
Merge branch 'develop' into api_fail_docker
prayanshchh a73ab60
Merge branch 'develop' into api_fail_docker
prayanshchh 577175f
db connection
prayanshchh 78fab42
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh 89f67dd
eslint removal
prayanshchh 4cfccd0
Merge branch 'develop' into api_fail_docker
prayanshchh 6841b72
fix failing tests
prayanshchh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,7 +295,116 @@ jobs: | |
with: | ||
path: './coverage/lcov.info' | ||
min_coverage: 95.0 | ||
|
||
|
||
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' | ||
|
||
- 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 ! timeout 300 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 | ||
prayanshchh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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 | ||
prayanshchh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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>&1 || [ $timeout -eq 0 ]; do | ||
echo "Waiting for API to start... ($timeout seconds remaining)" | ||
sleep 1 | ||
((timeout--)) | ||
done | ||
prayanshchh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 | ||
} | ||
prayanshchh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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-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}} | ||
|
||
prayanshchh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
JSDocs: | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
name: 'JSDocs comments and pipeline' | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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/scripts
directory.github/workflows/pull-request.yml
It'll make maintenance easier in future
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.
alright will create a new file for the docker script and reference it in this file