| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- name: API Integration Tests
- on:
- push:
- branches: [ main, develop ]
- paths:
- - 'web/tests/integration/**'
- - '.github/workflows/integration-tests.yml'
- pull_request:
- branches: [ main ]
- paths:
- - 'web/tests/integration/**'
- - '.github/workflows/integration-tests.yml'
- workflow_dispatch:
- jobs:
- integration-tests:
- runs-on: ubuntu-latest
- timeout-minutes: 15
- services:
- postgres:
- image: postgres:15
- env:
- POSTGRES_DB: test_d8dai
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: test_password
- options: >-
- --health-cmd="pg_isready -U postgres"
- --health-interval=10s
- --health-timeout=5s
- --health-retries=3
- ports:
- - 5432:5432
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version: '20'
- cache: 'pnpm'
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- - name: Install dependencies
- run: pnpm install --frozen-lockfile
- - name: Setup test environment
- run: |
- cp .env.test.example .env.test
- echo "TEST_DATABASE_URL=postgresql://postgres:test_password@localhost:5432/test_d8dai" >> .env.test
- echo "NODE_ENV=test" >> .env.test
- echo "JWT_SECRET=test_jwt_secret_1234567890" >> .env.test
- - name: Run database migrations
- run: |
- export NODE_ENV=test
- pnpm db:migrate
- - name: Run integration tests
- run: |
- export NODE_ENV=test
- cd web
- pnpm test:integration
- - name: Upload test results
- if: always()
- uses: actions/upload-artifact@v4
- with:
- name: integration-test-results
- path: |
- coverage/
- test-results/
- retention-days: 7
- - name: Generate test coverage report
- if: success()
- run: |
- npx vitest coverage --reporter=json-summary
- - name: Upload coverage to Codecov
- if: success()
- uses: codecov/codecov-action@v3
- with:
- file: ./coverage/coverage-final.json
- flags: integration-tests
- - name: Generate test summary
- if: always()
- uses: test-summary/action@v2
- with:
- paths: test-results/junit.xml
- - name: Notify on failure
- if: failure()
- uses: 8398a7/action-slack@v3
- with:
- status: ${{ job.status }}
- channel: '#ci-notifications'
- webhook_url: ${{ secrets.SLACK_WEBHOOK }}
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- - name: Send test results to GitHub
- if: always()
- uses: dorny/test-reporter@v1
- with:
- name: Integration Tests
- path: test-results/junit.xml
- reporter: jest-junit
- fail-on-error: false
|