Skip to content

build(deps-dev): bump @solvro/config from 2.0.7 to 2.3.1 #454

build(deps-dev): bump @solvro/config from 2.0.7 to 2.3.1

build(deps-dev): bump @solvro/config from 2.0.7 to 2.3.1 #454

Workflow file for this run

name: CI
on:
push:
branches: ["main"]
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run prettier
run: pnpm run format:check
if: always()
- name: Run Lint
run: pnpm run lint
if: always()
- name: Run typecheck
run: pnpm run typecheck
if: always()
- name: Build
run: pnpm run build
if: always()
- name: Run commitlint check
if: always() && github.event_name == 'pull_request'
run: npx commitlint -f ${{ github.event.pull_request.base.sha }}
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Pull rabbitmq alpine image
run: docker pull rabbitmq:3.12.11-alpine
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm -r --filter '!fetch-microservice' test
migrations:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
strategy:
fail-fast: false
matrix:
service:
- name: restapi-macroservice
db: restapi_db
- name: chat-microservice
db: chat_service
- name: gift-ideas-microservice
db: gift_ideas_service
- name: reranking-microservice
db: reranking_service
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create database
run: |
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE DATABASE ${{ matrix.service.db }};"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Test ${{ matrix.service.name }} migrations - Run up
working-directory: backend/${{ matrix.service.name }}
run: pnpm migration:run
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/${{ matrix.service.db }}
- name: Test ${{ matrix.service.name }} migrations - Show status
working-directory: backend/${{ matrix.service.name }}
run: pnpm migration:show
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/${{ matrix.service.db }}
- name: Test ${{ matrix.service.name }} migrations - Run down (revert all)
working-directory: backend/${{ matrix.service.name }}
run: |
# Revert all migrations (keep reverting until no more migrations to revert)
while pnpm migration:show 2>&1 | grep -q '\[X\]'; do
echo "Reverting migration..."
pnpm migration:revert
done
echo "✅ All migrations reverted"
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/${{ matrix.service.db }}
- name: Test ${{ matrix.service.name }} migrations - Run up again
working-directory: backend/${{ matrix.service.name }}
run: pnpm migration:run
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/${{ matrix.service.db }}
- name: Verify schema is up to date
working-directory: backend/${{ matrix.service.name }}
run: |
output=$(pnpm migration:check 2>&1)
echo "$output"
if echo "$output" | grep -q "Your schema is up to date - there are no queries to be executed by schema synchronization"; then
echo "✅ Schema is up to date - no pending migrations"
else
echo "⚠️ Schema drift detected or queries need to be executed:"
echo "$output"
echo ""
echo "❌ Schema is not synchronized with migrations. Please generate a new migration."
exit 1
fi
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/${{ matrix.service.db }}
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test Docker Compose configuration
run: |
cd deployment
# Validate configuration can be parsed
docker compose -f docker-compose.prod.yml --env-file .unencrypted-env.test config --quiet
echo "✅ Docker Compose configuration is valid"
- name: Build backend Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./deployment/Dockerfile
push: false
load: true
tags: ai-present-finder:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build frontend Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./deployment/frontend.Dockerfile
push: false
load: true
tags: ai-present-finder-frontend:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test backend container startup
run: |
# Start the backend container with minimal required env vars
docker run -d --name test-backend \
-e NODE_ENV=production \
-e CLOUDAMQP_URL=amqp://guest:guest@localhost:5672 \
-e OPENAI_API_KEY=sk-test-dummy-key \
-e BRIGHTDATA_API_KEY=test-key \
ai-present-finder:test
# Wait for PM2 to start services
sleep 10
# Check if container is still running
if docker ps | grep -q test-backend; then
echo "✅ Backend container is running"
# Check PM2 process status
echo "📊 PM2 process status:"
docker exec test-backend pm2 list || echo "⚠️ Could not get PM2 status"
# Show logs
echo "📝 Container logs (last 30 lines):"
docker logs test-backend --tail=30
docker stop test-backend
docker rm test-backend
else
echo "❌ Backend container crashed"
docker logs test-backend
docker rm -f test-backend
exit 1
fi
- name: Test frontend container startup
run: |
# Start the frontend container briefly to test it starts
docker run --rm -d --name test-frontend -p 8080:80 ai-present-finder-frontend:test
# Wait a moment for startup
sleep 10
# Check if container is still running (not crashed)
if docker ps | grep -q test-frontend; then
echo "✅ Frontend container started successfully"
# Test that nginx health endpoint is responding
if curl -f http://localhost:8080/health > /dev/null 2>&1; then
echo "✅ Frontend HTTP health endpoint responding"
else
echo "❌ Frontend HTTP health endpoint not responding"
docker logs test-frontend
exit 1
fi
docker stop test-frontend
else
echo "❌ Frontend container failed to start"
docker logs test-frontend
exit 1
fi
- name: Validate Docker image security
run: |
echo "🔍 Checking for security issues in Docker images..."
# Check backend image
echo "Backend image analysis:"
docker run --rm ai-present-finder:test sh -c "
echo 'Node version:' && node --version
echo 'PM2 version:' && pm2 --version
echo 'Checking for vulnerable packages...'
if command -v npm >/dev/null 2>&1; then
npm audit --audit-level=moderate --production || echo '⚠️ Some moderate vulnerabilities found'
fi
" || echo "⚠️ Could not run security checks on backend"
# Check frontend image
echo "Frontend image analysis:"
docker run --rm ai-present-finder-frontend:test sh -c "
echo 'Nginx version:' && nginx -v
echo 'Checking nginx configuration...'
nginx -t || exit 1
" || echo "⚠️ Could not run security checks on frontend"
- name: Test Docker Compose services startup
run: |
cd deployment
echo "🚀 Testing Docker Compose services startup..."
# Start services with production compose file
if docker compose -f docker-compose.prod.yml --env-file .unencrypted-env.test up -d --wait; then
echo "✅ All services started successfully"
else
echo "❌ Docker Compose services failed to start"
echo "📝 Service logs:"
docker compose -f docker-compose.prod.yml --env-file .unencrypted-env.test logs
echo "📊 Service status:"
docker compose -f docker-compose.prod.yml --env-file .unencrypted-env.test ps -a
# Save logs to file for artifact
mkdir -p ../docker-compose-logs
docker compose -f docker-compose.prod.yml --env-file .unencrypted-env.test logs > ../docker-compose-logs/all-services.log 2>&1
docker compose -f docker-compose.prod.yml --env-file .unencrypted-env.test ps -a > ../docker-compose-logs/services-status.txt 2>&1
docker compose -f docker-compose.prod.yml --env-file .unencrypted-env.test down -v
exit 1
fi
# Clean up
echo "🧹 Cleaning up..."
docker compose -f docker-compose.prod.yml --env-file .unencrypted-env.test down -v
- name: Upload Docker Compose logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: docker-compose-logs
path: docker-compose-logs/
retention-days: 7
docker-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Hadolint
run: |
wget -O hadolint https://github.com/hadolint/hadolint/releases/latest/download/hadolint-Linux-x86_64
chmod +x hadolint
sudo mv hadolint /usr/local/bin/
- name: Lint backend Dockerfile
run: hadolint deployment/Dockerfile
if: always()
- name: Lint frontend Dockerfile
run: hadolint deployment/frontend.Dockerfile
if: always()
- name: Validate Docker Compose schema
if: always()
run: |
# Install dependencies for schema validation
python -m pip install --upgrade pip
python -m pip install pyyaml jsonschema
# Validate docker-compose.prod.yml
cd deployment
python - <<'PYTHON'
import yaml
import jsonschema
from urllib.request import urlopen
# Load compose file
with open('docker-compose.prod.yml', 'r', encoding='utf-8') as f:
compose = yaml.safe_load(f)
# Load schema
schema_url = 'https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json'
with urlopen(schema_url) as response:
schema = yaml.safe_load(response)
# Validate
jsonschema.validate(compose, schema)
print('✅ Docker Compose schema validation passed')
PYTHON