# Run from your project root
vendor/lts/php-qa-ci/scripts/install-github-actions.bashOr manually:
mkdir -p .github/workflows
cp vendor/lts/php-qa-ci/templates/github-actions/php-qa-ci.yml .github/workflows/qa.ymlgit add .github/workflows/qa.yml
git commit -m "Add PHP QA pipeline"
git pushThe workflow will run automatically on your next push or pull request.
The workflow automatically detects the PHP version from your composer.json file's require.php constraint. No manual configuration needed.
- Shallow clone by default: Faster CI runs
- Full clone when needed: Only when
AUTO_COMMIT_FIXESis enabled - Protected branch safety: Never auto-commits to main/master or default branch
Manually trigger specific tools from GitHub UI:
- Actions -> PHP QA Pipeline -> Run workflow -> Select tool
- Test results saved for 7 days
- Coverage reports available for download
- Useful for debugging failed builds
Add these to the env: section of your workflow:
env:
CI: true # Required
skipUncommittedChangesCheck: 1 # Required
AUTO_COMMIT_FIXES: 'false' # Enable auto-commit of fixes
phpUnitCoverage: 0 # Disable coverage
phpqaQuickTests: 1 # Quick test mode
useInfection: 0 # Skip mutation testing
phpqaMemoryLimit: 4G # Memory limit for all QA toolsTo enable automatic committing of Rector/CS Fixer changes:
env:
AUTO_COMMIT_FIXES: 'true' # Only on feature branchesSafety Features:
- Never commits to main/master branches
- Never commits to repository's default branch
- Requires write permissions in repository settings
- Adds
[skip ci]to prevent infinite loops
- Go to Settings -> Actions -> General
- Under "Workflow permissions":
- Select "Read and write permissions"
- Check "Allow GitHub Actions to create and approve pull requests" (if using auto-commits)
- Go to Settings -> Branches
- Add rule for main/master branch
- Check "Require status checks to pass before merging"
- Select "PHP QA Pipeline" as required check
PHP-QA-CI includes an update-deps.yml workflow that runs weekly to automatically update all dependencies:
- Composer dependencies (
composer update) - PHARs via PHIVE (
phive update) -- PHPStan, PHP CS Fixer, Infection, Composer Require Checker - Isolated Rector installation (
composer update --working-dir=tools/rector)
If changes are detected, it runs the full QA pipeline. If QA passes, it creates a pull request with auto-merge enabled.
To add this to your project:
cp vendor/lts/php-qa-ci/.github/workflows/update-deps.yml .github/workflows/update-deps.ymlSee Continuous Integration for more details on the available workflows.
Place configuration files in your project's qaConfig/ directory:
qaConfig/qaConfig.inc.bash- Override pipeline settingsqaConfig/phpstan.neon- PHPStan configurationqaConfig/phpunit.xml- PHPUnit configurationqaConfig/php_cs.php- PHP CS Fixer rulesqaConfig/rector.php- Rector rulesqaConfig/infection.json- Infection configuration
- Go to Actions tab
- Select "PHP QA Pipeline"
- Click "Run workflow"
- Select tool from dropdown
- name: Run specific tool
run: vendor/bin/qa -t phpstanThe workflow caches:
- Composer dependencies
- QA tool PHARs
- PHPStan cache
Cache keys include PHP version to prevent conflicts.
The workflow includes:
- Dynamic PHP version detection from composer.json
- Smart git cloning (shallow by default, full when auto-commit enabled)
- PHIVE integration for PHAR tool management
- Comprehensive caching for speed
- Auto-commit capability with safety checks
- Manual tool selection via workflow_dispatch
- Artifact storage for test results and coverage
- Extensive inline documentation
"php-qa-ci not installed" error
composer require --dev lts/php-qa-ci:dev-php8.4@devPermission denied for auto-commits
- Check repository Settings -> Actions -> Workflow permissions
- Ensure "Read and write permissions" is selected
Out of memory (default is now 4G for all tools)
env:
phpqaMemoryLimit: 8GInfection timeout
env:
useInfection: 0 # Disable mutation testing in CI- Download artifacts from failed run
- Check
var/qa/directory contents - Run locally with same configuration:
CI=true vendor/bin/qa- Use branch protection - Require QA checks to pass
- Cache aggressively - Speeds up builds significantly
- Skip infection in CI - Run locally for faster feedback
- Auto-commit carefully - Only on feature branches, never on main
- Review workflow documentation - The template has extensive inline comments
- Enable update-deps.yml - Keep dependencies current automatically
- Replace
.travis.ymlwith.github/workflows/qa.yml - Environment variables work similarly
- Artifacts replace Travis's build artifacts
- GitHub Actions is commit-triggered by default
- No need for webhooks or polling
- Use workflow_dispatch for manual triggers
- name: Upload to Codecov
uses: codecov/codecov-action@v3
with:
file: var/qa/phpunit_logs/coverage.clover- name: Slack Notification
if: failure()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}