Skip to content

quality.yml: a missing phpcs composer script passes VACUOUSLY (composer exit 1 read as 'warnings only') #121

Closed

Description

@rubenvdlinde

Summary

In .github/workflows/quality.yml, the phpcs leg maps composer's exit code 1 to success. Composer itself exits 1 when the requested script does not exist, so a repo with no phpcs composer script gets a green "PHP Quality (phpcs)" tick forever.

The code

.github/workflows/quality.yml, the phpcs) branch of the Run ${{ matrix.tool }} step:

# Exit code 0 = clean, 1 = warnings only, 2 = errors found.
# We treat warnings as non-blocking (exit 1 → success).
RC=0
composer phpcs || RC=$?
if [ "$RC" -eq 1 ]; then
  echo "::warning::PHPCS found warnings but no errors — passing."
  exit 0
fi
exit $RC

The comment describes phpcs's exit codes, but RC captures composer's. Composer returns 1 both for "the script ran and returned 1" and for "there is no such script".

Evidence

ConductionNL/app-versions run 30677226950, job quality / PHP Quality (phpcs) — conclusion success:

##[error]Command "phpcs" is not defined.
##[warning]PHPCS found warnings but no errors — passing.

app-versions has no phpcs.xml and no phpcs composer script; it uses php-cs-fixer. Its phpmd and phpstan legs correctly went red with Command "…" is not defined. — only phpcs swallowed it, because only phpcs has the exit-1 special case.

Impact

Any fleet repo that has never adopted phpcs shows a passing phpcs job. Because a gate's absence and a gate's success look identical in the checks list, this is indistinguishable from coverage. enable-phpcs defaults to true, so it applies by default.

Suggested fix

Assert the script exists before interpreting its exit code:

if ! composer run-script --list 2>/dev/null | grep -qE '^\s*phpcs\s'; then
  echo "::error::enable-phpcs is true but this repo has no 'phpcs' composer script."
  exit 1
fi
RC=0
composer phpcs || RC=$?
...

The same existence check is worth applying to every tool leg — it turns today's confusing Command "phpmd" is not defined. failure into an actionable message, and closes the phpcs hole.

Context

Found while repairing composer check:strict in openbuild, nldesign and app-versions. Related: ConductionNL/app-versions#118.

Activity

  1. rubenvdlinde commented on Aug 2, 2026

    @rubenvdlinde
    ContributorAuthor

    Fixed in #123 (merged to main).

    Post-merge verification. Run 30766687154 on ConductionNL/petstore (branch feature/dotgithub-121-proof, composer.json with the phpcs script deliberately renamed away) was re-run at the same SHA before and after the merge. Nothing in petstore changed; only ConductionNL/.github@main did.

    • attempt 1 (pre-merge main): quality / PHP Quality (phpcs) → success, with ##[warning]PHPCS found warnings but no errors — passing. immediately after composer's Did you mean one of these? suggestion list.
    • attempt 2 (post-merge main): quality / PHP Quality (phpcs) → failure:
    ##[error]The 'phpcs' gate is enabled but composer.json declares no 'phpcs' script. Add it under "scripts", or turn the gate off with the enable-phpcs input.
    ##[error]Process completed with exit code 1.
    

    Blast radius: one repo, one leg. All 19 org consumers of quality.yml were swept for the six gate scripts in their default-branch composer.json. Eighteen declare all six and are unaffected. Only ConductionNL/app-versions changes: its PHP Quality (phpcs) tick goes green → red. Its phpmd / phpstan / phpmetrics legs were already red for the same missing-script reason; phpcs was the only one being swallowed. One-line fix on that side: enable-phpcs: false in .github/workflows/code-quality.yml (ConductionNL/versioniq#118).

    The proof branch ConductionNL/petstore@feature/dotgithub-121-proof is left in place as an inspectable evidence trail. It is not attached to a PR and must not be merged — it renames petstore's phpcs composer script.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions