diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml index 1e3e77642ca69417b8dd47fd4ed9e2368e5a0750..f33cd08e43466429431fcdc6951b139343dfd09e 100644 --- a/includes/include.drupalci.main-d7.yml +++ b/includes/include.drupalci.main-d7.yml @@ -385,6 +385,10 @@ phpcs: needs: ['composer'] rules: - *skip-phpcs-rule + - if: $_PHPCS_ALLOW_FAILURE == "1" || ($_ALL_VALIDATE_ALLOW_FAILURE == "1" && $_PHPCS_ALLOW_FAILURE != "0") + allow_failure: true + - if: $_PHPCS_ALLOW_FAILURE == "0" || $_ALL_VALIDATE_ALLOW_FAILURE == "0" + allow_failure: false - when: on_success script: - test -f phpcs.xml.dist || curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml index 024f2f6c7965f8509dc47654eee7d797e060a866..7d5243f333d7d9e8f5ad6ea459d53fedfd4a469b 100644 --- a/includes/include.drupalci.main.yml +++ b/includes/include.drupalci.main.yml @@ -302,12 +302,6 @@ - '**/tests/**/*Test.php' when: on_success -.php-files-exist-rule: &php-files-exist-rule - - exists: - - '*.{$DRUPAL_PHP_FILE_TYPES}' - - '**/*.{$DRUPAL_PHP_FILE_TYPES}' - when: on_success - .nightwatch-tests-exist-rule: &nightwatch-tests-exist-rule - exists: - tests/src/Nightwatch/**/*.js @@ -315,6 +309,20 @@ - tests/modules/*/tests/src/Nightwatch/**/*.js when: on_success +.php-files-exist: &php-files-exist + exists: + - '*.{$DRUPAL_PHP_FILE_TYPES}' + - '**/*.{$DRUPAL_PHP_FILE_TYPES}' + +.ccs-files-exist: &css-files-exist + exists: + - '**/*.css' + +.js-and-yml-files-exist: &js-and-yml-files-exist + exists: + - '**/*.js' + - '**/*.yml' + ################ # Global variables (contrib only). ################ @@ -564,6 +572,10 @@ composer-lint: stage: validate rules: - *skip-composer-lint-rule + - if: $_COMPOSER_LINT_ALLOW_FAILURE == "1" || ($_ALL_VALIDATE_ALLOW_FAILURE == "1" && $_COMPOSER_LINT_ALLOW_FAILURE != "0") + allow_failure: true + - if: $_COMPOSER_LINT_ALLOW_FAILURE == "0" || $_ALL_VALIDATE_ALLOW_FAILURE == "0" + allow_failure: false - when: on_success needs: - composer @@ -602,6 +614,10 @@ phpcs: stage: validate rules: - *skip-phpcs-rule + - if: $_PHPCS_ALLOW_FAILURE == "1" || ($_ALL_VALIDATE_ALLOW_FAILURE == "1" && $_PHPCS_ALLOW_FAILURE != "0") + allow_failure: true + - if: $_PHPCS_ALLOW_FAILURE == "0" || $_ALL_VALIDATE_ALLOW_FAILURE == "0" + allow_failure: false - when: on_success needs: - composer @@ -624,12 +640,22 @@ phpcs: reports: junit: junit.xml +.phpstan-allow-failure-rule: &phpstan-allow-failure-rule + - if: $_PHPSTAN_ALLOW_FAILURE == "1" || ($_ALL_VALIDATE_ALLOW_FAILURE == "1" && $_PHPSTAN_ALLOW_FAILURE != "0") + <<: *php-files-exist + allow_failure: true + - if: $_PHPSTAN_ALLOW_FAILURE == "0" || $_ALL_VALIDATE_ALLOW_FAILURE == "0" + <<: *php-files-exist + allow_failure: false + - <<: *php-files-exist + when: on_success + .phpstan-base: stage: validate rules: - *opt-in-current-rule - *skip-phpstan-rule - - *php-files-exist-rule + - *phpstan-allow-failure-rule needs: - composer script: @@ -693,7 +719,7 @@ phpstan (max PHP version): - *opt-in-max-php-rule - *skip-phpstan-rule - *check-max-php-version-rule - - *php-files-exist-rule + - *phpstan-allow-failure-rule needs: - 'composer (max PHP version)' @@ -702,7 +728,7 @@ phpstan (next minor): rules: - *opt-in-next-minor-rule - *skip-phpstan-rule - - *php-files-exist-rule + - *phpstan-allow-failure-rule needs: - 'composer (next minor)' @@ -711,7 +737,7 @@ phpstan (next major): rules: - *opt-in-next-major-rule - *skip-phpstan-rule - - *php-files-exist-rule + - *phpstan-allow-failure-rule needs: - 'composer (next major)' script: @@ -770,8 +796,13 @@ stylelint: allow_failure: true rules: - *skip-stylelint-rule - - exists: - - '**/*.css' + - if: $_STYLELINT_ALLOW_FAILURE == "1" || ($_ALL_VALIDATE_ALLOW_FAILURE == "1" && $_STYLELINT_ALLOW_FAILURE != "0") + <<: *css-files-exist + allow_failure: true + - if: $_STYLELINT_ALLOW_FAILURE == "0" || $_ALL_VALIDATE_ALLOW_FAILURE == "0" + <<: *css-files-exist + allow_failure: false + - <<: *css-files-exist when: on_success needs: - composer @@ -801,9 +832,13 @@ eslint: stage: validate rules: - *skip-eslint-rule - - exists: - - '**/*.js' - - '**/*.yml' + - if: $_ESLINT_ALLOW_FAILURE == "1" || ($_ALL_VALIDATE_ALLOW_FAILURE == "1" && $_ESLINT_ALLOW_FAILURE != "0") + <<: *js-and-yml-files-exist + allow_failure: true + - if: $_ESLINT_ALLOW_FAILURE == "0" || $_ALL_VALIDATE_ALLOW_FAILURE == "0" + <<: *js-and-yml-files-exist + allow_failure: false + - <<: *js-and-yml-files-exist when: on_success needs: - composer @@ -869,6 +904,10 @@ cspell: stage: validate rules: - *skip-cspell-rule + - if: $_CSPELL_ALLOW_FAILURE == "1" || ($_ALL_VALIDATE_ALLOW_FAILURE == "1" && $_CSPELL_ALLOW_FAILURE != "0") + allow_failure: true + - if: $_CSPELL_ALLOW_FAILURE == "0" || $_ALL_VALIDATE_ALLOW_FAILURE == "0" + allow_failure: false - when: on_success allow_failure: true needs: @@ -1285,6 +1324,13 @@ environment check: - printf "$DIVIDER\n* Out of date reference .amend-core-requirements-drupal-11 is used.\n* To remove this warning, change it to .amend-core-requirements-next-major\n$DIVIDER\n" - *amend-core-requirements-next-major +# This rule is not used any more, but may exist in some customized .gitlab-ci.yml files, therefore it should not be deleted. +.php-files-exist-rule: &php-files-exist-rule + - exists: + - '*.{$DRUPAL_PHP_FILE_TYPES}' + - '**/*.{$DRUPAL_PHP_FILE_TYPES}' + when: on_success + # Check for deprecated variables and display a deprecation messages. .base-deprecation-rules: &base-deprecation-rules - if: $SKIP_COMPOSER != "" || $LENIENT_ALLOW_LIST != "" || $COMPOSER_PATCHES_FILE != "" || ($_TARGET_CORE != "" && ($CI_JOB_NAME == "deprecation - composer" || $CI_JOB_NAME == "deprecation - composer (max PHP version)")) diff --git a/includes/include.drupalci.variables.yml b/includes/include.drupalci.variables.yml index 82c42b1df154ecfbeb854345252a4cb15021b76e..154702ef5be21b00dc0b5d874b1e0702a26c99d2 100644 --- a/includes/include.drupalci.variables.yml +++ b/includes/include.drupalci.variables.yml @@ -92,14 +92,30 @@ variables: value: '32' description: 'Value for the `--concurrency` parameter when running with `_PHPUNIT_CONCURRENT: 1`.' + _ALL_VALIDATE_ALLOW_FAILURE: + value: '' + description: 'Set to 1 to allow the all the validation/linting jobs to fail, set to 0 for not allowing any failure. Individual job variables can override this global settings. Leave blank to use the template defaults.' + + _COMPOSER_LINT_ALLOW_FAILURE: + value: '' + description: 'Set to 1 to allow the Composer-lint job to fail, set to 0 for not allowing failure. Leave blank to use _ALL_VALIDATE_ALLOW_FAILURE' + _PARALLEL_LINT_EXTRA: value: '' description: 'Additional options that are appended to the `parallel-lint` job call.' + _PHPCS_ALLOW_FAILURE: + value: '' + description: 'Set to 1 to allow the PHPCS job to fail, set to 0 for not allowing failure. Leave blank to use _ALL_VALIDATE_ALLOW_FAILURE' + _PHPCS_EXTRA: value: '' description: 'Additional options that are appended to the `phpcs` job call.' + _STYLELINT_ALLOW_FAILURE: + value: '' + description: 'Set to 1 to allow the Stylelint job to fail, set to 0 for not allowing failure. Leave blank to use _ALL_VALIDATE_ALLOW_FAILURE' + _STYLELINT_EXTRA: value: '' description: 'Additional options that are appended to the `stylelint` job call.' @@ -112,6 +128,10 @@ variables: value: '' description: 'Additional options that are appended to the `composer require` call in the `Upgrade status` job.' + _CSPELL_ALLOW_FAILURE: + value: '' + description: 'Set to 1 to allow the CSpell job to fail, set to 0 for not allowing failure. Leave blank to use _ALL_VALIDATE_ALLOW_FAILURE' + _CSPELL_WORDS: value: '' description: 'A comma-separated list of words to add to the CSpell dictionary. For example `mycustomthing, madeupword`. Quotes are not required.' @@ -136,10 +156,18 @@ variables: value: '' description: 'Additional options that are appended to the `CSpell` job call.' + _ESLINT_ALLOW_FAILURE: + value: '' + description: 'Set to 1 to allow the ESLint job to fail, set to 0 for not allowing failure. Leave blank to use _ALL_VALIDATE_ALLOW_FAILURE' + _ESLINT_EXTRA: value: '--quiet' description: 'Additional options that are appended to the `eslint` job call. The default value `--quiet` matches what Drupal core `eslint` job does. You can set it to empty to get warnings or add any additional options that you might need for the `eslint` job.' + _PHPSTAN_ALLOW_FAILURE: + value: '' + description: 'Set to 1 to allow the PHPStan job to fail, set to 0 for not allowing failure. Leave blank to use _ALL_VALIDATE_ALLOW_FAILURE' + _PHPSTAN_LEVEL: value: '' description: 'Specify the PHPStan level to use (0-9). If left blank it will use the `level` value in your phpstan.neon configuration file, or default to 0 if there is no `level` parameter. See https://phpstan.org/user-guide/rule-levels for more information.'