Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/ci-lint-css.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
type: string
default: "npm run lint:css"
changed-files:
description: "Newline-separated list of CSS files to lint. Empty = run lint-command over the whole project."
description: "Newline-separated changed files (ci-detect-changes' css-files). Stylesheets are linted file by file; if the list is empty or holds anything else (package.json, package-lock.json), lint-command runs over the whole project."
type: string
default: ""
working-dir:
Expand Down Expand Up @@ -51,8 +51,13 @@ jobs:
CHANGED_FILES: ${{ inputs.changed-files }}
LINT_COMMAND: ${{ inputs.lint-command }}
run: |
if [ -n "$CHANGED_FILES" ]; then
printf '%s\n' "$CHANGED_FILES" | xargs -d '\n' --no-run-if-empty npx --no-install stylelint --
# css-files also lists package.json and package-lock.json, so a dependency
# change re-runs this job. Stylelint cannot parse them, and a dependency
# change can affect every stylesheet, so lint the whole project then.
stylesheets=$(printf '%s\n' "$CHANGED_FILES" | grep -E '\.s?css$' || true)
others=$(printf '%s\n' "$CHANGED_FILES" | grep -vE '^$|\.s?css$' || true)
if [ -n "$stylesheets" ] && [ -z "$others" ]; then
printf '%s\n' "$stylesheets" | xargs -d '\n' --no-run-if-empty npx --no-install stylelint --
else
bash -eo pipefail -c "$LINT_COMMAND"
fi
13 changes: 10 additions & 3 deletions .github/workflows/ci-lint-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
type: string
default: "vendor/bin/phpcs"
changed-files:
description: "Newline-separated list of PHP files to lint with PHPCS. Empty = lint the whole project. PHPStan always runs whole-project — it analyses cross-file dependencies."
description: "Newline-separated changed files (ci-detect-changes' php-files). PHP files that still exist are linted file by file; if the list is empty or holds anything else (composer.json, composer.lock, PHPStan config), PHPCS lints the whole project. PHPStan always runs whole-project — it analyses cross-file dependencies."
type: string
default: ""
phpstan-command:
Expand Down Expand Up @@ -101,10 +101,17 @@ jobs:
# they stay argv. The pipe to cs2pr stays out here, so a non-zero phpcs still trips
# pipefail exactly as before.
args=(-q --report=checkstyle --runtime-set ignore_warnings_on_exit 1)
if [ -n "$CHANGED_FILES" ]; then
# php-files also lists composer.json, composer.lock and the PHPStan config, so a
# dependency or config change re-runs this job, and it can name files the change
# deleted. PHPCS only takes PHP files that exist; when anything else changed, a
# dependency or ruleset change can affect every file, so lint the whole project.
php_files=$(printf '%s\n' "$CHANGED_FILES" | grep -E '\.php$' \
| while IFS= read -r file; do [ ! -f "$file" ] || printf '%s\n' "$file"; done || true)
others=$(printf '%s\n' "$CHANGED_FILES" | grep -vE '^$|\.php$' || true)
if [ -n "$php_files" ] && [ -z "$others" ]; then
tmp_list=$(mktemp)
trap 'rm -f "$tmp_list"' EXIT
printf '%s\n' "$CHANGED_FILES" > "$tmp_list"
printf '%s\n' "$php_files" > "$tmp_list"
args=(--file-list="$tmp_list" "${args[@]}")
fi
bash -eo pipefail -c "$PHPCS_COMMAND \"\$@\"" _ "${args[@]}" \
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to `@rtcamp/wp-shared-workflows` are documented in this file

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Unreleased

### Fixed

- `ci-lint-css.yml` no longer passes `package.json` and `package-lock.json` to Stylelint. `ci-detect-changes` lists them in `css-files` so that a dependency change re-runs the job, and Stylelint failed on them with `CssSyntaxError`. When `changed-files` holds anything other than stylesheets, or is empty, the job now runs `lint-command` over the whole project.
- `ci-lint-php.yml` no longer passes deleted files or non-PHP files to PHPCS. `ci-detect-changes` lists `composer.json`, `composer.lock` and the PHPStan config in `php-files`, and a change that deletes PHP files lists them too, so PHPCS failed with `does not exist` or `Start tag expected`. Changed PHP files that still exist are linted file by file; if the list holds anything else, PHPCS lints the whole project.

## v1.0.0 - 2026-08-10

First tagged release. Consumers pin `@v1`.
Expand Down