Testing my theory: Fix API Errors and Add Comprehensive Testing Infrastructure #9
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: API Integration Tests | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| jobs: | |
| integration-tests: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [22.x] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run prebuild (content processing) | |
| run: npm run prebuild | |
| - name: Start development server | |
| run: | | |
| npm run dev & | |
| echo $! > dev-server.pid | |
| sleep 30 # Wait for server to start | |
| - name: Wait for server to be ready | |
| run: | | |
| # Try both port 3000 and 3001, and use a simple endpoint that should work | |
| timeout 120s bash -c 'until curl -f http://localhost:3000/api/content/terraform-enterprise/doc/latest/enterprise/index || curl -f http://localhost:3001/api/content/terraform-enterprise/doc/latest/enterprise/index; do echo "Waiting for server..."; sleep 5; done' | |
| - name: Run all integration tests | |
| run: npm run test:all | |
| - name: Stop development server | |
| run: | | |
| if [ -f dev-server.pid ]; then | |
| kill $(cat dev-server.pid) | |
| fi | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: integration-test-results-${{ github.run_number }} | |
| path: | | |
| test-results.json | |
| __tests__/ | |
| retention-days: 30 | |
| - name: Comment on PR with test results | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| echo "## 🧪 Integration Test Results" >> $GITHUB_STEP_SUMMARY | |
| echo "All integration tests completed successfully! ✅" >> $GITHUB_STEP_SUMMARY | |
| echo "- API endpoints tested and working" >> $GITHUB_STEP_SUMMARY | |
| echo "- Content routing validated" >> $GITHUB_STEP_SUMMARY | |
| echo "- Production regression tests passed" >> $GITHUB_STEP_SUMMARY |