feat(ci): add E2E tests with PHP code coverage#253
Merged
Conversation
- Add E2E job to CI workflow that runs Playwright tests - Create PHP coverage collector (public/coverage.php) for E2E tests - Enable coverage collection via COVERAGE_ENABLED and XDEBUG_MODE env vars - Upload E2E coverage to Codecov with 'e2e' flag - Upload PHPUnit coverage with 'unit' flag for separation - Include test artifacts (screenshots, reports) on failure The coverage collector: - Starts Xdebug coverage on each HTTP request - Saves coverage data to var/coverage/e2e/*.json - Provides /coverage.php?action=report endpoint for Clover XML export - Only active when COVERAGE_ENABLED=1
There was a problem hiding this comment.
Pull request overview
This PR adds E2E test execution to the CI pipeline with PHP code coverage collection via Xdebug. The implementation includes a new coverage collector script, CI workflow job, and configuration changes to enable coverage during E2E tests.
Changes:
- New E2E CI job that builds the E2E Docker image, runs Playwright tests, and collects coverage
- PHP coverage collector (
public/coverage.php) with API endpoints for status, report generation, and clearing data - Integration in
index.phpto conditionally load coverage collector based on environment variables
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 21 comments.
| File | Description |
|---|---|
.github/workflows/ci.yml |
Adds E2E job with coverage collection, Playwright execution, and Codecov upload with e2e flag |
public/coverage.php |
New file implementing coverage collection, Clover XML generation, and API endpoints |
public/index.php |
Conditionally includes coverage.php when COVERAGE_ENABLED=1 |
compose.yml |
Adds COVERAGE_ENABLED and XDEBUG_MODE environment variables to app-e2e service |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #253 +/- ##
=========================================
Coverage 46.07% 46.07%
Complexity 2627 2627
=========================================
Files 172 172
Lines 7205 7205
=========================================
Hits 3320 3320
Misses 3885 3885
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Coverage collector fixes: - Fix nginx routing detection using REQUEST_URI instead of SCRIPT_FILENAME - Add error handling for file operations (mkdir, file_put_contents, unlink) - Handle glob() returning false - Validate action and format parameters - Use random_bytes() for better unique ID generation - Filter dead code (-2) and non-src files during collection - Use restrictive permissions (0755 for directories) - Require COVERAGE_ENABLED=1 for API access - Only enable coverage in test/dev environments CI improvements: - Add E2E test sharding (3 parallel jobs) - Add --max-failures=10 for fail-fast behavior - Use more restrictive chmod permissions (755 instead of 777) - Pass COVERAGE_ENABLED and XDEBUG_MODE as proper env vars - Reduce timeout to 20 minutes per shard
Performance optimizations: - Create E2E Docker target with Playwright + Chromium pre-installed - Build and push E2E image via Docker Publish workflow - CI pulls pre-built image (falls back to build if unavailable) - Run Playwright tests inside container (no host browser install) - Increase workers from 1 to 2 per shard for parallelism - Use -x flag for immediate fail-fast behavior Expected time savings: - Skip ~4 min image build per shard (after first push) - Skip ~30s Playwright browser install per shard - Total: ~15 min saved across 3 shards Changes: - Dockerfile: Add e2e target extending dev with Playwright - docker-bake.hcl: Update app-e2e to use e2e target - docker-publish.yml: Build and push E2E image - ci.yml: Pull image, run tests in container - playwright.config.ts: Use 2 workers in CI
docker compose run doesn't support --network flag like docker run. Use internal service name httpd-e2e:80 instead of host network.
…h check - Add Symfony cache warmup for test environment - Improve health check to fail if app doesn't start - Add container logs output on failure for debugging - Increase retry attempts with better feedback
The deps stage runs composer install --no-dev which doesn't install MakerBundle. But composer post-install scripts run with default APP_ENV=dev, causing Symfony to try loading the dev-only MakerBundle class. Setting APP_ENV=prod prevents dev bundles from being loaded during cache warmup.
Show HTTP response code, response body, PHP-FPM logs, nginx logs, and Symfony error log to help diagnose why the app returns 500 errors.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds E2E test execution to CI with PHP code coverage collection and significant performance optimizations.
Changes
1. E2E CI Job with Sharding
-xflag (stop on first failure)2. Pre-built E2E Docker Image
e2eDockerfile target with Playwright + Chromium pre-installed3. PHP Coverage Collector
var/coverage/e2e//coverage.php)COVERAGE_ENABLED=1in test/dev environment4. Coverage Integration
unitflage2eflag (per shard)Performance Improvements
Test Plan
unitflagHow E2E Coverage Works
Local Usage