fix(community): sync webEnvTemplate fix to community subtree #104
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
| # ============================================================================= | |
| # SynthStack Community Edition - CI Workflow | |
| # ============================================================================= | |
| # This workflow runs tests and linting for the community edition. | |
| # | |
| # For deployment workflows, see docs/DEPLOYMENT_GUIDE.md | |
| # The deployment jobs are commented out below and can be enabled when you have: | |
| # - Your own server infrastructure | |
| # - GitHub secrets configured (REMOTE_HOST, SSH keys, etc.) | |
| # ============================================================================= | |
| name: CI | |
| on: | |
| push: | |
| branches: ["main", "master", "develop"] | |
| pull_request: | |
| branches: ["main", "master", "develop"] | |
| env: | |
| NODE_VERSION: "20" | |
| PNPM_VERSION: "9" | |
| jobs: | |
| # ========================================= | |
| # Code Quality & Testing | |
| # ========================================= | |
| test: | |
| name: Test & Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run Linting | |
| id: lint | |
| run: | | |
| pnpm lint && echo "lint_status=✅ Passed" >> $GITHUB_OUTPUT || echo "lint_status=⚠️ Issues found" >> $GITHUB_OUTPUT | |
| continue-on-error: true | |
| - name: Run Type Checking | |
| id: typecheck | |
| run: | | |
| pnpm typecheck && echo "typecheck_status=✅ Passed" >> $GITHUB_OUTPUT || echo "typecheck_status=⚠️ Issues found" >> $GITHUB_OUTPUT | |
| continue-on-error: true | |
| - name: Run Unit Tests | |
| id: tests | |
| run: | | |
| # Run tests and capture output | |
| pnpm test --reporter=json --outputFile=test-results.json 2>&1 | tee test-output.txt | |
| # Extract test counts from Vitest output | |
| TESTS_PASSED=$(grep -oP '\d+(?= passed)' test-output.txt | head -1 || echo "0") | |
| TESTS_FAILED=$(grep -oP '\d+(?= failed)' test-output.txt | head -1 || echo "0") | |
| TEST_FILES=$(grep -oP '\d+(?= test files)' test-output.txt | head -1 || echo "0") | |
| # Calculate totals | |
| TOTAL_TESTS=$((TESTS_PASSED + TESTS_FAILED)) | |
| if [ "$TOTAL_TESTS" -gt 0 ]; then | |
| PASS_RATE=$((TESTS_PASSED * 100 / TOTAL_TESTS)) | |
| else | |
| PASS_RATE=0 | |
| fi | |
| echo "tests_passed=$TESTS_PASSED" >> $GITHUB_OUTPUT | |
| echo "tests_failed=$TESTS_FAILED" >> $GITHUB_OUTPUT | |
| echo "tests_total=$TOTAL_TESTS" >> $GITHUB_OUTPUT | |
| echo "test_files=$TEST_FILES" >> $GITHUB_OUTPUT | |
| echo "pass_rate=$PASS_RATE" >> $GITHUB_OUTPUT | |
| # Fail if tests failed | |
| if [ "$TESTS_FAILED" -gt 0 ]; then | |
| exit 1 | |
| fi | |
| continue-on-error: true | |
| - name: Generate Test Summary | |
| if: always() | |
| run: | | |
| echo "## 🧪 Test Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Metric | Result |" >> $GITHUB_STEP_SUMMARY | |
| echo "|--------|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Tests Passed** | ${{ steps.tests.outputs.tests_passed || '0' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Tests Failed** | ${{ steps.tests.outputs.tests_failed || '0' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Total Tests** | ${{ steps.tests.outputs.tests_total || '0' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Pass Rate** | ${{ steps.tests.outputs.pass_rate || '0' }}% |" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Test Files** | ${{ steps.tests.outputs.test_files || '0' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Code Quality" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Check | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Linting | ${{ steps.lint.outputs.lint_status || '⚠️ Skipped' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Type Checking | ${{ steps.typecheck.outputs.typecheck_status || '⚠️ Skipped' }} |" >> $GITHUB_STEP_SUMMARY | |
| # ========================================= | |
| # Build Frontend | |
| # ========================================= | |
| build-web: | |
| name: Build Web App | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build Web Application | |
| run: pnpm --filter @synthstack/web build | |
| env: | |
| # These can be overridden via GitHub repository variables | |
| VITE_API_URL: ${{ vars.VITE_API_URL || 'http://localhost:3003' }} | |
| VITE_SUPABASE_URL: ${{ vars.VITE_SUPABASE_URL || '' }} | |
| VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY || '' }} | |
| - name: Upload Web Build Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: web-dist | |
| path: apps/web/dist/spa | |
| retention-days: 7 | |
| # ============================================================================= | |
| # DEPLOYMENT JOBS (DISABLED) | |
| # ============================================================================= | |
| # Uncomment and configure these jobs for production deployment. | |
| # Required secrets: | |
| # - REMOTE_HOST_PRODUCTION: Your server IP | |
| # - REMOTE_USER: SSH username (usually 'root') | |
| # - REMOTE_SSH_KEY: Your SSH private key | |
| # - GH_PAT: GitHub Personal Access Token for pulling images | |
| # | |
| # See docs/DEPLOYMENT_GUIDE.md for full setup instructions. | |
| # ============================================================================= | |
| # build-api: | |
| # name: Build API Docker Image | |
| # runs-on: ubuntu-latest | |
| # needs: test | |
| # if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| # | |
| # permissions: | |
| # contents: read | |
| # packages: write | |
| # | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # | |
| # - name: Set up Docker Buildx | |
| # uses: docker/setup-buildx-action@v3 | |
| # | |
| # - name: Login to GitHub Container Registry | |
| # uses: docker/login-action@v3 | |
| # with: | |
| # registry: ghcr.io | |
| # username: ${{ github.actor }} | |
| # password: ${{ secrets.GITHUB_TOKEN }} | |
| # | |
| # - name: Build and push API image | |
| # uses: docker/build-push-action@v5 | |
| # with: | |
| # context: . | |
| # file: ./packages/api-gateway/Dockerfile | |
| # push: true | |
| # tags: ghcr.io/${{ github.repository }}/api:latest | |
| # deploy-production: | |
| # name: Deploy to Production | |
| # runs-on: ubuntu-latest | |
| # needs: [build-web, build-api] | |
| # if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| # environment: production | |
| # | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # | |
| # - name: Download Web Build | |
| # uses: actions/download-artifact@v4 | |
| # with: | |
| # name: web-dist | |
| # path: ./dist | |
| # | |
| # - name: Setup SSH Key | |
| # run: | | |
| # mkdir -p ~/.ssh | |
| # echo "${{ secrets.REMOTE_SSH_KEY }}" > ~/.ssh/deploy_key | |
| # chmod 600 ~/.ssh/deploy_key | |
| # ssh-keyscan -H ${{ secrets.REMOTE_HOST_PRODUCTION }} >> ~/.ssh/known_hosts | |
| # | |
| # - name: Deploy Web to Production | |
| # run: | | |
| # rsync -avz --delete -e "ssh -i ~/.ssh/deploy_key" \ | |
| # ./dist/ ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST_PRODUCTION }}:/var/www/synthstack/ | |
| # | |
| # - name: Deploy Services | |
| # run: | | |
| # ssh -i ~/.ssh/deploy_key ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST_PRODUCTION }} \ | |
| # 'cd /opt/synthstack && docker compose pull && docker compose up -d' |