Skip to content

People in projects #131

People in projects

People in projects #131

Workflow file for this run

on:
pull_request:
branches: [ main, master ]
paths:
- 'server/**'
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Run docker-compose up
run: |
docker-compose -f .github/docker-compose.yaml up -d
- name: Wait for Setup to complete (with timeout)
run: |
echo "Waiting for setup to complete..."
attempt=1
max_attempts=60 # Increased for complex migrations
while true; do
# Check container logs for completion message
if docker-compose -f .github/docker-compose.yaml logs setup | grep "PROCESS FINISHED" > /dev/null; then
echo "Setup has completed successfully."
break
fi
# Check for container exit
if ! docker-compose -f .github/docker-compose.yaml ps | grep -q "setup.*Up"; then
# Container exited, check if it was successful
if docker-compose -f .github/docker-compose.yaml logs setup | grep "PROCESS FINISHED" > /dev/null; then
echo "Setup completed and exited successfully."
break
else
echo "Setup container exited without completion message. Showing logs:"
docker-compose -f .github/docker-compose.yaml logs
exit 1
fi
fi
if [ $attempt -ge $max_attempts ]; then
echo "Setup did not complete within the expected time. Showing logs:"
docker-compose -f .github/docker-compose.yaml logs
exit 1
fi
echo "Attempt $attempt of $max_attempts: Setup still running. Waiting..."
sleep 10
attempt=$((attempt+1))
done
- name: Debug - Check PostgreSQL connection
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
echo "Attempting to connect to PostgreSQL..."
count=0
max_attempts=60
while [ $count -lt $max_attempts ]; do
if PGPASSWORD=abcd1234! pg_isready -h 127.0.0.1 -p 5433 -d server -U server_user > /dev/null 2>&1; then
echo "Connection to server database successful."
break
fi
echo "Connection attempt failed. Retrying in 3 seconds..."
sleep 3
count=$((count + 1))
done
if [ $count -eq $max_attempts ]; then
echo "Failed to connect after $max_attempts attempts."
docker-compose -f .github/docker-compose.yaml logs
exit 1
fi
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: |
cd server
npm ci
- name: Run Vitest tests
run: |
cd server
npm test
env:
DB_USER_SERVER: server_user
DB_PASSWORD_SERVER: abcd1234!
DB_NAME_SERVER: server
DB_HOST: 127.0.0.1
DB_PORT: 5433
APP_ENV: development
DB_TYPE: postgres
NODE_OPTIONS: --experimental-vm-modules
- name: Build
run: |
cd server
npm run build
env:
NODE_ENV: production
DB_USER_SERVER: server_user
DB_PASSWORD_SERVER: abcd1234!
DB_NAME_SERVER: server
DB_HOST: 127.0.0.1
DB_PORT: 5433
APP_ENV: development
DB_TYPE: postgres
NODE_OPTIONS: --experimental-vm-modules
- name: Cleanup
if: always()
run: |
docker-compose -f .github/docker-compose.yaml down -v