Root cause: the ci.yml e2e job had JWT_SECRET (23 chars) and
JWT_REFRESH_SECRET (27 chars), both below the MIN_SECRET_LENGTH=32
enforced by env-validation.ts. The API webServer refused to start with
"Insecure JWT secret configuration", so every E2E test failed with
ERR_CONNECTION_REFUSED before a single assertion ran.
Fixes in this commit:
1. .github/workflows/ci.yml — sync e2e job env with the working
standalone e2e.yml:
• JWT secrets lengthened past 32-char minimum
• Add API_PORT / WEB_PORT / *_BASE_URL for Playwright webServer
• Add REDIS_HOST/PORT, TYPESENSE_PROTOCOL, JWT_EXPIRES_IN,
BCRYPT_ROUNDS, GOOGLE_*/ZALO_* OAuth stubs
• VNPAY_HASH_SECRET lengthened to 32 chars
• MINIO creds use vars fallback pattern (matches e2e.yml)
2. phone-login-otp-requested.event.ts + .listener.ts — the notifications
module imported PhoneLoginOtpRequestedListener but neither the event
class nor the listener file existed, causing module-resolution errors
in four unrelated test suites that import notifications.module.ts.
3. create-payment.handler.spec.ts — inject mockSbvCompliance so the two
handler tests that were TypeError-ing on undefined.error() pass.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
303 lines
8.5 KiB
YAML
303 lines
8.5 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
ci:
|
|
name: Lint → Typecheck → Test → Build
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
node-version: [22]
|
|
|
|
services:
|
|
postgres:
|
|
image: postgis/postgis:16-3.4
|
|
env:
|
|
POSTGRES_DB: goodgo_test
|
|
POSTGRES_USER: goodgo
|
|
POSTGRES_PASSWORD: goodgo_test_secret
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd "pg_isready -U goodgo -d goodgo_test"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
--health-start-period 30s
|
|
|
|
env:
|
|
DATABASE_URL: postgresql://goodgo:goodgo_test_secret@localhost:5432/goodgo_test
|
|
NODE_ENV: test
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
|
|
- name: Setup Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Generate Prisma client
|
|
run: pnpm db:generate
|
|
|
|
- name: Lint
|
|
run: pnpm lint
|
|
|
|
- name: Typecheck
|
|
run: pnpm typecheck
|
|
|
|
- name: Test
|
|
run: pnpm test
|
|
|
|
- name: Build
|
|
run: pnpm build
|
|
|
|
ai-services:
|
|
name: AI Services (Python) — Smoke
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
defaults:
|
|
run:
|
|
working-directory: libs/ai-services
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
cache: pip
|
|
cache-dependency-path: libs/ai-services/pyproject.toml
|
|
|
|
- name: Install dependencies (runtime + dev, no underthesea)
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install \
|
|
"fastapi==0.115.0" \
|
|
"uvicorn[standard]==0.32.0" \
|
|
"xgboost==2.1.0" \
|
|
"numpy==1.26.4" \
|
|
"pydantic==2.9.0" \
|
|
"pydantic-settings==2.5.0" \
|
|
"httpx==0.27.0" \
|
|
"slowapi==0.1.9" \
|
|
"scikit-learn>=1.5.0" \
|
|
"pytest>=8.3.0" \
|
|
"pytest-asyncio>=0.24.0"
|
|
|
|
- name: Pytest (unit + health smoke)
|
|
env:
|
|
AI_CORS_ORIGINS: http://localhost:3000
|
|
run: pytest -q --ignore=tests/test_nlp.py
|
|
|
|
- name: Boot FastAPI + /health smoke
|
|
env:
|
|
AI_CORS_ORIGINS: http://localhost:3000
|
|
run: |
|
|
uvicorn app.main:app --host 127.0.0.1 --port 8000 &
|
|
PID=$!
|
|
for i in 1 2 3 4 5 6 7 8 9 10; do
|
|
if curl -sf http://127.0.0.1:8000/health; then
|
|
echo "health ok"
|
|
kill $PID
|
|
exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo "health failed"
|
|
kill $PID || true
|
|
exit 1
|
|
|
|
- name: OpenAPI schema export (verifies /predict routes)
|
|
env:
|
|
AI_CORS_ORIGINS: http://localhost:3000
|
|
run: |
|
|
python - <<'PY'
|
|
import json, sys
|
|
from app.main import app
|
|
schema = app.openapi()
|
|
paths = schema.get("paths", {})
|
|
required = ["/avm/predict", "/avm/v2/predict", "/avm/industrial/predict", "/moderation/check", "/neighborhood/score"]
|
|
missing = [p for p in required if p not in paths]
|
|
if missing:
|
|
print("MISSING OpenAPI paths:", missing)
|
|
sys.exit(1)
|
|
print("OpenAPI paths OK:", sorted(paths.keys()))
|
|
PY
|
|
|
|
e2e:
|
|
name: E2E Tests
|
|
needs: ci
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
|
|
services:
|
|
postgres:
|
|
image: postgis/postgis:16-3.4
|
|
env:
|
|
POSTGRES_DB: goodgo_test
|
|
POSTGRES_USER: goodgo
|
|
POSTGRES_PASSWORD: goodgo_test_secret
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd "pg_isready -U goodgo -d goodgo_test"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
--health-start-period 30s
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
ports:
|
|
- 6379:6379
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
typesense:
|
|
image: typesense/typesense:27.1
|
|
ports:
|
|
- 8108:8108
|
|
env:
|
|
TYPESENSE_API_KEY: ts_ci_key
|
|
TYPESENSE_DATA_DIR: /data
|
|
options: >-
|
|
--health-cmd "curl -sf http://localhost:8108/health || exit 1"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
minio:
|
|
image: minio/minio:latest
|
|
ports:
|
|
- 9000:9000
|
|
env:
|
|
MINIO_ROOT_USER: ${{ vars.CI_MINIO_ACCESS_KEY || 'ci_minio_user' }}
|
|
MINIO_ROOT_PASSWORD: ${{ vars.CI_MINIO_SECRET_KEY || 'ci_minio_secret_key_32chars!!' }}
|
|
options: >-
|
|
--health-cmd "curl -sf http://localhost:9000/minio/health/live || exit 1"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
env:
|
|
DATABASE_URL: postgresql://goodgo:goodgo_test_secret@localhost:5432/goodgo_test
|
|
REDIS_URL: redis://localhost:6379
|
|
REDIS_HOST: localhost
|
|
REDIS_PORT: 6379
|
|
TYPESENSE_URL: http://localhost:8108
|
|
TYPESENSE_HOST: localhost
|
|
TYPESENSE_PORT: 8108
|
|
TYPESENSE_PROTOCOL: http
|
|
TYPESENSE_API_KEY: ts_ci_key
|
|
MINIO_ENDPOINT: localhost
|
|
MINIO_PORT: 9000
|
|
MINIO_ACCESS_KEY: ${{ vars.CI_MINIO_ACCESS_KEY || 'ci_minio_user' }}
|
|
MINIO_SECRET_KEY: ${{ vars.CI_MINIO_SECRET_KEY || 'ci_minio_secret_key_32chars!!' }}
|
|
MINIO_BUCKET: goodgo-uploads
|
|
NODE_ENV: test
|
|
CI: true
|
|
# API and Web ports for Playwright webServer
|
|
API_PORT: 3001
|
|
WEB_PORT: 3000
|
|
API_BASE_URL: http://localhost:3001/api/v1/
|
|
WEB_BASE_URL: http://localhost:3000
|
|
NEXT_PUBLIC_API_URL: http://localhost:3001/api/v1
|
|
JWT_SECRET: e2e-test-jwt-secret-key-minimum-32-chars-long-enough
|
|
JWT_REFRESH_SECRET: e2e-test-refresh-secret-key-minimum-32-chars-ok
|
|
JWT_EXPIRES_IN: 15m
|
|
JWT_REFRESH_EXPIRES_IN: 7d
|
|
BCRYPT_ROUNDS: 4
|
|
VNPAY_TMN_CODE: TESTCODE
|
|
VNPAY_HASH_SECRET: TESTHASHSECRETTESTHASHSECRETTEST
|
|
VNPAY_URL: https://sandbox.vnpayment.vn/paymentv2/vpcpay.html
|
|
VNPAY_RETURN_URL: http://localhost:3000/payment/return
|
|
GOOGLE_CLIENT_ID: test-google-client-id
|
|
GOOGLE_CLIENT_SECRET: test-google-client-secret
|
|
GOOGLE_CALLBACK_URL: http://localhost:3001/api/v1/auth/google/callback
|
|
ZALO_APP_ID: test-zalo-app-id
|
|
ZALO_APP_SECRET: test-zalo-app-secret
|
|
ZALO_CALLBACK_URL: http://localhost:3001/api/v1/auth/zalo/callback
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Cache Playwright browsers
|
|
id: playwright-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
|
|
- name: Install Playwright browsers
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
- name: Install Playwright system deps
|
|
if: steps.playwright-cache.outputs.cache-hit == 'true'
|
|
run: npx playwright install-deps chromium
|
|
|
|
- name: Generate Prisma client
|
|
run: pnpm db:generate
|
|
|
|
- name: Run database migrations
|
|
run: pnpm db:migrate:deploy
|
|
|
|
- name: Seed database
|
|
run: pnpm db:seed
|
|
|
|
- name: Run E2E tests
|
|
run: pnpm test:e2e
|
|
|
|
- name: Upload Playwright report
|
|
if: ${{ !cancelled() }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-report
|
|
path: playwright-report/
|
|
retention-days: 14
|
|
|
|
- name: Upload Playwright traces
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-traces
|
|
path: test-results/
|
|
retention-days: 7
|