staabm/annotate-pull-request-from-checkstyle
GitHub Action that annotates pull requests with Checkstyle-compatible reports. Converts XML/JSON output into inline review comments so code style, lint, and static analysis issues appear directly on changed lines during PR review.
staabm/annotate-pull-request-from-checkstyle) bridges static code analysis (Checkstyle XML reports) with GitHub PR feedback, aligning well with CI/CD pipelines where code quality gates are enforced. It fits into developer workflows by surfacing actionable feedback directly in PRs, reducing friction in adoption.phpunit, pest) or pre-commit hooks (e.g., laravel-pint, laravel-shift) to annotate PRs with style/quality violations.--format=checkstyle)--error-format=checkstyle)--output-format=checkstyle)--files flags or post-processing.phpunit.xml or pint.json may define custom rules not covered by default Checkstyle profiles. Solution: Extend the package’s rule mappings or pre-process reports.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| GitHub API Rate Limits | Medium | Use GitHub Actions tokens; implement retries. |
| Checkstyle Report Parsing | Low | Validate XML schema; handle malformed reports. |
| Laravel-Specific Rules | Medium | Pre-process reports or extend rule mappings. |
| CI Pipeline Complexity | High | Start with a single tool (e.g., PHP-CS-Fixer) before adding others. |
| Self-Hosted CI Adaptation | Medium | Abstract GitHub API calls behind an adapter. |
app/Models/User.php") or line-level details (default)?staabm/annotate-pull-request-from-checkstyle via a custom workflow step.--log-junit or custom listeners.--format=checkstyle in composer.json scripts.gitlab-api PHP package).php-cs-fixer locally with --dry-run --format=checkstyle to preview annotations.Phase 1: Proof of Concept (1-2 weeks)
composer.json with Checkstyle output:
"scripts": {
"checkstyle": "php-cs-fixer fix --dry-run --format=checkstyle --rules=@PSR12 --path-mode=intersection app tests > checkstyle.xml"
}
/.github/workflows/checkstyle.yml):
- name: Run Checkstyle
run: composer checkstyle
- name: Annotate PR
uses: staabm/annotate-pull-request-from-checkstyle@v1
with:
path-to-checkstyle-report: "checkstyle.xml"
Phase 2: Expand to Other Tools (2-3 weeks)
- name: Run PHPStan
run: vendor/bin/phpstan analyse --error-format=checkstyle > phpstan.xml
- name: Annotate PR
uses: staabm/annotate-pull-request-from-checkstyle@v1
with:
path-to-checkstyle-report: "phpstan.xml"
Phase 3: Optimization (Ongoing)
vendor/ or node_modules/ from reports.error/warning) with GitHub annotation levels.--path flags to scope reports to Laravel directories.checkstyle-rules.json to map Laravel-specific rules to Checkstyle.Makefile target to generate reports locally:
checkstyle:
composer checkstyle
php vendor/bin/staabm/annotate-pull-request-from-checkstyle checkstyle.xml
CONTRIBUTING.md section explaining how to interpret annotations..github/PULL_REQUEST_TEMPLATE.md with a "Checkstyle Feedback" section.GITHUB_TOKEN with write permissions.--parallel in PHP-CS-Fixer and batch annotations by file.dd() in production code").How can I help you explore Laravel packages today?