Problem/Motivation

If a module has a (manually created) composer.json in its repository (for example to use .tugboat) then the module dependencies from submodules are completely ignored and tests fail with message:

Unable to install modules cookies, etracker, cookies_etracker, test_page_test, block, js_deprecation_log_test, css_disable_transitions_test due to missing modules cookies.

eventhough the dependencies are present in the submodule .info.yml file:

dependencies:
  - cookies:cookies
  - etracker:etracker

The case for example occured in https://www.drupal.org/project/etracker module with the cookies_etracker submodule.

I found a workaround here: https://github.com/acquia/coding-standards-php/issues/6
and implemented the following workaround:
https://git.drupalcode.org/project/etracker/-/merge_requests/24/diffs?co...
Now the test is executed as expected:
https://www.drupal.org/pift-ci-job/2241319 (The now failing 2 tests are expected due to a current bug in cookies schema!)

Update: Workaround doesn't work!

Another workaround I tried was to add

test_dependencies:
  - cookies:cookies

in the etracker.info.yml file in the parent module, but that didn't change things as it's not relevant to the composer.yml used by the testbot.

Also you can very handy compare the situation to the Userlike module: https://www.drupal.org/project/userlike which is a clone of etracker for a different service and with cookies_userlike submodule. It does NOT have a custom composer.json file and therefor everything works fine and the testbot downloads and enables the submodule dependencies correctly!

Steps to reproduce

  1. Create a module and a submodule within with Functional tests.
  2. Let the submodule depend (dependencies in .info.yml) on a different contrib module which has to be downloaded by the testbot. Add all dependencies to the $modules array in the FunctionalTest.
  3. Run test and see in the console that all dependencies from the main module and submodule are downloaded correctly. => WORKS AS EXPECTED!
  4. Add a custom composer.json to the parent module, of course NOT containing the submodule dependencies, as you wouldn't want them!
  5. Run test and see in the console that all dependencies from the main module composer.json are downloaded correctly. But the submodules dependencies are missing completely and all submodule tests fail! => BROKEN!

Important update:
See my comment #7 below and examples in #3249459: Failing issue fork tests in submodule due to infrastructure issue with composer this problem does only seem to exist in issue forks, not for the project main tests!

Proposed resolution

Eventhough a composer.json exists in a module, dependencies from the submodules have to be considered and fulfilled for the test runs like composer.json wasn't existing.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Anybody created an issue. See original summary.

Anybody’s picture

Sadly my workaround with the composer.json in the submodule doesn't work! I had forgotten to remove the dependency from the main module I added for testing before.

So the only workaround I currently see is to completely remove the composer.json from the main module... :(

Anybody’s picture

Anybody’s picture

Any chance for feedback here? This affects us in several modules with submodules, can someone confirm the issue or tell me, what we're doing wrong?

Anybody’s picture

Project: DrupalCI: Test Runner » DrupalCI: Drupal.org Testing Infrastructure
Component: Testrunner Codebase » Code

Moving this to "DrupalCI: Drupal.org Testing Infrastructure" project, hope to get some feedback there as the issue is blocking submodule tests to work correctly. If the issue is wrong there, please move it to the right place and excuse me.

Anybody’s picture

Issue summary: View changes
Anybody’s picture

Issue summary: View changes

This is crazy... as we just saw in #3249459: Failing issue fork tests in submodule due to infrastructure issue with composer the tests are green for the project (at https://www.drupal.org/node/475370/qa run with the same code) but fail in a fresh issue fork!

Anybody’s picture

Issue summary: View changes
Anybody’s picture

Title: Submodule dependencies are ignored if composer.json present in parent module (in Test runs) » Submodule dependencies are ignored if composer.json present in parent module (only in issue fork test runs!)

Changed the title accordingly, I'm still confused, such a crazy thing... :D

Anybody’s picture

Priority: Normal » Major

Here's another example from a different (sub)module:
https://www.drupal.org/project/cookies/issues/3294968#comment-14640535

So I'll set the priority to Major as any module with submodules and other contrib dependencies is potentially affected by this bug.

Grevil’s picture

This problem just appeared again in #3323038: Submoduletests in issues broken without a change:

Undefined array key "facebook_pixel"

The testing suite inside the issue fork doesn't require the submodule's required module "drupal/facebook_pixel" and therefore can not install it.

Anybody’s picture

Priority: Major » Normal
Status: Active » Closed (works as designed)

@MegaChriz found the solution: Use require-dev in composer to make things work!

See #3323038: Submoduletests in issues broken without a change or this commit for the appropriate change. So this can finally be closed! Thank you so much @MegaChriz! :)