name: CI on: push: branches: [main, 'release/**'] pull_request: branches: [main, 'release/**'] # Cancel previous runs on the same branch/PR concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: backend: name: Backend tests runs-on: ubuntu-latest defaults: run: working-directory: document-parser steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" cache: pip cache-dependency-path: document-parser/requirements.txt - name: Install system dependencies run: sudo apt-get update && sudo apt-get install -y --no-install-recommends poppler-utils - name: Install Python dependencies run: | pip install --upgrade pip pip install -r requirements.txt pip install pytest pytest-asyncio httpx ruff - name: Lint run: ruff check . - name: Run tests run: pytest tests/ -v frontend: name: Frontend tests & build runs-on: ubuntu-latest defaults: run: working-directory: frontend steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 cache: npm cache-dependency-path: frontend/package-lock.json - name: Install dependencies run: npm ci - name: Lint run: npx eslint src/ - name: Type check run: npm run type-check - name: Run tests run: npm run test:run - name: Build run: npm run build e2e: name: E2E API tests (Karate) needs: [backend, frontend] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" - uses: actions/setup-java@v4 with: java-version: "17" distribution: temurin cache: maven - name: Generate test PDFs run: | pip install pypdfium2 python e2e/generate-test-data.py - name: Start stack run: docker compose up -d --wait --build timeout-minutes: 10 env: RATE_LIMIT_RPM: "0" - name: Wait for health run: | for i in $(seq 1 30); do if curl -sf http://localhost:8000/api/health > /dev/null 2>&1; then echo "Backend healthy" exit 0 fi echo "Waiting for backend... ($i/30)" sleep 5 done echo "Backend failed to start" docker compose logs exit 1 - name: Run E2E tests run: | KARATE_TAGS="@smoke" if [[ "${{ github.base_ref }}" == release/* ]] || [[ "${{ github.ref }}" == refs/heads/release/* ]]; then KARATE_TAGS="@smoke,@regression,@e2e" fi mvn test -f e2e/pom.xml -Dkarate.options="--tags ${KARATE_TAGS}" - name: Upload Karate reports if: always() uses: actions/upload-artifact@v4 with: name: karate-reports path: e2e/target/karate-reports/ - name: Tear down if: always() run: docker compose down