[D7] Composer 1 only needed if _D7_DRUPAL_COMPOSER_NEEDED is true

Migrated issue

Reported by: fjgarlin

Related to !98 (merged)

Problem/Motivation

The composer step uses composer 1. This was due to "drupal/composer" package, but bringing this package is now behind a variable, so we might be able to speed up other runs if we only switch to composer 1 when _D7_DRUPAL_COMPOSER_NEEDED is set to 1, otherwise default to composer 2.

Steps to reproduce

Run any D7 contrib pipeline

Proposed resolution

Put the comkposer self-update --1 behind a conditional checking _D7_DRUPAL_COMPOSER_NEEDED is 1.

7.x modules used here for gitlab_templates MR testing

packages.drupal.org (aka project_composer)

This has _TARGET_PHP: "5.6" so already using Composer 1 from the start
_D7_DRUPAL_COMPOSER_NEEDED is not specified so takes the default value 0
MR12 project_composer!12

API 7.x-2.x

Has _TARGET_PHP: "5.6" so already has Composer 1 at the start
Has _D7_DRUPAL_COMPOSER_NEEDED: "1"
MR22 api!22

Scheduler 7.x-1.x

No value of _TARGET_PHP so defaults to latest, and hence starts off with Composer 2
Has _D7_DRUPAL_COMPOSER_NEEDED: "1"
MR99 scheduler!99 (closed)

i18n module

This has completely un-customised .gitlab-ci.yml template, therefore uses Composer 2 and does not require _D7_DRUPAL_COMPOSER_NEEDED
MR6 i18n!6

The above four MRs can remain open for future testing.

Related issue: Issue #3408456

Edited by drupalbot