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).

CommentFileSizeAuthor
#20 3294386-20.patch1.13 KBmfb
#19 3294386-19.patch1.13 KBmfb
#7 3294386-7.patch1.13 KBmfb

Comments

mfb created an issue. See original summary.

joseph.olstad’s picture

I 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.

joseph.olstad’s picture

Priority: Normal » Major
joseph.olstad’s picture

Issue summary: View changes
joseph.olstad’s picture

Issue summary: View changes
mfb’s picture

[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

mfb’s picture

Status: Active » Needs review
StatusFileSize
new1.13 KB

Perhaps 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.

mfb’s picture

Issue summary: View changes
mfb’s picture

Issue summary: View changes
joseph.olstad’s picture

@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!

joseph.olstad’s picture

Title: D7 contrib project tests failing with Composer 2 » All of D7 contrib project tests failing (with Composer 2)
mfb’s picture

btw, 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."

Mixologic’s picture

Status: Needs review » Fixed

The 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.

mfb’s picture

Priority: Major » Normal
Status: Fixed » Needs review

Thanks :)

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

joseph.olstad’s picture

Thanks @Mixologic

joseph.olstad’s picture

actually I should also say thanks to @mfb, since it was your genious patch that fixed the glitch.

mfb’s picture

maybe 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.

damienmckenna’s picture

I can confirm that the changes fixed the test failures that Metatag started seeing recently too (#3294781). Thanks everyone!

mfb’s picture

StatusFileSize
new1.13 KB

Here's a follow-up to see if we can get tests passing with Composer 1 again (don't require the command to succeed)

mfb’s picture

StatusFileSize
new1.13 KB

Fixing punctuation in the message

mfb’s picture

@Mixologic could you take a look at #20 - this might fix test runs on Composer 1

joseph.olstad’s picture

Yes please have a look at #20, php 7.2 testing is blocked atm

Mixologic’s picture

Looks 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.

joseph.olstad’s picture

joseph.olstad’s picture

mfb’s picture

Status: Needs review » Fixed

I 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).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.