|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, staging] |
| 6 | + pull_request: |
| 7 | + branches: [main, staging] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Run Tests |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + services: |
| 15 | + postgres: |
| 16 | + image: postgres:16 |
| 17 | + env: |
| 18 | + POSTGRES_USER: postgres |
| 19 | + POSTGRES_PASSWORD: postgres |
| 20 | + POSTGRES_DB: databuddy_test |
| 21 | + ports: |
| 22 | + - 5432:5432 |
| 23 | + options: >- |
| 24 | + --health-cmd pg_isready |
| 25 | + --health-interval 10s |
| 26 | + --health-timeout 5s |
| 27 | + --health-retries 5 |
| 28 | + |
| 29 | + redis: |
| 30 | + image: redis:7-alpine |
| 31 | + ports: |
| 32 | + - 6379:6379 |
| 33 | + options: >- |
| 34 | + --health-cmd "redis-cli ping" |
| 35 | + --health-interval 10s |
| 36 | + --health-timeout 5s |
| 37 | + --health-retries 5 |
| 38 | + |
| 39 | + clickhouse: |
| 40 | + image: clickhouse/clickhouse-server:latest |
| 41 | + ports: |
| 42 | + - 8123:8123 |
| 43 | + - 9000:9000 |
| 44 | + env: |
| 45 | + CLICKHOUSE_DB: databuddy_test |
| 46 | + options: >- |
| 47 | + --health-cmd "clickhouse-client --query 'SELECT 1'" |
| 48 | + --health-interval 10s |
| 49 | + --health-timeout 5s |
| 50 | + --health-retries 5 |
| 51 | +
|
| 52 | + steps: |
| 53 | + - name: Checkout repository |
| 54 | + uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Setup Bun |
| 57 | + uses: oven-sh/setup-bun@v2 |
| 58 | + with: |
| 59 | + bun-version: latest |
| 60 | + |
| 61 | + - name: Install dependencies |
| 62 | + run: bun install --frozen-lockfile |
| 63 | + |
| 64 | + - name: Run tests |
| 65 | + env: |
| 66 | + # Database URLs |
| 67 | + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/databuddy_test |
| 68 | + POSTGRES_URL: postgresql://postgres:postgres@localhost:5432/databuddy_test |
| 69 | + |
| 70 | + # Redis URL |
| 71 | + REDIS_URL: redis://localhost:6379 |
| 72 | + REDIS_HOST: localhost |
| 73 | + REDIS_PORT: 6379 |
| 74 | + |
| 75 | + # ClickHouse URLs |
| 76 | + CLICKHOUSE_URL: http://localhost:8123 |
| 77 | + CLICKHOUSE_HOST: localhost |
| 78 | + CLICKHOUSE_PORT: 8123 |
| 79 | + CLICKHOUSE_DATABASE: databuddy_test |
| 80 | + |
| 81 | + # Test environment |
| 82 | + NODE_ENV: test |
| 83 | + |
| 84 | + # Auth secrets (use dummy values for tests) |
| 85 | + AUTH_SECRET: test-auth-secret-for-ci-testing-only |
| 86 | + NEXTAUTH_SECRET: test-auth-secret-for-ci-testing-only |
| 87 | + |
| 88 | + # API keys (use dummy values for tests) |
| 89 | + EMAIL_API_KEY: test-email-api-key |
| 90 | + IP_HASH_SALT: test-ip-hash-salt |
| 91 | + |
| 92 | + run: bun test |
| 93 | + |
| 94 | + - name: Upload coverage reports |
| 95 | + if: always() |
| 96 | + uses: codecov/codecov-action@v4 |
| 97 | + with: |
| 98 | + files: ./coverage/coverage-final.json |
| 99 | + fail_ci_if_error: false |
| 100 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 101 | + |
0 commit comments