|
| 1 | +name: Test PostgreSQL Integration |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main, develop] |
| 8 | + |
| 9 | +jobs: |
| 10 | + unit-tests: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + node-version: [18.x, 20.x, 22.x] |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Use Node.js ${{ matrix.node-version }} |
| 20 | + uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: ${{ matrix.node-version }} |
| 23 | + cache: 'npm' |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: npm ci |
| 27 | + |
| 28 | + - name: Compile TypeScript |
| 29 | + run: npm run compile |
| 30 | + |
| 31 | + - name: Run unit tests |
| 32 | + run: npm run test |
| 33 | + |
| 34 | + - name: Generate coverage report |
| 35 | + run: npm run coverage |
| 36 | + |
| 37 | + - name: Upload coverage to Codecov |
| 38 | + uses: codecov/codecov-action@v3 |
| 39 | + with: |
| 40 | + files: ./coverage/coverage-final.json |
| 41 | + flags: unittests |
| 42 | + name: codecov-umbrella |
| 43 | + fail_ci_if_error: false |
| 44 | + |
| 45 | + integration-tests: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + postgres-version: [12, 14, 15, 16, 17] |
| 50 | + |
| 51 | + services: |
| 52 | + postgres: |
| 53 | + image: postgres:${{ matrix.postgres-version }}-alpine |
| 54 | + env: |
| 55 | + POSTGRES_USER: testuser |
| 56 | + POSTGRES_PASSWORD: testpass |
| 57 | + POSTGRES_DB: testdb |
| 58 | + options: >- |
| 59 | + --health-cmd pg_isready |
| 60 | + --health-interval 10s |
| 61 | + --health-timeout 5s |
| 62 | + --health-retries 5 |
| 63 | + ports: |
| 64 | + - 5432:5432 |
| 65 | + |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v4 |
| 68 | + |
| 69 | + - name: Use Node.js 20.x |
| 70 | + uses: actions/setup-node@v4 |
| 71 | + with: |
| 72 | + node-version: 20.x |
| 73 | + cache: 'npm' |
| 74 | + |
| 75 | + - name: Install dependencies |
| 76 | + run: npm ci |
| 77 | + |
| 78 | + - name: Compile TypeScript |
| 79 | + run: npm run compile |
| 80 | + |
| 81 | + - name: Run integration tests |
| 82 | + run: npm run test:integration |
| 83 | + env: |
| 84 | + DB_HOST: localhost |
| 85 | + DB_PORT: 5432 |
| 86 | + DB_USER: testuser |
| 87 | + DB_PASSWORD: testpass |
| 88 | + DB_NAME: testdb |
| 89 | + |
| 90 | + - name: Upload integration test results |
| 91 | + if: always() |
| 92 | + uses: actions/upload-artifact@v3 |
| 93 | + with: |
| 94 | + name: integration-test-results-pg${{ matrix.postgres-version }} |
| 95 | + path: test-results/ |
| 96 | + |
| 97 | + renderer-component-tests: |
| 98 | + runs-on: ubuntu-latest |
| 99 | + |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@v4 |
| 102 | + |
| 103 | + - name: Use Node.js 20.x |
| 104 | + uses: actions/setup-node@v4 |
| 105 | + with: |
| 106 | + node-version: 20.x |
| 107 | + cache: 'npm' |
| 108 | + |
| 109 | + - name: Install dependencies |
| 110 | + run: npm ci |
| 111 | + |
| 112 | + - name: Compile TypeScript |
| 113 | + run: npm run compile |
| 114 | + |
| 115 | + - name: Run renderer component tests |
| 116 | + run: npm run test:renderer |
| 117 | + |
| 118 | + - name: Generate renderer test coverage |
| 119 | + run: npm run test:renderer:coverage |
| 120 | + |
| 121 | + docker-integration: |
| 122 | + runs-on: ubuntu-latest |
| 123 | + |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v4 |
| 126 | + |
| 127 | + - name: Set up Docker Buildx |
| 128 | + uses: docker/setup-buildx-action@v3 |
| 129 | + |
| 130 | + - name: Start PostgreSQL test containers |
| 131 | + run: docker-compose -f docker-compose.test.yml up -d |
| 132 | + |
| 133 | + - name: Wait for PostgreSQL services |
| 134 | + run: | |
| 135 | + for port in 5412 5414 5415 5416 5417; do |
| 136 | + echo "Waiting for PostgreSQL on port $port..." |
| 137 | + until pg_isready -h localhost -p $port -U testuser; do |
| 138 | + sleep 1 |
| 139 | + done |
| 140 | + done |
| 141 | + env: |
| 142 | + PGPASSWORD: testpass |
| 143 | + |
| 144 | + - name: Use Node.js 20.x |
| 145 | + uses: actions/setup-node@v4 |
| 146 | + with: |
| 147 | + node-version: 20.x |
| 148 | + cache: 'npm' |
| 149 | + |
| 150 | + - name: Install dependencies |
| 151 | + run: npm ci |
| 152 | + |
| 153 | + - name: Compile TypeScript |
| 154 | + run: npm run compile |
| 155 | + |
| 156 | + - name: Run version compatibility tests |
| 157 | + run: npm run test:versions |
| 158 | + env: |
| 159 | + DB_HOST: localhost |
| 160 | + DB_USER: testuser |
| 161 | + DB_PASSWORD: testpass |
| 162 | + DB_NAME: testdb |
| 163 | + |
| 164 | + - name: Cleanup Docker containers |
| 165 | + if: always() |
| 166 | + run: docker-compose -f docker-compose.test.yml down |
| 167 | + |
| 168 | + lint-and-format: |
| 169 | + runs-on: ubuntu-latest |
| 170 | + |
| 171 | + steps: |
| 172 | + - uses: actions/checkout@v4 |
| 173 | + |
| 174 | + - name: Use Node.js 20.x |
| 175 | + uses: actions/setup-node@v4 |
| 176 | + with: |
| 177 | + node-version: 20.x |
| 178 | + cache: 'npm' |
| 179 | + |
| 180 | + - name: Install dependencies |
| 181 | + run: npm ci |
| 182 | + |
| 183 | + - name: Check TypeScript |
| 184 | + run: npm run compile -- --noEmit |
| 185 | + |
| 186 | + coverage-report: |
| 187 | + runs-on: ubuntu-latest |
| 188 | + needs: [unit-tests, integration-tests, renderer-component-tests] |
| 189 | + if: always() |
| 190 | + |
| 191 | + steps: |
| 192 | + - uses: actions/checkout@v4 |
| 193 | + |
| 194 | + - name: Download all coverage reports |
| 195 | + uses: actions/download-artifact@v3 |
| 196 | + with: |
| 197 | + path: coverage-reports |
| 198 | + |
| 199 | + - name: Generate coverage summary |
| 200 | + run: | |
| 201 | + echo "## Test Coverage Summary" >> $GITHUB_STEP_SUMMARY |
| 202 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 203 | + echo "Unit Tests: ✓ Completed" >> $GITHUB_STEP_SUMMARY |
| 204 | + echo "Integration Tests: ✓ Completed (PostgreSQL 12-17)" >> $GITHUB_STEP_SUMMARY |
| 205 | + echo "Renderer Component Tests: ✓ Completed" >> $GITHUB_STEP_SUMMARY |
| 206 | + echo "Docker Integration: ✓ Completed" >> $GITHUB_STEP_SUMMARY |
| 207 | +
|
| 208 | + security-audit: |
| 209 | + runs-on: ubuntu-latest |
| 210 | + |
| 211 | + steps: |
| 212 | + - uses: actions/checkout@v4 |
| 213 | + |
| 214 | + - name: Run security audit |
| 215 | + run: npm audit --audit-level=moderate || true |
| 216 | + |
| 217 | + - name: Check for known vulnerabilities |
| 218 | + run: | |
| 219 | + npm list | grep vulnerable || echo "No known vulnerabilities found" |
0 commit comments