Skip to content

Commit 33d5b7b

Browse files
Add devcontainer workflow (PalisadoesFoundation#3454)
Co-authored-by: Peter Harrison <[email protected]>
1 parent b92360e commit 33d5b7b

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/pull-request.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,56 @@ jobs:
348348
echo "- Contributor may be merging into an incorrect branch."
349349
echo "- Source branch may be incorrect please use develop as source branch."
350350
exit 1
351+
352+
Check-App-Startup:
353+
name: Check App Startup and Health
354+
runs-on: ubuntu-latest
355+
needs: [Run-Tests]
356+
steps:
357+
- name: Checkout repository
358+
uses: actions/[email protected]
359+
- name: Install Devcontainer CLI
360+
run: npm install -g @devcontainers/cli
361+
- name: Copy devcontainer environment file
362+
run: cp envFiles/.env.devcontainer .env
363+
- name: Bring up devcontainer
364+
run: devcontainer up --workspace-folder .
365+
- name: Wait for Devcontainer to be ready
366+
run: |
367+
echo "Waiting for devcontainer services to be ready..."
368+
sleep 10
369+
- name: Verify Running Containers
370+
run: docker ps
371+
- name: Install dependencies inside the container
372+
run: docker exec talawa-api-1 /bin/bash -c 'pnpm install'
373+
- name: Start server and monitor logs
374+
run: |
375+
docker exec talawa-api-1 /bin/bash -c 'pnpm run start_development_server' &
376+
sleep 10
377+
- name: Wait for GraphQL endpoint to become available
378+
if: always()
379+
run: |
380+
echo "Waiting for the GraphQL endpoint to become available..."
381+
for i in {1..60}; do
382+
# Check if container exists first
383+
if ! docker ps | grep -q talawa-api-1; then
384+
echo "Container talawa-api-1 not found. Waiting..."
385+
sleep 2
386+
continue
387+
fi
388+
docker exec talawa-api-1 which curl >/dev/null 2>&1 || {
389+
docker exec talawa-api-1 apt-get update && docker exec talawa-api-1 apt-get install -y curl
390+
}
391+
RESPONSE=$(docker exec talawa-api-1 curl -s -X POST http://127.0.0.1:4000/graphql -H "Content-Type: application/json" -d '{"query":"{__typename}"}' 2>/dev/null || echo "Connection failed")
392+
if echo "$RESPONSE" | grep -q '__typename'; then
393+
echo "GraphQL endpoint is available!"
394+
exit 0
395+
fi
396+
echo "GraphQL endpoint not ready. Retrying in 2 seconds..."
397+
sleep 2
398+
done
399+
echo "GraphQL endpoint did not become available within the expected time."
400+
exit 1
401+
- name: Cleanup - Free ports by stopping containers
402+
if: always()
403+
run: docker compose down

0 commit comments

Comments
 (0)