Skip to content

fix(ci): pass only lintable files to Stylelint and PHPCS - #40

Merged
aryanjasala merged 2 commits into
release/v1.0.0from
fix/changed-files-linting
Oct 1, 2026
Merged

aryanjasala merged 2 commits into
release/v1.0.0from
fix/changed-files-linting

Conversation

@aryanjasala

Copy link
Copy Markdown
Member

ci-detect-changes puts more than source files into the changed-file lists: css-files includes package.json and package-lock.json, and php-files includes composer.json, composer.lock and the PHPStan config, so that a dependency or config change re-runs the lint jobs. A change that deletes files lists those too. The lint jobs passed these lists straight to the linters:

Changes

  • ci-lint-css.yml: changed stylesheets are linted file by file only when nothing else is in the list. Otherwise, or with an empty list, lint-command runs over the whole project.
  • ci-lint-php.yml: changed PHP files that still exist are linted file by file only when nothing else is in the list. Otherwise PHPCS lints the whole project. PHPStan is unchanged (always whole-project).

Linting the whole project when a manifest or config changed is also the right behaviour on its own: a new @rtcamp/stylelint-config or rtcamp/wp-phpcs can change the result for every file.

Testing

  • actionlint: clean
  • Both steps run under bash -e -o pipefail with the linters stubbed:
changed-files Stylelint PHPCS
only source files those files those files
a manifest or config file only whole project whole project
source files plus a manifest or config file whole project whole project
a deleted PHP file plus an existing one n/a the existing one
only deleted PHP files n/a whole project
empty whole project whole project
trailing newline that file that file

…e manifests

ci-detect-changes lists package.json and package-lock.json in css-files so a
dependency change re-runs Stylelint, but ci-lint-css passed them straight to
Stylelint, which failed with CssSyntaxError. Lint changed stylesheets file by
file only when nothing else is in the list; otherwise run lint-command over
the whole project, since a dependency change can affect every stylesheet.
ci-detect-changes lists composer.json, composer.lock and the PHPStan config
in php-files, and a change that deletes PHP files lists those too.
ci-lint-php passed the whole list to PHPCS, which failed with 'does not
exist' for deleted files and 'Start tag expected' for the config files, as
on rtCamp/theme-elementary#692. Lint changed PHP files that still exist file
by file only when nothing else is in the list; otherwise lint the whole
project, since a dependency or ruleset change can affect every file.
@aryanjasala
aryanjasala merged commit 2b73f70 into release/v1.0.0 Oct 1, 2026
@aryanjasala
aryanjasala deleted the fix/changed-files-linting branch October 1, 2026 21:09
aryanjasala added a commit that referenced this pull request Oct 1, 2026
Picks up #42. Both added an Unreleased section to CHANGELOG.md; it now
holds #42's Changed entry and #40's Fixed entries.
@aryanjasala aryanjasala mentioned this pull request Oct 1, 2026
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