|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, production] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint-and-build: |
| 11 | + name: Lint, Typecheck & Build |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - uses: pnpm/action-setup@v4 |
| 18 | + |
| 19 | + - uses: actions/setup-node@v4 |
| 20 | + with: |
| 21 | + node-version: 20 |
| 22 | + cache: 'pnpm' |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: pnpm install --frozen-lockfile |
| 26 | + |
| 27 | + - name: Generate Prisma Client |
| 28 | + run: pnpm --filter database exec prisma generate |
| 29 | + |
| 30 | + - name: Build Database package |
| 31 | + run: pnpm --filter database build |
| 32 | + |
| 33 | + - name: Build Engines package |
| 34 | + run: pnpm --filter engines build |
| 35 | + |
| 36 | + - name: Build API |
| 37 | + run: pnpm --filter api build |
| 38 | + |
| 39 | + - name: Build Worker |
| 40 | + run: pnpm --filter worker build |
| 41 | + |
| 42 | + - name: Build Admin |
| 43 | + run: pnpm --filter admin build |
| 44 | + env: |
| 45 | + NEXT_PUBLIC_API_URL: http://localhost:3000 |
| 46 | + |
| 47 | + docker-build: |
| 48 | + name: Docker Build Test |
| 49 | + runs-on: ubuntu-latest |
| 50 | + needs: lint-and-build |
| 51 | + |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Build API Image |
| 56 | + run: docker build -f docker/Dockerfile.api -t multiwa-api:test . |
| 57 | + |
| 58 | + - name: Build Worker Image |
| 59 | + run: docker build -f docker/Dockerfile.worker -t multiwa-worker:test . |
| 60 | + |
| 61 | + - name: Build Admin Image |
| 62 | + run: | |
| 63 | + docker build -f docker/Dockerfile.admin \ |
| 64 | + --build-arg NEXT_PUBLIC_API_URL=http://localhost:3000 \ |
| 65 | + -t multiwa-admin:test . |
| 66 | +
|
| 67 | + test: |
| 68 | + name: Tests |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: lint-and-build |
| 71 | + |
| 72 | + services: |
| 73 | + postgres: |
| 74 | + image: postgres:16-alpine |
| 75 | + env: |
| 76 | + POSTGRES_USER: test |
| 77 | + POSTGRES_PASSWORD: test |
| 78 | + POSTGRES_DB: multiwa_test |
| 79 | + options: >- |
| 80 | + --health-cmd pg_isready |
| 81 | + --health-interval 10s |
| 82 | + --health-timeout 5s |
| 83 | + --health-retries 5 |
| 84 | + ports: |
| 85 | + - 5432:5432 |
| 86 | + |
| 87 | + redis: |
| 88 | + image: redis:7-alpine |
| 89 | + options: >- |
| 90 | + --health-cmd "redis-cli ping" |
| 91 | + --health-interval 10s |
| 92 | + --health-timeout 5s |
| 93 | + --health-retries 5 |
| 94 | + ports: |
| 95 | + - 6379:6379 |
| 96 | + |
| 97 | + steps: |
| 98 | + - uses: actions/checkout@v4 |
| 99 | + |
| 100 | + - uses: pnpm/action-setup@v4 |
| 101 | + |
| 102 | + - uses: actions/setup-node@v4 |
| 103 | + with: |
| 104 | + node-version: 20 |
| 105 | + cache: 'pnpm' |
| 106 | + |
| 107 | + - name: Install dependencies |
| 108 | + run: pnpm install --frozen-lockfile |
| 109 | + |
| 110 | + - name: Generate Prisma Client |
| 111 | + run: pnpm --filter database exec prisma generate |
| 112 | + |
| 113 | + - name: Build Database package |
| 114 | + run: pnpm --filter database build |
| 115 | + |
| 116 | + - name: Build Engines package |
| 117 | + run: pnpm --filter engines build |
| 118 | + |
| 119 | + - name: Run API tests |
| 120 | + run: pnpm --filter api test -- --run |
| 121 | + env: |
| 122 | + DATABASE_URL: postgresql://test:test@localhost:5432/multiwa_test |
| 123 | + REDIS_URL: redis://localhost:6379 |
| 124 | + JWT_SECRET: test-jwt-secret |
| 125 | + JWT_REFRESH_SECRET: test-jwt-refresh-secret |
| 126 | + ENCRYPTION_KEY: 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef |
0 commit comments