Problem/Motivation
Tests recently for several D7 contrib modules are failing when using Composer 2, see https://www.drupal.org/node/130687/qa and also i18n and file_entity automated tests and likely many many others are severely failing despite no code changes since prior passing runs.
Tests pass locally, but on drupal.org, tests fail when using Composer 2 on the PHP 7.3 thru PHP 8.1 environments, and pass when using Composer 1 on older PHP versions.
It looks like perhaps a dependency cannot be found, as tests fail during the setUp method.
I did notice that if I install my module locally using Composer 2, the module directories are empty, apparently due to this drupal-composer/preserve-paths bug: https://github.com/drupal-composer/preserve-paths/issues/39 - not sure if the same bug is being encountered on drupal.org
Steps to reproduce
Run Drupal 7 automated tests at e.g. https://www.drupal.org/node/130687/qa or https://www.drupal.org/node/2599354/qa Note that previously passing tests on PHP 8.1 such as https://www.drupal.org/pift-ci-job/2384907 printed a warning message:
You have until July 2022 to add the setting. Composer will then switch the default behavior to disallow all plugins.
Proposed resolution
We should run "composer config" to allow the composer/installers plugin before installing it. I believe this should resolve errors such as In PluginManager.php line 769: composer/installers 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 config --no-plugins allow-plugins.composer/installers [true|false]" to enable it (true) or disable it explicitly and suppress this exception (false) See https://getcomposer.org/allow-plugins at https://www.drupal.org/pift-ci-job/2432484 - and hopefully resolves other test failures as well, which seem to be caused by missing dependencies.
Remaining tasks
Review patch and verify the fix in a DrupalCI instance (for all PHP versions).
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 3294386-20.patch | 1.13 KB | mfb |
| #7 | 3294386-7.patch | 1.13 KB | mfb |
Comments
Comment #2
joseph.olstadI confirm , have observed this problem also, but in other contrib modules, quite likely all of D7 contrib is affected.
several changes noted comparing to passed and failed tests when the module code base is stable between tests.
It appears that changes to the test runner ci in the past month or so (june/july) have caused an issue resulting in massive test fails in various projects.
Comment #3
joseph.olstadComment #4
joseph.olstadComment #5
joseph.olstadComment #6
mfb[Edited to add more info]
Looks like all of my D7 contrib projects are now showing "D7 Composer require failure" with PHP 8.1
Additionally, some of my D7 contrib projects are failing with PHP 7.3 thru 8.0 (which use Composer 2) e.g. https://www.drupal.org/node/130687/qa and https://www.drupal.org/node/2599354/qa However for another project tests are passing on PHP 7.3 thru 8.0: https://www.drupal.org/node/146238/qa
Comment #7
mfbPerhaps allowing the composer/installers plugin will help? I do see some warnings about it not being allowed to run.
I haven't yet setup a local instance of drupalci to confirm this, however.
Comment #8
mfbComment #9
mfbComment #10
joseph.olstad@mfb, thanks for looking into this, I imagine this patch is for the Drupal.org ci runner? Someone will know what do do with your patch? Hoping this is resolved soon!
Comment #11
joseph.olstadComment #12
mfbbtw, Drupal core 7.x branch might have the same test failures, as test runs there also print "You have until July 2022 to add the setting. Composer will then switch the default behavior to disallow all plugins."
Comment #13
MixologicThe 8.1 containers were rebuilt, which introduced a newer version of composer for 8.1, specifically.
This issue reports 7.3, but I dont see any evidence of that happening.
I've applied the patch in #7, and deployed it, and it appears to fix 8.1 testing.
https://www.drupal.org/pift-ci-job/2435502 shows it passing now.
Im marking this fixed. if there are still other jobs breaking, let me know.
Comment #14
mfbThanks :)
I'm actually now seeing test failure on PHP 7.2 for some reason - but this is an old version so reducing priority.
see e.g. https://www.drupal.org/node/130687/qa https://www.drupal.org/node/146238/qa https://www.drupal.org/node/532982/qa https://www.drupal.org/node/2599354/qa
Comment #15
joseph.olstadThanks @Mixologic
Comment #16
joseph.olstadactually I should also say thanks to @mfb, since it was your genious patch that fixed the glitch.
Comment #17
mfbmaybe we could just allow this command to fail, since it doesn't work with Composer 1? I don't have a container handy to experiment.
Comment #18
damienmckennaI can confirm that the changes fixed the test failures that Metatag started seeing recently too (#3294781). Thanks everyone!
Comment #19
mfbHere's a follow-up to see if we can get tests passing with Composer 1 again (don't require the command to succeed)
Comment #20
mfbFixing punctuation in the message
Comment #21
mfb@Mixologic could you take a look at #20 - this might fix test runs on Composer 1
Comment #22
joseph.olstadYes please have a look at #20, php 7.2 testing is blocked atm
Comment #23
MixologicLooks good, I deployed this patch today and a running test on an older php version appears to work fine now (composer 1 fails and moves on)
https://dispatcher.drupalci.org/job/drupal_d7/219565/console
Thank you for the patches, has made fixing this considerably easier.
Comment #24
joseph.olstadsomething weird
#3307795: Drupal 7.x core tests dissappeared
Comment #25
joseph.olstadComment #26
mfbI believe this could be closed now. The one remaining issue I've seen with Drupal 7 modules is phpcs not working, but we might be able to resolve that over in #3283978: Remove --config-set installed_paths (Referenced sniff does not exist).