[컴퓨터공학부_최재혁] - github 블로그 #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| backend: | |
| name: Backend tests and migrations | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: commit_blog | |
| POSTGRES_PASSWORD: commit_blog | |
| POSTGRES_DB: commit_blog | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U commit_blog -d commit_blog" | |
| --health-interval 5s | |
| --health-timeout 3s | |
| --health-retries 10 | |
| defaults: | |
| run: | |
| working-directory: backend | |
| env: | |
| USE_MOCKS: "true" | |
| DATABASE_URL: postgresql+psycopg://commit_blog:commit_blog@localhost:5432/commit_blog | |
| CORS_ORIGINS: http://localhost:3000 | |
| FRONTEND_BASE_URL: http://localhost:3000 | |
| SESSION_SECRET: ci_session_secret | |
| GITHUB_TOKEN: dummy_github_token_for_local_mock | |
| GITHUB_OAUTH_CLIENT_ID: dummy_github_oauth_client_id | |
| GITHUB_OAUTH_CLIENT_SECRET: dummy_github_oauth_client_secret | |
| GITHUB_OAUTH_REDIRECT_URI: http://localhost:8000/auth/github/callback | |
| ANTHROPIC_API_KEY: dummy_anthropic_key_for_local_mock | |
| ANTHROPIC_MODEL: claude-opus-4-7 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v6 | |
| - name: Install backend dependencies | |
| run: uv sync --extra test --group dev | |
| - name: Run backend lint | |
| run: uv run ruff check . | |
| - name: Check backend formatting | |
| run: uv run ruff format --check . | |
| - name: Verify staging migration | |
| run: uv run sh scripts/verify_staging_migration.sh | |
| - name: Run backend tests | |
| run: uv run pytest | |
| frontend: | |
| name: Frontend build | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: frontend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install frontend dependencies | |
| run: npm ci | |
| - name: Run frontend lint | |
| run: npm run lint | |
| - name: Check frontend formatting | |
| run: npm run format:check | |
| - name: Run frontend typecheck | |
| run: npm run typecheck | |
| - name: Run dependency audit | |
| run: npm audit --audit-level=high | |
| - name: Build frontend | |
| run: npm run build | |
| e2e: | |
| name: End-to-end Chrome flow | |
| runs-on: ubuntu-latest | |
| needs: | |
| - backend | |
| - frontend | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: commit_blog | |
| POSTGRES_PASSWORD: commit_blog | |
| POSTGRES_DB: commit_blog | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U commit_blog -d commit_blog" | |
| --health-interval 5s | |
| --health-timeout 3s | |
| --health-retries 10 | |
| env: | |
| USE_MOCKS: "true" | |
| DATABASE_URL: postgresql+psycopg://commit_blog:commit_blog@localhost:5432/commit_blog | |
| CORS_ORIGINS: http://localhost:3000 | |
| FRONTEND_BASE_URL: http://localhost:3000 | |
| SESSION_SECRET: ci_session_secret | |
| GITHUB_TOKEN: dummy_github_token_for_local_mock | |
| GITHUB_OAUTH_CLIENT_ID: dummy_github_oauth_client_id | |
| GITHUB_OAUTH_CLIENT_SECRET: dummy_github_oauth_client_secret | |
| GITHUB_OAUTH_REDIRECT_URI: http://localhost:8000/auth/github/callback | |
| ANTHROPIC_API_KEY: dummy_anthropic_key_for_local_mock | |
| ANTHROPIC_MODEL: claude-opus-4-7 | |
| NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v6 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install backend dependencies | |
| working-directory: backend | |
| run: uv sync --extra test --group dev | |
| - name: Install frontend dependencies | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Install Chrome for Playwright | |
| working-directory: frontend | |
| run: npx playwright install --with-deps chrome | |
| - name: Run migrations | |
| working-directory: backend | |
| run: uv run alembic upgrade head | |
| - name: Start backend | |
| working-directory: backend | |
| run: | | |
| uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 & | |
| - name: Start frontend | |
| working-directory: frontend | |
| run: | | |
| npm run dev -- --port 3000 & | |
| - name: Wait for services | |
| run: | | |
| for i in {1..30}; do | |
| curl -fsS http://localhost:8000/health && curl -fsS http://localhost:3000 && exit 0 | |
| sleep 2 | |
| done | |
| exit 1 | |
| - name: Run E2E | |
| working-directory: frontend | |
| run: npx playwright test --project=chrome | |
| staging-migration: | |
| name: Staging database migration | |
| runs-on: ubuntu-latest | |
| needs: | |
| - backend | |
| if: github.event_name == 'workflow_dispatch' | |
| defaults: | |
| run: | |
| working-directory: backend | |
| env: | |
| USE_MOCKS: "false" | |
| DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }} | |
| CORS_ORIGINS: ${{ vars.STAGING_CORS_ORIGINS }} | |
| FRONTEND_BASE_URL: ${{ vars.STAGING_FRONTEND_BASE_URL }} | |
| SESSION_SECRET: ${{ secrets.STAGING_SESSION_SECRET }} | |
| GITHUB_TOKEN: ${{ secrets.STAGING_GITHUB_TOKEN }} | |
| GITHUB_OAUTH_CLIENT_ID: ${{ secrets.STAGING_GITHUB_OAUTH_CLIENT_ID }} | |
| GITHUB_OAUTH_CLIENT_SECRET: ${{ secrets.STAGING_GITHUB_OAUTH_CLIENT_SECRET }} | |
| GITHUB_OAUTH_REDIRECT_URI: ${{ vars.STAGING_GITHUB_OAUTH_REDIRECT_URI }} | |
| GITHUB_ALLOWED_ORGS: ${{ vars.STAGING_GITHUB_ALLOWED_ORGS }} | |
| GITHUB_ADMIN_LOGINS: ${{ vars.STAGING_GITHUB_ADMIN_LOGINS }} | |
| ANTHROPIC_API_KEY: ${{ secrets.STAGING_ANTHROPIC_API_KEY }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v6 | |
| - name: Check required staging secrets | |
| run: | | |
| test -n "$DATABASE_URL" | |
| test -n "$SESSION_SECRET" | |
| - name: Install backend dependencies | |
| run: uv sync --frozen --no-dev | |
| - name: Verify staging migration | |
| run: uv run sh scripts/verify_staging_migration.sh |