name: WAF integration # Phase 2-3: Build Once, Test Many - Use registry image instead of building # This workflow now waits for docker-build.yml to complete and pulls the built image on: workflow_dispatch: inputs: image_tag: description: 'Docker image tag to test (e.g., pr-123-abc1234, latest)' required: false type: string pull_request: push: branches: - main # Prevent race conditions when PR is updated mid-test # Cancels old test runs when new build completes with different SHA concurrency: group: ${{ github.workflow }}-${{ github.event.workflow_run.event || github.event_name }}-${{ github.event.workflow_run.head_branch || github.ref }} cancel-in-progress: true permissions: contents: read jobs: waf-integration: name: Coraza WAF Integration runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Build Docker image (Local) run: | echo "Building image locally for integration tests..." docker build -t charon:local --build-arg CI="${CI:-false}" . echo "✅ Successfully built charon:local" - name: Run WAF integration tests id: waf-test run: | chmod +x scripts/coraza_integration.sh scripts/coraza_integration.sh 2>&1 | tee waf-test-output.txt exit "${PIPESTATUS[0]}" - name: Dump Debug Info on Failure if: failure() run: | { echo "## 🔍 Debug Information" echo "" echo "### Container Status" echo '```' docker ps -a --filter "name=charon" --filter "name=coraza" 2>&1 || true echo '```' echo "" echo "### Caddy Admin Config" echo '```json' curl -s http://localhost:2019/config 2>/dev/null | head -200 || echo "Could not retrieve Caddy config" echo '```' echo "" echo "### Charon Container Logs (last 100 lines)" echo '```' docker logs charon-debug 2>&1 | tail -100 || echo "No container logs available" echo '```' echo "" echo "### WAF Ruleset Files" echo '```' docker exec charon-debug sh -c 'ls -la /app/data/caddy/coraza/rulesets/ 2>/dev/null && echo "---" && cat /app/data/caddy/coraza/rulesets/*.conf 2>/dev/null' || echo "No ruleset files found" echo '```' } >> "$GITHUB_STEP_SUMMARY" - name: WAF Integration Summary if: always() run: | { echo "## 🛡️ WAF Integration Test Results" if [ "${{ steps.waf-test.outcome }}" == "success" ]; then echo "✅ **All WAF tests passed**" echo "" echo "### Test Results:" echo '```' grep -E "^✓|^===|^Coraza" waf-test-output.txt || echo "See logs for details" echo '```' else echo "❌ **WAF tests failed**" echo "" echo "### Failure Details:" echo '```' grep -E "^✗|Unexpected|Error|failed" waf-test-output.txt | head -20 || echo "See logs for details" echo '```' fi } >> "$GITHUB_STEP_SUMMARY" - name: Cleanup if: always() run: | docker rm -f charon-debug || true docker rm -f coraza-backend || true docker network rm containers_default || true