Skip to content

feat(lint-php): annotate and cache PHP lint results - #63

Open
Adi-ty wants to merge 1 commit into
mainfrom
fix/lint-php-adoption-gaps
Open

Adi-ty wants to merge 1 commit into
mainfrom
fix/lint-php-adoption-gaps

Conversation

@Adi-ty

@Adi-ty Adi-ty commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

Makes ci-lint-php.yml annotate PHPCS and PHPStan results on the right files in a monorepo, caches both linters' results, and lets the ruleset decide whether PHPCS warnings fail the job.

Closes

Part of #51

Changes

  • PHPCS writes its checkstyle report to a file for cs2pr and prints --report-full in the log, so every violation shows with file and line, including those past GitHub's 10-annotations-per-step limit. --basepath=$GITHUB_WORKSPACE makes annotation paths repo-relative in a monorepo.
  • PHPStan runs with --error-format=checkstyle and is annotated through cs2pr. Relative paths get the working-dir prefix so they resolve from the repo root; absolute paths and non-file errors pass through unchanged.
  • Restore/save steps cache the PHPCS result file and PHPStan's tmpDir, with a per-run key and a restore-keys prefix of OS, PHP version, working-dir and the composer.lock hash. tmpDir comes from phpstan dump-parameters --json; if that fails, only the PHPStan cache is skipped.
  • PHPStan and the cache save run whenever Composer install succeeded, so a PHPCS failure no longer skips PHPStan.
  • Dropped --runtime-set ignore_warnings_on_exit 1: PHPCS warnings now fail the job unless the ruleset sets <config name="ignore_warnings_on_exit" value="1"/>. The CLI flag also overrode a ruleset that wanted warnings to fail.
  • phpcs-command / phpstan-command descriptions say the command must forward its arguments.

How I verified

$ pipx run yamllint .
./.github/workflows/ci-lint-php.yml
  23:201    warning  line too long (334 > 200 characters)  (line-length)   # already on main
$ actionlint .github/workflows/*.yml examples/*.yml
$ bin/check-workflows.sh
Workflow/example contract check passed.

Ran the extracted step bodies in a php:8.3 container (PHPCS 3.13.6 and 4.0.4, PHPStan 2.3.5): 24/24 cases, covering monorepo and root annotation paths, warnings with and without the ruleset opt-out, cache write and reuse, the wp-phpcs template args, PHPStan unmatched ignores and non-file errors, and a symlinked workspace. Also ran the PHPStan step on macOS (bash 3.2, BSD sed).

Acceptance criteria

Runtime behavior

  • PHPCS annotations point at the real file in a monorepo
  • PHPStan annotations point at the real file; absolute paths untouched
  • Warnings fail the job unless the ruleset opts out
  • PHPStan still runs when PHPCS fails
  • Custom phpcs-command / phpstan-command still receive the flags as argv

Code quality

  • Lint — only the pre-existing long line on 23
  • Static analysis — actionlint clean
  • Tests — bin/check-workflows.sh

Housekeeping

  • PR title is a Conventional Commit
  • examples/ci-lint-php.yml unchanged (no input changes)
  • yamllint, actionlint, bin/check-workflows.sh pass

Reviewer notes

  • Behaviour change for @v1 callers: a ruleset without ignore_warnings_on_exit now fails on warnings. Shipped as feat, not feat!, so v1 callers get it; say if you'd treat it as breaking.
  • PHPStan inside wp-env is deferred to the wp-env PR for [wp-ci] Close the adoption gaps for consuming projects #51.
  • A custom phpstan-command that points PHPStan at another config may miss the cache, since tmpDir is read from the default config; it still runs.
  • Dependabot feat(deps): bump actions/cache from 4.2.0 to 6.1.0 #59 bumps actions/cache; whichever merges second aligns the pins.

Conventions: AGENTS.md · PR process: CONTRIBUTING.md

@Adi-ty Adi-ty changed the title feat(lint-php): annotate and cache PHP lint results. feat(lint-php): annotate and cache PHP lint results Nov 5, 2026
@Adi-ty
Adi-ty marked this pull request as ready for review November 5, 2026 11:39
Copilot AI balanced review requested due to automatic review settings November 5, 2026 11:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants