integration-tests.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. name: API Integration Tests
  2. on:
  3. push:
  4. branches: [ main, develop ]
  5. paths:
  6. - 'web/tests/integration/**'
  7. - '.github/workflows/integration-tests.yml'
  8. pull_request:
  9. branches: [ main ]
  10. paths:
  11. - 'web/tests/integration/**'
  12. - '.github/workflows/integration-tests.yml'
  13. workflow_dispatch:
  14. jobs:
  15. integration-tests:
  16. runs-on: ubuntu-latest
  17. timeout-minutes: 15
  18. services:
  19. postgres:
  20. image: postgres:15
  21. env:
  22. POSTGRES_DB: test_d8dai
  23. POSTGRES_USER: postgres
  24. POSTGRES_PASSWORD: test_password
  25. options: >-
  26. --health-cmd="pg_isready -U postgres"
  27. --health-interval=10s
  28. --health-timeout=5s
  29. --health-retries=3
  30. ports:
  31. - 5432:5432
  32. steps:
  33. - name: Checkout code
  34. uses: actions/checkout@v4
  35. - name: Setup Node.js
  36. uses: actions/setup-node@v4
  37. with:
  38. node-version: '20'
  39. cache: 'pnpm'
  40. - name: Install pnpm
  41. uses: pnpm/action-setup@v2
  42. with:
  43. version: 8
  44. - name: Install dependencies
  45. run: pnpm install --frozen-lockfile
  46. - name: Setup test environment
  47. run: |
  48. cp .env.test.example .env.test
  49. echo "TEST_DATABASE_URL=postgresql://postgres:test_password@localhost:5432/test_d8dai" >> .env.test
  50. echo "NODE_ENV=test" >> .env.test
  51. echo "JWT_SECRET=test_jwt_secret_1234567890" >> .env.test
  52. - name: Run database migrations
  53. run: |
  54. export NODE_ENV=test
  55. pnpm db:migrate
  56. - name: Run integration tests
  57. run: |
  58. export NODE_ENV=test
  59. cd web
  60. pnpm test:integration
  61. - name: Upload test results
  62. if: always()
  63. uses: actions/upload-artifact@v4
  64. with:
  65. name: integration-test-results
  66. path: |
  67. coverage/
  68. test-results/
  69. retention-days: 7
  70. - name: Generate test coverage report
  71. if: success()
  72. run: |
  73. npx vitest coverage --reporter=json-summary
  74. - name: Upload coverage to Codecov
  75. if: success()
  76. uses: codecov/codecov-action@v3
  77. with:
  78. file: ./coverage/coverage-final.json
  79. flags: integration-tests
  80. - name: Generate test summary
  81. if: always()
  82. uses: test-summary/action@v2
  83. with:
  84. paths: test-results/junit.xml
  85. - name: Notify on failure
  86. if: failure()
  87. uses: 8398a7/action-slack@v3
  88. with:
  89. status: ${{ job.status }}
  90. channel: '#ci-notifications'
  91. webhook_url: ${{ secrets.SLACK_WEBHOOK }}
  92. env:
  93. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
  94. - name: Send test results to GitHub
  95. if: always()
  96. uses: dorny/test-reporter@v1
  97. with:
  98. name: Integration Tests
  99. path: test-results/junit.xml
  100. reporter: jest-junit
  101. fail-on-error: false