-
-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6e7ac9
commit 64bee20
Showing
1 changed file
with
110 additions
and
1 deletion.
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 | ||
users: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
- users: 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-stack-server redis-cli ping >dev/null 2>&1 || [ $timemout -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 | ||
|
||
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-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}} | ||
|
||
JSDocs: | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
name: 'JSDocs comments and pipeline' | ||
|