docs: add architecture diagrams, testing guide and deployment docs #6
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: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| NODE_VERSION: '20' | |
| PNPM_VERSION: '9' | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT | |
| id: pnpm-cache | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install Backend dependencies | |
| working-directory: Backend | |
| run: npm ci --legacy-peer-deps | |
| - name: Install Frontend dependencies | |
| working-directory: Frontend | |
| run: pnpm install --frozen-lockfile | |
| - name: Backend - Lint & Typecheck | |
| working-directory: Backend | |
| run: npx tsc --noEmit | |
| - name: Frontend - Typecheck | |
| working-directory: Frontend | |
| run: pnpm typecheck | |
| backend-test: | |
| name: Backend Tests | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_DB: fastr_wallet_test | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| redis: | |
| image: redis:7-alpine | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/fastr_wallet_test | |
| REDIS_URL: redis://localhost:6379 | |
| JWT_SECRET: ci-test-secret-key-at-least-32-characters-long | |
| USE_MOCK_DB: 'true' | |
| NODE_ENV: test | |
| defaults: | |
| run: | |
| working-directory: Backend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: npm | |
| cache-dependency-path: Backend/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci --legacy-peer-deps | |
| - name: Run tests with Vitest | |
| run: npx vitest run --reporter=verbose --reporter=json --outputFile=test-results.json | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: backend-test-results | |
| path: Backend/test-results.json | |
| retention-days: 7 | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: backend-coverage | |
| path: Backend/coverage/ | |
| retention-days: 7 | |
| frontend-build: | |
| name: Frontend Build | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| env: | |
| NEXT_PUBLIC_API_URL: http://localhost:4000 | |
| NEXT_PUBLIC_WS_URL: ws://localhost:4000 | |
| NEXT_PUBLIC_WEB3AUTH_CLIENT_ID: ${{ secrets.WEB3AUTH_CLIENT_ID || 'dummy-for-ci' }} | |
| NEXT_PUBLIC_APP_ENV: ci | |
| defaults: | |
| run: | |
| working-directory: Frontend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT | |
| id: pnpm-cache | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build | |
| run: pnpm build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-build | |
| path: Frontend/.next/ | |
| retention-days: 7 | |
| docker: | |
| name: Docker Build | |
| runs-on: ubuntu-latest | |
| needs: [backend-test, frontend-build] | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Backend Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./Backend | |
| push: true | |
| tags: ghcr.io/${{ github.repository }}/backend:${{ github.sha }},ghcr.io/${{ github.repository }}/backend:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build Frontend Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./Frontend | |
| push: true | |
| tags: ghcr.io/${{ github.repository }}/frontend:${{ github.sha }},ghcr.io/${{ github.repository }}/frontend:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Docker Compose build check | |
| run: docker compose build | |
| ci-status: | |
| name: CI Status Check | |
| runs-on: ubuntu-latest | |
| needs: [lint, backend-test, frontend-build] | |
| if: always() | |
| steps: | |
| - name: Check all jobs passed | |
| run: | | |
| if [[ "${{ needs.lint.result }}" != "success" || "${{ needs.backend-test.result }}" != "success" || "${{ needs.frontend-build.result }}" != "success" ]]; then | |
| echo "CI failed!" | |
| echo "Lint: ${{ needs.lint.result }}" | |
| echo "Backend Tests: ${{ needs.backend-test.result }}" | |
| echo "Frontend Build: ${{ needs.frontend-build.result }}" | |
| exit 1 | |
| fi | |
| echo "All CI checks passed!" |