Define extra rule to jobs that have "needs: composer"
Problem/Motivation
We have lots of jobs with this property:
needs:
- composer
However, if a pipeline runs with the variable SKIP_COMPOSER: '1', then that job won't run and the jobs in need of that are invalid. An error message will be printed:
Unable to create pipeline
'composer-lint' job needs 'composer' job, but 'composer' is not in any previous stage
'phpcs' job needs 'composer' job, but 'composer' is not in any previous stage
'phpstan' job needs 'composer' job, but 'composer' is not in any previous stage
'eslint' job needs 'composer' job, but 'composer' is not in any previous stage
'phpunit' job needs 'composer' job, but 'composer' is not in any previous stage
Steps to reproduce
Add the variable SKIP_COMPOSER: '1' to your gitlab-ci config and commit that. It will immediately show this error.
Goals to achieve
- Allow PHPUNIT and PHSTAN to be run on any set of core version variants and the current version. This includes the scenario of not running at the current version
- 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>
- Allow any job (or sets of job variants) to be skipped. Skipped jobs should not be forced internally to run. "Skip means Skip"
Proposed resolution
- Introduce a new variable
OPT_IN_TEST_CURRENTwith 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. - Remove/deprecate the
SKIP_COMPOSERvariable and simply determine which Composer job(s) should be run, depending on the settings of SKIP_ and OPT_IN_