Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
597 lines
18 KiB
YAML
597 lines
18 KiB
YAML
# =============================================================================
|
|
# Gitgram CI - Comprehensive Production Gates
|
|
# =============================================================================
|
|
# Runs on push to main/develop and on all PRs targeting those branches.
|
|
#
|
|
# Gates:
|
|
# 1. Build gates - TypeScript compilation, ESLint, build artifacts
|
|
# 2. Migration gates - Prisma migrate status validation
|
|
# 3. Test gates - Unit tests, integration-safe tests, DB-backed tests
|
|
# 4. Quality gates - OpenAPI route validation
|
|
# 5. Smoke tests - Build-and-start verification, health endpoint check
|
|
# =============================================================================
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
|
|
concurrency:
|
|
group: gitgram-ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# ---------------------------------------------------------------------------
|
|
# Job 1: Backend - Lint & TypeScript type-check
|
|
# ---------------------------------------------------------------------------
|
|
backend-lint:
|
|
name: "Backend: Lint & Type Check"
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
node-version: [18, 20]
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: npm
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate Prisma Client
|
|
run: npx prisma generate
|
|
|
|
- name: ESLint
|
|
run: npm run lint
|
|
|
|
- name: TypeScript type-check
|
|
run: npx tsc --noEmit
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 2: Backend - Build artifacts
|
|
# ---------------------------------------------------------------------------
|
|
backend-build:
|
|
name: "Backend: Build"
|
|
runs-on: ubuntu-latest
|
|
needs: [backend-lint]
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate Prisma Client
|
|
run: npx prisma generate
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: backend-dist
|
|
path: backend/dist
|
|
retention-days: 7
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 3: Backend - Prisma migration validation
|
|
# ---------------------------------------------------------------------------
|
|
backend-migration-check:
|
|
name: "Backend: Migration Validation"
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:15
|
|
env:
|
|
POSTGRES_USER: gitgram
|
|
POSTGRES_PASSWORD: gitgram_password
|
|
POSTGRES_DB: gitgram_test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
env:
|
|
DATABASE_URL: postgresql://gitgram:gitgram_password@localhost:5432/gitgram_test?schema=public
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate Prisma Client
|
|
run: npx prisma generate
|
|
|
|
- name: Apply migrations
|
|
run: npx prisma migrate deploy
|
|
|
|
- name: Validate migration status
|
|
run: |
|
|
STATUS=$(npx prisma migrate status 2>&1)
|
|
echo "$STATUS"
|
|
if echo "$STATUS" | grep -q "have not yet been applied"; then
|
|
echo "FAIL: Pending migrations detected."
|
|
exit 1
|
|
fi
|
|
echo "All migrations are applied."
|
|
|
|
- name: Validate Prisma schema drift
|
|
run: |
|
|
npx prisma db pull --force
|
|
DIFF=$(npx prisma migrate diff \
|
|
--from-schema-datamodel prisma/schema.prisma \
|
|
--to-schema-datasource prisma/schema.prisma \
|
|
--exit-code 2>&1) || true
|
|
echo "$DIFF"
|
|
echo "Migration drift check complete."
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 4: Backend - Unit tests (no DB required)
|
|
# ---------------------------------------------------------------------------
|
|
backend-unit-tests:
|
|
name: "Backend: Unit Tests"
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
node-version: [18, 20]
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: npm
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate Prisma Client
|
|
run: npx prisma generate
|
|
|
|
- name: Run unit tests
|
|
run: npx jest --testPathIgnorePatterns='integration' --passWithNoTests
|
|
env:
|
|
JWT_SECRET: test-secret-key
|
|
NODE_ENV: test
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 5: Backend - Integration tests (DB-backed)
|
|
# ---------------------------------------------------------------------------
|
|
backend-integration-tests:
|
|
name: "Backend: Integration Tests (DB)"
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:15
|
|
env:
|
|
POSTGRES_USER: gitgram
|
|
POSTGRES_PASSWORD: gitgram_password
|
|
POSTGRES_DB: gitgram_test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis:alpine
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 6379:6379
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
env:
|
|
DATABASE_URL: postgresql://gitgram:gitgram_password@localhost:5432/gitgram_test?schema=public
|
|
REDIS_URL: redis://localhost:6379
|
|
JWT_SECRET: test-secret-key
|
|
JWT_REFRESH_SECRET: test-refresh-secret
|
|
NODE_ENV: test
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate Prisma Client
|
|
run: npx prisma generate
|
|
|
|
- name: Apply migrations
|
|
run: npx prisma migrate deploy
|
|
|
|
- name: Run all tests (including integration)
|
|
run: npm test
|
|
|
|
- name: Upload coverage
|
|
if: always()
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
directory: ./backend/coverage
|
|
flags: backend
|
|
fail_ci_if_error: false
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 6: Web - Lint & Build
|
|
# ---------------------------------------------------------------------------
|
|
web-lint-build:
|
|
name: "Web: Lint & Build"
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
node-version: [18, 20]
|
|
defaults:
|
|
run:
|
|
working-directory: web
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: npm
|
|
cache-dependency-path: web/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: ESLint
|
|
run: npm run lint
|
|
|
|
- name: Build (Next.js)
|
|
run: npm run build
|
|
env:
|
|
NEXT_PUBLIC_API_URL: https://api.gitgram.app/api
|
|
NEXT_PUBLIC_SOCKET_URL: https://api.gitgram.app
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 7: OpenAPI spec validation
|
|
# ---------------------------------------------------------------------------
|
|
openapi-validation:
|
|
name: "Quality: OpenAPI Route Coverage"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install backend dependencies
|
|
working-directory: backend
|
|
run: npm ci
|
|
|
|
- name: Install root dependencies (for script)
|
|
run: |
|
|
if [ -f package.json ]; then
|
|
npm ci --ignore-scripts 2>/dev/null || true
|
|
fi
|
|
|
|
- name: Validate OpenAPI route coverage
|
|
run: npx tsx scripts/validate-openapi-routes.ts
|
|
working-directory: .
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 8: Web Playwright repo routing smoke
|
|
# ---------------------------------------------------------------------------
|
|
web-playwright-repo-routing:
|
|
name: "Web: Playwright Repo Routing"
|
|
runs-on: ubuntu-latest
|
|
needs: [web-lint-build]
|
|
defaults:
|
|
run:
|
|
working-directory: web
|
|
env:
|
|
CI: true
|
|
NEXT_PUBLIC_API_URL: http://127.0.0.1:4000/api
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: web/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Install Playwright Chromium
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
- name: Run focused Playwright coverage
|
|
run: npm run test:e2e:repo-text
|
|
|
|
- name: Upload Playwright report
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: web-playwright-repo-routing-report
|
|
path: |
|
|
web/playwright-report
|
|
web/test-results
|
|
retention-days: 7
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 9: Web Playwright live auth/comment/notification smoke
|
|
# ---------------------------------------------------------------------------
|
|
web-playwright-live-engagement:
|
|
name: "Web: Playwright Live Engagement"
|
|
runs-on: ubuntu-latest
|
|
needs: [web-lint-build]
|
|
defaults:
|
|
run:
|
|
working-directory: web
|
|
env:
|
|
CI: true
|
|
NEXT_PUBLIC_API_URL: http://127.0.0.1:4000/api
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: web/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Install Playwright Chromium
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
- name: Run focused live engagement coverage
|
|
run: npm run test:e2e:live-engagement
|
|
|
|
- name: Upload Playwright report
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: web-playwright-live-engagement-report
|
|
path: |
|
|
web/playwright-report
|
|
web/test-results
|
|
retention-days: 7
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 10: Backend smoke test (build, start, health check)
|
|
# ---------------------------------------------------------------------------
|
|
backend-smoke-test:
|
|
name: "Smoke: Backend Starts & Responds"
|
|
runs-on: ubuntu-latest
|
|
needs: [backend-build]
|
|
services:
|
|
postgres:
|
|
image: postgres:15
|
|
env:
|
|
POSTGRES_USER: gitgram
|
|
POSTGRES_PASSWORD: gitgram_password
|
|
POSTGRES_DB: gitgram_test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis:alpine
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 6379:6379
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
env:
|
|
DATABASE_URL: postgresql://gitgram:gitgram_password@localhost:5432/gitgram_test?schema=public
|
|
REDIS_URL: redis://localhost:6379
|
|
JWT_SECRET: test-secret-key
|
|
JWT_REFRESH_SECRET: test-refresh-secret
|
|
NODE_ENV: test
|
|
PORT: 3000
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate Prisma Client
|
|
run: npx prisma generate
|
|
|
|
- name: Apply migrations
|
|
run: npx prisma migrate deploy
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Start server and verify health
|
|
run: |
|
|
# Start the backend in the background
|
|
node dist/index.js &
|
|
SERVER_PID=$!
|
|
|
|
echo "Waiting for server to start (PID $SERVER_PID)..."
|
|
|
|
RETRIES=20
|
|
INTERVAL=3
|
|
SUCCESS=false
|
|
|
|
for i in $(seq 1 $RETRIES); do
|
|
HTTP_CODE=$(curl -sf -o /dev/null -w "%{http_code}" http://localhost:${PORT}/health 2>/dev/null || echo "000")
|
|
if [ "$HTTP_CODE" = "200" ]; then
|
|
echo "Health check PASSED (HTTP $HTTP_CODE) on attempt $i"
|
|
SUCCESS=true
|
|
break
|
|
fi
|
|
echo "Attempt $i/$RETRIES: HTTP $HTTP_CODE - waiting ${INTERVAL}s..."
|
|
sleep $INTERVAL
|
|
done
|
|
|
|
# Clean up
|
|
kill $SERVER_PID 2>/dev/null || true
|
|
|
|
if [ "$SUCCESS" = "false" ]; then
|
|
echo "FAIL: Backend did not respond to /health within timeout."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Backend smoke test PASSED."
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Job 10: Mobile tests (soft gate)
|
|
# ---------------------------------------------------------------------------
|
|
mobile-test:
|
|
name: "Mobile: Lint & Test"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: mobile/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
working-directory: mobile
|
|
run: npm ci
|
|
|
|
- name: Run linter
|
|
working-directory: mobile
|
|
run: npm run lint || true
|
|
|
|
- name: Run tests
|
|
working-directory: mobile
|
|
run: npm test || true
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Gate summary (require all critical jobs to pass)
|
|
# ---------------------------------------------------------------------------
|
|
ci-gate:
|
|
name: "CI Gate (all checks)"
|
|
runs-on: ubuntu-latest
|
|
if: always()
|
|
needs:
|
|
- backend-lint
|
|
- backend-build
|
|
- backend-migration-check
|
|
- backend-unit-tests
|
|
- backend-integration-tests
|
|
- web-lint-build
|
|
- web-playwright-repo-routing
|
|
- web-playwright-live-engagement
|
|
- backend-smoke-test
|
|
steps:
|
|
- name: Check all gates
|
|
run: |
|
|
echo "Checking all CI gate results..."
|
|
echo "backend-lint: ${{ needs.backend-lint.result }}"
|
|
echo "backend-build: ${{ needs.backend-build.result }}"
|
|
echo "backend-migration-check: ${{ needs.backend-migration-check.result }}"
|
|
echo "backend-unit-tests: ${{ needs.backend-unit-tests.result }}"
|
|
echo "backend-integration-tests: ${{ needs.backend-integration-tests.result }}"
|
|
echo "web-lint-build: ${{ needs.web-lint-build.result }}"
|
|
echo "web-playwright-repo-routing: ${{ needs.web-playwright-repo-routing.result }}"
|
|
echo "web-playwright-live-engagement: ${{ needs.web-playwright-live-engagement.result }}"
|
|
echo "backend-smoke-test: ${{ needs.backend-smoke-test.result }}"
|
|
|
|
FAILED=false
|
|
for result in \
|
|
"${{ needs.backend-lint.result }}" \
|
|
"${{ needs.backend-build.result }}" \
|
|
"${{ needs.backend-migration-check.result }}" \
|
|
"${{ needs.backend-unit-tests.result }}" \
|
|
"${{ needs.backend-integration-tests.result }}" \
|
|
"${{ needs.web-lint-build.result }}" \
|
|
"${{ needs.web-playwright-repo-routing.result }}" \
|
|
"${{ needs.web-playwright-live-engagement.result }}" \
|
|
"${{ needs.backend-smoke-test.result }}"; do
|
|
if [ "$result" != "success" ]; then
|
|
FAILED=true
|
|
fi
|
|
done
|
|
|
|
if [ "$FAILED" = "true" ]; then
|
|
echo "FAIL: One or more CI gates did not pass."
|
|
exit 1
|
|
fi
|
|
|
|
echo "All CI gates passed."
|