Skip to content

no time for fun commits, serious business here: delete functionality #6

no time for fun commits, serious business here: delete functionality

no time for fun commits, serious business here: delete functionality #6

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=20
while true; do
# Check if any container matching *setup* is still running
setup_status=$(docker ps --filter "name=setup" --format "{{.Names}}")
if [ -z "$setup_status" ]; then
echo "Setup has completed."
break
fi
if [ $attempt -ge $max_attempts ]; then
echo "Setup did not complete within the expected time. Failing the workflow."
exit 1
fi
echo "Attempt $attempt of $max_attempts: Setup still running. Waiting..."
sleep 5
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=50
while [ $count -lt $max_attempts ]; do
if PGPASSWORD=abcd1234! pg_isready -h 127.0.0.1 -U postgres -d postgres > /dev/null 2>&1; then
echo "Connection attempt successful."
break
else
echo "Connection attempt failed. Retrying in 2 seconds..."
sleep 2
count=$((count + 1))
fi
done
if [ $count -eq $max_attempts ]; then
echo "Failed to connect after $max_attempts attempts."
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
- name: Build
run: |
cd server
npm run build
env:
NODE_ENV: production
DB_USER_SERVER: postgres
DB_PASSWORD_SERVER: abcd1234!
DB_NAME_SERVER: server
DB_HOST: 127.0.0.1
DB_PORT: 5432