name: Test on: push: branches: [ main, develop ] pull_request: branches: [ main, develop ] jobs: test: runs-on: ubuntu-latest strategy: matrix: node-version: [18.x, 20.x] mongodb-version: ['6.0', '7.0'] redis-version: ['7'] services: mongodb: image: mongo:${{ matrix.mongodb-version }} ports: - 27017:27017 options: >- --health-cmd mongosh --health-interval 10s --health-timeout 5s --health-retries 5 redis: image: redis:${{ matrix.redis-version }} ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install dependencies run: | npm ci cd services/api-gateway && npm ci cd ../orchestrator && npm ci cd ../analytics && npm ci cd ../scheduler && npm ci cd ../user-management && npm ci cd ../.. - name: Run linter run: npm run lint - name: Run unit tests env: NODE_ENV: test JWT_SECRET: test-jwt-secret MONGODB_URI: mongodb://localhost:27017/test REDIS_URL: redis://localhost:6379 run: npm run test:unit - name: Run integration tests env: NODE_ENV: test JWT_SECRET: test-jwt-secret MONGODB_URI: mongodb://localhost:27017/test REDIS_URL: redis://localhost:6379 run: npm run test:integration - name: Run E2E tests env: NODE_ENV: test JWT_SECRET: test-jwt-secret MONGODB_URI: mongodb://localhost:27017/test REDIS_URL: redis://localhost:6379 run: npm run test:e2e - name: Generate coverage report run: npm run test:coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage/lcov.info flags: unittests name: codecov-umbrella fail_ci_if_error: true - name: Upload test results uses: actions/upload-artifact@v3 if: always() with: name: test-results-${{ matrix.node-version }}-${{ matrix.mongodb-version }} path: test-results/junit.xml - name: Upload coverage artifacts uses: actions/upload-artifact@v3 with: name: coverage-${{ matrix.node-version }}-${{ matrix.mongodb-version }} path: coverage/ test-summary: needs: test runs-on: ubuntu-latest if: always() steps: - name: Download artifacts uses: actions/download-artifact@v3 - name: Publish test results uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: files: '**/junit.xml' check_name: Test Results comment_title: Test Results Summary