Customize DrupalCI config to allow running cweagans/composer-patches; fails otherwise

Created on 4 September 2022, about 2 years ago
Updated 22 May 2023, over 1 year ago

Important note

The current hypothesis is that there seems to be a delay or other factor that prevents immediate changes to a project's DrupalCI config being applied to new test runs, either by design or as a limitation of the testing system. This seems to be partly or mostly backed up via trial and error, waiting a day or so, and running the tests again. This doesn't always resolve things, so it still needs more work and evaluating.

Original summary follows for archive purposes.

Problem/Motivation

DrupalCI now results in a "Composer require failure" such as the following โ†’ :

--- Commands Executed ---
sudo -u www-data /usr/local/bin/composer require drupal/config_enforce_devel 1.0.x-dev#6997c904e0133ffaa1eb9624f8f5584449c1e44a --prefer-stable --no-progress --prefer-dist --no-suggest --no-interaction --working-dir /var/www/html
Return Code: 1
--- Output ---

--- Errors ---
You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.
./composer.json has been updated
Running composer update drupal/config_enforce_devel
> Drupal\Composer\Composer::ensureComposerVersion
Loading composer repositories with package information
Updating dependencies
Lock file operations: 5 installs, 0 updates, 0 removals
  - Locking cweagans/composer-patches (1.7.3)
  - Locking drupal/config_devel (1.8.0)
  - Locking drupal/config_enforce (1.0.0-rc4)
  - Locking drupal/config_enforce_devel (dev-1.0.x 6997c90)
  - Locking drupal/multiselect (1.2.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 5 installs, 0 updates, 0 removals
As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' or '7z' (21.01+) may remediate them.
  - Syncing drupal/config_enforce_devel (dev-1.0.x 6997c90) into cache

In PluginManager.php line 738:
                                                                               
  cweagans/composer-patches contains a Composer plugin which is blocked by yo  
  ur allow-plugins config. You may add it to the list if you consider it safe  
  .                                                                            
  You can run "composer config --no-plugins allow-plugins.cweagans/composer-p  
  atches [true|false]" to enable it (true) or disable it explicitly and suppr  
  ess this exception (false)                                                   
  See https://getcomposer.org/allow-plugins                                    

Steps to reproduce

Run module tests via DrupalCI; get above error.

Proposed resolution

The error suggests running composer config --no-plugins allow-plugins.cweagans/composer-patches true, which we may be able to do via a custom command in a drupalci.yml:

However, attempts to make this work have all failed, because DrupalCI seems to not run our custom commands before it tries to composer install and it's unclear if it's possible to specify where to run our commands.

Trying to find good examples of how to accomplish this has been rather difficult and the documentation doesn't provide 100% clear examples of a fully working configuration, at least for our purposes.

It looks like this may be a current limitation of the DrupalCI testbot as detailed in #3334914-13: Testing is broken because simplesamlphp/composer-module-installer contains a Composer plugin which is blocked โ†’ so hopefully a fix will be implemented at some point. There's also #3261803: Using GitLab CI instead of Drupal CI โ†’ which is currently in alpha.

In the short term, we can try removing the plug-in from our composer.json so that testing can pass. We'll have to provide instructions in our installation documentation for requiring it.

Working example: the Color Field module โ†’

This module supports Asset Packagist packages, but in their case, they only provide them in their "suggest" composer.json field. That said, they have a working drupalci.yml which results in successful builds for testing as can be seen on their Automated testing tab โ†’ .

Other examples and links

Remaining tasks

See above.

User interface changes

None.

API changes

None.

Data model changes

None.

๐Ÿ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada ambient.impact Toronto

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024