Files
2026-09-10 02:30:45 -04:00

88 lines
3.4 KiB
YAML

name: Quality
on:
push:
branches: [develop]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- name: Start integration services
env:
POSTGRES_PASSWORD: ci-password
POSTGRES_DB: pokemon_inventory
POSTGRES_USER: pokemon_inventory
POSTGRES_PORT: 5433
REDIS_PORT: 6380
run: |
cat > .env <<'EOF'
API_PORT=3000
DATABASE_URL=postgresql://pokemon_inventory:ci-password@localhost:5433/pokemon_inventory
POSTGRES_DB=pokemon_inventory
POSTGRES_PASSWORD=ci-password
POSTGRES_PORT=5433
POSTGRES_USER=pokemon_inventory
REDIS_PORT=6380
REDIS_URL=redis://localhost:6380
TEST_DATABASE_URL=postgresql://pokemon_inventory:ci-password@localhost:5433/pokemon_inventory_test
TEST_REDIS_URL=redis://localhost:6380
SMTP_URL=smtp://localhost:1025
SMTP_FROM=no-reply@example.test
MFA_ENCRYPTION_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
PRICING_FIXTURE_PROVIDER_ENABLED=true
INITIAL_ADMIN_EMAIL=ci-admin@example.test
INITIAL_ADMIN_PASSWORD=CiPassword123!
INITIAL_SELLER_NAME=CI Catalog Owner
EOF
npm run db:up
docker compose exec -T postgres createdb -U pokemon_inventory pokemon_inventory_test || true
DATABASE_URL=postgresql://pokemon_inventory:ci-password@localhost:5433/pokemon_inventory_test npm run db:migrate
- run: npx playwright install --with-deps chromium
- run: npm test
- name: Run worker tests
run: npm run test --workspace=@pokemon-inventory/worker
- name: Audit production dependencies
run: npm audit --omit=dev
- name: Validate deployment scripts
run: |
sh -n scripts/*.sh
sh scripts/deployment-health-wait.test.sh
sh scripts/verify-postgres-backup.test.sh
sh scripts/restore-postgres.test.sh
sh scripts/restore-image-storage.test.sh
sh scripts/smoke-production.test.sh
sh scripts/validate-production-env.test.sh
- name: Run integration tests
env:
TEST_DATABASE_URL: postgresql://pokemon_inventory:ci-password@localhost:5433/pokemon_inventory_test
TEST_REDIS_URL: redis://localhost:6380
run: npm run test:integration
- name: Start application for E2E tests
run: |
nohup npm run dev > /tmp/pokemon-inventory-dev.log 2>&1 &
echo $! > /tmp/pokemon-inventory-dev.pid
npx wait-on http://localhost:3000/health http://localhost:5173/
npm run provision:admin
- name: Run authenticated E2E tests
env:
INITIAL_ADMIN_EMAIL: ci-admin@example.test
INITIAL_ADMIN_PASSWORD: CiPassword123!
run: npm run test:e2e
- name: Stop application and services
if: always()
run: |
if [ -f /tmp/pokemon-inventory-dev.pid ]; then kill "$(cat /tmp/pokemon-inventory-dev.pid)" || true; fi
docker compose down -v
- run: npm run test --workspace=@pokemon-inventory/web
- run: npm run build --workspace=@pokemon-inventory/web
- run: npm run build-storybook --workspace=@pokemon-inventory/web
- run: npm run test-storybook