Improve MODULE_NAME calculation

Created on 25 July 2024, about 1 month ago

Problem/Motivation

This is a follow-up issue to #3459888: Job Upgrade Status: Variable MODULE_NAME should be overridable and the drush command should also work for themes . There, the MODULE_NAME variable got improved for the upgrade_status job (see https://git.drupalcode.org/project/gitlab_templates/-/merge_requests/237...). That methodology should be considered to be used in the .create-environment-variables job for general usage.

Before doing that, we need to consider that there are 3 different names that may identify a module/theme/project:

  • GitLab project name from CI_PROJECT_NAME
  • Drupal project name, i.e. the machine name of the module, theme, profile or else. This is the base name of the info.yml file and is required for e.g. drush commands to enable the module or theme ===> This is what we want in MODULE_NAME
  • The directory name, where the project is installed, which can be different if e.g. the composer.json file contains the extra.installer-name property

Maybe we can include MODULE_TYPE in the calculations too. Once we find the info file, it's something like this: export MODULE_TYPE=$(grep "^type:" $MODULE_NAME.info.yml).

If we don't find an info file, we can always use the code that we've had so far as fallback: export MODULE_NAME=${CI_PROJECT_NAME%-*}

We should consider the non-standard case where the info file is _not_ in the root folder. I guess in this case, it will be a best guess among all the info files found (maybe shortest name as submodules tend to be "module_submodule").

📌 Task
Status

Active

Component

gitlab-ci

Created by

🇩🇪Germany jurgenhaas Gottmadingen

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

Comments & Activities

  • Issue created by @jurgenhaas
  • 🇪🇸Spain fjgarlin

    I was making a comment, but decided to update the issue description with the changes that I suggest we do along the way and possible approach.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Thanks for the enhancement. Just a couple of thoughts:

    • Not sure if MODULE_NAME is the appropriate name. It's more a PROJECT_NAME as it can be a module or theme or profile, or other things like recipes in the future.
    • If a module has sub-modules, there is always more than one. This needs more thought on how to handle that. What's for sure that the requirements of jobs using that information will be different. If a job wants to enable those modules, i.e. the main module and all sub-modules, then a space separated list of all the (sub-)module names is required.
    • One could argue that this method should just provide the name of the main module, but then there is that case where a Drupal module has no main module but a few sub-modules.
  • 🇪🇸Spain fjgarlin

    Agree.
    * As MODULE_NAME is not documented and it's only used internally in one (soon to be two) job, we can totally change it to _PROJECT_NAME. As then _PROJECT_TYPE.
    * Yeah. So far we haven't had a situation where we need to enable all the modules or a list of modules. I'd say let's wait until that need is created.
    * Yup, that's what I said in the description about "the best guess". We can make the guess and show it in the job output. I think the best guess is usually the shortest name (ie: https://git.drupalcode.org/project/drupalorg - on the D7 branch)

    We should still allow the option for a module maintainer to define _PROJECT_NAME and then only do the calculations if this is empty (default value). This way, we can easily fix edge cases where the above is not enough.

Production build 0.71.5 2024