Skip to content
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
merged 61 commits into from
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 Dec 14, 2024
4fa5812
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 14, 2024
6ca6131
syntax errors
prayanshchh Dec 14, 2024
57ae541
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh Dec 14, 2024
cfec867
suggestion-1
prayanshchh Dec 14, 2024
1544502
indentation 1
prayanshchh Dec 14, 2024
0b6ef08
indentation 2
prayanshchh Dec 14, 2024
d8db396
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 16, 2024
4adec1f
removing unions file
prayanshchh Dec 19, 2024
45b7fcc
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh Dec 19, 2024
338a7b8
fixing tests
prayanshchh Dec 21, 2024
bb63fc2
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 21, 2024
d540981
docker-compose issue
prayanshchh Dec 21, 2024
5c54d6a
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh Dec 21, 2024
c942e2c
increasing timeout
prayanshchh Dec 22, 2024
fbbb7ea
test fix
prayanshchh Dec 22, 2024
798b4f7
using mongosh
prayanshchh Dec 22, 2024
05f9c97
idenation fix
prayanshchh Dec 22, 2024
006092e
pwd variable fix, redi-stack-server fix
prayanshchh Dec 23, 2024
1c57fba
health-check-api
prayanshchh Dec 23, 2024
08c8d16
api fix
prayanshchh Dec 23, 2024
548e83b
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 23, 2024
a228c07
removing unnecessary files
prayanshchh Dec 23, 2024
4c7280c
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh Dec 23, 2024
67baf1b
fixing replic-set issues
prayanshchh Dec 27, 2024
04ba4b2
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 27, 2024
a22e41d
fixing workflow
prayanshchh Dec 27, 2024
e455a7c
identation
prayanshchh Dec 27, 2024
01e8d37
indentaion fix
prayanshchh Dec 27, 2024
22e66be
merge 2
prayanshchh Dec 27, 2024
31a7dff
idenation fix 2
prayanshchh Dec 27, 2024
1a53bab
correction mongo build
prayanshchh Dec 27, 2024
d62920f
suggestions
prayanshchh Dec 27, 2024
5d8cdd9
fixing build error
prayanshchh Dec 27, 2024
cfcd134
error fix
prayanshchh Dec 27, 2024
a1425e0
error fix
prayanshchh Dec 27, 2024
cd44d42
ai suggestions
prayanshchh Dec 27, 2024
9b300e1
added caddy service
prayanshchh Dec 27, 2024
94fad12
suggestions
prayanshchh Dec 27, 2024
baaa36d
simpler config for replSet
prayanshchh Dec 29, 2024
a8a121d
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 29, 2024
5cf642a
env fix
prayanshchh Dec 29, 2024
ef036d7
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh Dec 29, 2024
5e6a5e9
suggestion
prayanshchh Dec 29, 2024
8c9d690
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh Dec 29, 2024
481b979
final fix
prayanshchh Dec 29, 2024
717ad62
suggestions
prayanshchh Dec 29, 2024
5ccabab
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 29, 2024
4457277
last suggestions
prayanshchh Dec 29, 2024
0dc1c72
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh Dec 29, 2024
6cc3161
sytnax error
prayanshchh Dec 29, 2024
626991c
line continuation
prayanshchh Dec 29, 2024
75939ab
revert suggestions
prayanshchh Dec 30, 2024
e86129c
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 30, 2024
18d47a8
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 31, 2024
a73ab60
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 31, 2024
577175f
db connection
prayanshchh Dec 31, 2024
78fab42
Merge branch 'api_fail_docker' of https://github.com/prayanshchh/pray…
prayanshchh Dec 31, 2024
89f67dd
eslint removal
prayanshchh Dec 31, 2024
4cfccd0
Merge branch 'develop' into api_fail_docker
prayanshchh Dec 31, 2024
6841b72
fix failing tests
prayanshchh Jan 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 110 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please create a .github/workflows/scripts directory
  2. Move this to a script located there
  3. Reference the script in .github/workflows/pull-request.yml

It'll make maintenance easier in future

Copy link
Contributor Author

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

# 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'
Expand Down
Loading