Define extra rule to jobs that have "needs: composer"
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3414391. -->
Reported by: [jurgenhaas](https://www.drupal.org/user/168924)
Related to !112 !108
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>We have lots of jobs with this property:</p>
<pre> needs:<br> - composer</pre><p>However, if a pipeline runs with the variable <code>SKIP_COMPOSER: '1'</code>, then that job won't run and the jobs in need of that are invalid. An error message will be printed:</p>
<pre> Unable to create pipeline<br><br> 'composer-lint' job needs 'composer' job, but 'composer' is not in any previous stage<br> 'phpcs' job needs 'composer' job, but 'composer' is not in any previous stage<br> 'phpstan' job needs 'composer' job, but 'composer' is not in any previous stage<br> 'eslint' job needs 'composer' job, but 'composer' is not in any previous stage<br> 'phpunit' job needs 'composer' job, but 'composer' is not in any previous stage</pre><h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Add the variable <code>SKIP_COMPOSER: '1'</code> to your gitlab-ci config and commit that. It will immediately show this error.</p>
<h3>Goals to achieve</h3>
<ol>
<li>Allow PHPUNIT and PHSTAN to be run on any set of core version variants and the current version. This includes the scenario of <i>not</i> running at the current version</li>
<li>Independent of the version variants that PHPUNIT and/or PHPSTAN are being run at, allow ESLINT, COMPOSER_LINT, STYLELINT, PHPCS and NIGHTWATCH jobs to be run. These all need the current core version, there are no variants></li>
<li>Allow any job (or sets of job variants) to be skipped. Skipped jobs should not be forced internally to run. "Skip means Skip"
</li></ol>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ol>
<li>Introduce a new variable <code>OPT_IN_TEST_CURRENT</code> with default value 1 (unlike the other OPT_IN variables which default to 0. This will be used to run the correct Composer version, and also the PHPSTAN and PHPUNIT jobs for current core.</li>
<li>Remove/deprecate the <code>SKIP_COMPOSER</code> variable and simply determine which Composer job(s) should be run, depending on the settings of SKIP_ and OPT_IN_</li>
</ol>
issue