PHPCS is run even when it cannot check any files

Created on 20 March 2025, 3 months ago

Problem/Motivation

The PHPCS job is added to the pipeline and runs even when there are no files for it to check.

Here is an example where there a no .php files or any other file extensions that PHPCS can check. Running with _PHPCS_EXTRA: -v shows 0 files checked.

Maybe there is a mismatch between the job rules and the list of php files we derive? It is odd to have the job running when it cannot do anything.

Proposed resolution

Feature request
Status

Active

Component

gitlab-ci

Created by

🇬🇧United Kingdom jonathan1055

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jonathan1055
  • 🇬🇧United Kingdom jonathan1055

    The phpcs job has:

      rules:
        - *skip-phpcs-rule
        - if: $_PHPCS_ALLOW_FAILURE == "1" || ($_ALL_VALIDATE_ALLOW_FAILURE == "1" && $_PHPCS_ALLOW_FAILURE != "0")
          allow_failure: true
        - if: $_PHPCS_ALLOW_FAILURE == "0" || $_ALL_VALIDATE_ALLOW_FAILURE == "0"
          allow_failure: false
        - when: on_success
    

    There is no checking at all for what file types exist, so that is why the GTD main branch runs the jobs but checks zero files.

    The default assets/phpcs.xml checks file extensions of php,inc,module,install,info,test,profile,theme

    We currently have a rule .php-files-exist which checks for:

      exists:
        - '*.{$DRUPAL_PHP_FILE_TYPES}'
        - '**/*.{$DRUPAL_PHP_FILE_TYPES}'
    

    where $DRUPAL_PHP_FILE_TYPES is defined as php,module,install,inc,profile,theme,engine

    These are nearly the same set. phpcs.xml has .info and .test which are not in $DRUPAL_PHP_FILE_TYPES. I think these are exclusively Drupal 7 filetype extensions, not used in Drupal 8+ ?

    However $DRUPAL_PHP_FILE_TYPES has .engine which is not in the phpcs.xml list.

    We could use .php-files-exist in the phpcs job definition for the main pipeline, and if we wanted to backport to main-d7 we could also add .info and .test but that's not a problem.

  • 🇪🇸Spain fjgarlin

    Yeah, that sounds like a good way forward. We can/should unify the extentions being checked for D8+ and add the extra ones for D7.

  • 🇬🇧United Kingdom jonathan1055

    I used _PHPCS_EXTRA: -v and verified that the Coding Standards phpcs job is checking 0 files, just like our GTD branch

    We can/should unify the extentions being checked

    So is there any harm in adding 'info' and 'test' into $DRUPAL_PHP_FILE_TYPES and also adding 'engine' into the assets/phpcs.xml file? Then $DRUPAL_PHP_FILE_TYPES will work in D8+ and also in the D7 job. Or should the Drupal7 specifc extensions be added via hardcoding an extra line in the d7 phpcs job rule? If D8+ does not have any files ending .info or .test then I can't see any problem adding them into the list.

    Maybe I will just start the work and see how it looks, the you can make a judgement when you can see the chnages :-)

  • 🇪🇸Spain fjgarlin

    Yeah, agree. We can have them all under the same variable.

Production build 0.71.5 2024