Improve integration test job handling when secrets are missing #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: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| name: Lint & Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Biome lint & format check | |
| run: pnpm lint | |
| type-check: | |
| name: Type Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: TypeScript type check | |
| run: npx tsc --noEmit | |
| test-unit: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run unit tests | |
| run: pnpm test:unit | |
| test-integration: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| # Requires a Neon-compatible DATABASE_URL secret. | |
| # Add it under GitHub → Settings → Secrets and variables → Actions. | |
| # The app uses @neondatabase/serverless (HTTP-based), so a standard local | |
| # Postgres container is not sufficient — use a real Neon test database. | |
| env: | |
| DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
| # SESSION_SECRET can be any string for test purposes | |
| SESSION_SECRET: ${{ secrets.SESSION_SECRET || 'ci-integration-test-secret' }} | |
| steps: | |
| - name: Check for required secrets | |
| id: check-secrets | |
| run: | | |
| if [ -z "$DATABASE_URL" ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "::notice::Skipping integration tests — DATABASE_URL secret is not configured" | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - uses: actions/checkout@v6 | |
| if: steps.check-secrets.outputs.skip != 'true' | |
| - uses: pnpm/action-setup@v4 | |
| if: steps.check-secrets.outputs.skip != 'true' | |
| with: | |
| version: latest | |
| - uses: actions/setup-node@v6 | |
| if: steps.check-secrets.outputs.skip != 'true' | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| if: steps.check-secrets.outputs.skip != 'true' | |
| run: pnpm install --frozen-lockfile | |
| - name: Apply database migrations | |
| if: steps.check-secrets.outputs.skip != 'true' | |
| run: pnpm db:migrate | |
| - name: Run integration tests | |
| if: steps.check-secrets.outputs.skip != 'true' | |
| run: pnpm test:integration |