Skip to content

ci: install phpcs + Drupal coding standard before unit tests#53

Merged
darrenoh merged 5 commits intomainfrom
copilot/fix-workflow-run-failure
Mar 15, 2026
Merged

ci: install phpcs + Drupal coding standard before unit tests#53
darrenoh merged 5 commits intomainfrom
copilot/fix-workflow-run-failure

Conversation

Copy link
Contributor

Copilot AI commented Mar 15, 2026

  • Investigate CI failure and identify missing phpcs installation
  • Add phpcs installation step (with Drupal coding standard) to tests.yml workflow
    • Allows dealerdirect/phpcodesniffer-composer-installer plugin before requiring packages
    • Installs squizlabs/php_codesniffer=* and drupal/coder=* via Composer global (always latest)
    • Lets the dealerdirect plugin auto-register all coding standards (drupal/coder + slevomat) — fixes missing SlevomatCodingStandard sniffs
    • Adds Composer global bin-dir to $GITHUB_PATH instead of using a sudo symlink

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Co-authored-by: darrenoh <2293701+darrenoh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix workflow run failure due to missing phpcs ci: install phpcs + Drupal coding standard before unit tests Mar 15, 2026
Copilot AI requested a review from darrenoh March 15, 2026 01:39

- name: Install PHP CodeSniffer with Drupal coding standard
run: |
composer global require "squizlabs/php_codesniffer=^4.0" "drupal/coder=^9.0"
Copy link
Member

Choose a reason for hiding this comment

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

Let's not lock versions. We always want to require the latest version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done — updated to use =* for both packages in 0694631.

Co-authored-by: darrenoh <2293701+darrenoh@users.noreply.github.com>
Copilot AI requested a review from darrenoh March 15, 2026 02:03
@darrenoh darrenoh requested a review from Copilot March 15, 2026 02:05
@darrenoh darrenoh marked this pull request as ready for review March 15, 2026 02:05
Copy link
Member

@darrenoh darrenoh left a comment

Choose a reason for hiding this comment

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

The failing job is due to the following Composer error:

dealerdirect/phpcodesniffer-composer-installer (installed globally) contains a Composer plugin which is blocked by your allow-plugins config. You may add it to the list if you consider it safe.
You can run "composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer [true|false]" to enable it (true) or disable it explicitly and suppress this exception (false)
See https://getcomposer.org/allow-plugins

Solution:
Add the plugin to Composer’s allow-plugins configuration before running composer global require in your workflow. Update your install step in .github/workflows/tests.yml as follows:

- name: Install PHP CodeSniffer with Drupal coding standard
  run: |
    composer global config --no-interaction allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
    composer global require "squizlabs/php_codesniffer=*" "drupal/coder=*"
    # Register the Drupal coding standard with phpcs
    "$(composer global config bin-dir --absolute --quiet)/phpcs" \
      --config-set installed_paths \
      "$(composer global config home --quiet)/vendor/drupal/coder/coder_sniffer"
    # Make phpcs available system-wide
    sudo ln -sf "$(composer global config bin-dir --absolute --quiet)/phpcs" /usr/local/bin/phpcs
  env:
    COMPOSER_ALLOW_SUPERUSER: '1'

This ensures the Composer plugin is explicitly allowed, fixing the error and unblocking the installation step.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the CI unit-tests job to ensure PHP CodeSniffer (phpcs) and the Drupal coding standard are installed before the shell-based unit test suite runs, preventing tests/test-phpcs.sh from failing due to missing tooling.

Changes:

  • Add a workflow step to install squizlabs/php_codesniffer and drupal/coder via composer global require
  • Configure phpcs to recognize Drupal’s sniffs via --config-set installed_paths
  • Symlink phpcs into /usr/local/bin so it’s available on PATH during tests

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: darrenoh <2293701+darrenoh@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 15, 2026

The failing job is due to the following Composer error:

dealerdirect/phpcodesniffer-composer-installer (installed globally) contains a Composer plugin which is blocked by your allow-plugins config. Y...

Fixed in 261ef71 — added composer global config --no-interaction allow-plugins.dealerdirect/phpcodesniffer-composer-installer true before the composer global require step.

Copilot AI requested a review from darrenoh March 15, 2026 02:09
Copy link
Member

@darrenoh darrenoh left a comment

Choose a reason for hiding this comment

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

The job failed during the "test-phpcs" stage due to missing PHP_CodeSniffer sniffs from the Slevomat Coding Standard. The log reports errors such as:

  • ERROR: Referenced sniff "SlevomatCodingStandard.Classes.BackedEnumTypeSpacing" does not exist.
  • Several other SlevomatCodingStandard sniffs are also reported missing.

This indicates that the required Slevomat Coding Standard is not installed or is not available to PHP_CodeSniffer in your workflow.

Solution:
You need to ensure the Slevomat Coding Standard for PHP_CodeSniffer is installed and accessible before running phpcs. Typically, this is managed via Composer.

Code Fix

In your workflow definition (likely in .github/workflows/tests.yml), add or update the step that installs coding standards, for example:

- name: Install Slevomat Coding Standard
  run: |
    composer require --dev slevomat/coding-standard
    ./vendor/bin/phpcs --config-set installed_paths vendor/slevomat/coding-standard

You should place this step before running phpcs in your workflow. This ensures the Slevomat coding standard and all its referenced sniffs are available for phpcs runs.

Summary:
Install Slevomat Coding Standard via Composer and ensure it's registered with PHP_CodeSniffer. This will resolve the "sniff does not exist" errors and allow phpcs to apply your coding standards correctly.

… phpcs

Co-authored-by: darrenoh <2293701+darrenoh@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 15, 2026

The job failed during the "test-phpcs" stage due to missing PHP_CodeSniffer sniffs from the Slevomat Coding Standard. The log reports errors such as:

  • ERROR: Referenced sniff "SlevomatCodingStandard...

Fixed in ea9cfb2 — removed the manual --config-set installed_paths step and now rely on the dealerdirect/phpcodesniffer-composer-installer plugin (already allowed) to auto-register all installed coding standards, including slevomat/coding-standard (a dependency of drupal/coder).

Copilot AI requested a review from darrenoh March 15, 2026 02:17
@darrenoh darrenoh merged commit 534dc0b into main Mar 15, 2026
3 checks passed
@darrenoh darrenoh deleted the copilot/fix-workflow-run-failure branch March 15, 2026 02:21
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.

3 participants