Install contrib module dependencies specified in info.yml file (when no composer.json file exists)

Created on 3 November 2023, about 1 year ago
Updated 3 September 2024, 4 months ago

Problem/Motivation

The GitLab CI template currently does not install contrib module dependencies specified in .info.yml file if the composer.json file is not present.
This may affect phpstan and phpunit steps causing failures.

The composer.json file is currently not mandatory for contrib modules and is automatically generated for modules releases on Drupal.org. Many maintainers relies on this behavior to avoid maintaining the separate composer.json file.

As a workaround, the module maintainer may either add a composer.json file or add a section to their .gitlab-ci.yml file to manually install dependencies in composer/after_script, e.g.:

composer:
  after_script:
    - composer require 'drupal/other_custom_module'

However, it would be great if this would be handled automatically.

Steps to reproduce

1. Run a pipeline for a contrib module having dependency on another contrib module.
2. Check the composer job log.
Expected: there are log records about dependencies being installed.
Actual: dependencies from .info.yml file aren't installed.

Proposed resolution

Update the template to handle automatic installation of contrib module dependencies.

✨ Feature request
Status

Closed: won't fix

Component

gitlab-ci

Created by

πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

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

Comments & Activities

  • Issue created by @abramm
  • πŸ‡ͺπŸ‡ΈSpain fjgarlin

    Shouldn't module dependencies be defined in the "require" section of the "composer.json" file within the module?

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I'd expect them to be in require-dev.

  • πŸ‡ͺπŸ‡ΈSpain fjgarlin

    Test dependencies should be in the require-dev section.
    Module dependencies should be in the require section.

    The composer step just builds the code according to what it says in the composer.json file.

  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

    I meant the explicit module dependency, i.e. something required for module to run.

    That dependency would be included in require section of composer.json file generated for module release; however, if the module does not include the file (which is ok, contrib modules currently doesn't require to have it), it won't be generated during CI run (which runs on a git ref) and thus the dependency won't be installed.

    Probably the CI should generate the composer.json if it's not included in module repository.

  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

    Updated issue summary to clearly state that this issue is happening if there's no composer.json file committed in a module repository.

  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    #6: Ahhh, now that makes more sense!

    You're right that the Drupal.org composer facade has been generating composer.json for years. You've only needed to define one if and only if your depending on non drupal/* packages. (Also see @mixologic's comment at https://www.drupal.org/drupalorg/blog/drupalorgs-composer-endpoints-are-... β†’ β€” it's the 4th comment.)

    Relevant issue: #2551703: Store composer.json if present β†’ .

    I think it makes sense that with the switch from DrupalCI to GitLab CI, we start requiring composer.json instead of providing dark magic to have it happen automatically. And in fact … that would very much pave the path for ✨ Replace .info.yml with composer.json for extensions Postponed (which is postponed on #3250765: [meta] Clean up .info.yml files β†’ ).

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • Status changed to Closed: won't fix about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States moshe weitzman Boston, MA

    Agree with #8. This is Wont Fix or By Design.

  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

    I don't think it's a good idea to require having module dependencies defined in both composer.json and info.yml. I have seen enough times that people updated a version constraint in one file but not the other, leading to confusing situations. As long as having module dependencies in info.yml is required, we shouldn't also make it required in composer.json, to make sure contrib modules maintain a single source of truth for their dependencies. And if we do decide to make both required, this should probably be communicated in a change record or in some form of documentation, instead of being hidden in some comment in a core issue.

Production build 0.71.5 2024