How to not fail on deprecation warnings

Created on 3 November 2024, about 2 months ago

After a bit of searching I found out how to enable deprecation warnings in CI runs.
However, when I tried it out I discovered that any deprecation warnings during the tests cause the build to fail instead of passing with warnings, as I’d hoped (see the fourth of that MR’s pipelines).

Unfortunately, the documentation only explains how to make it fail on deprecations, which already seems to be the default (unless I have unwittingly made a customization in my module that caused this behavior).
Is there an easy way to make deprecation warnings during PHPUnit test runs just produce CI warnings, not cause the build to fail?

💬 Support request
Status

Active

Component

gitlab-ci

Created by

🇦🇹Austria drunken monkey Vienna, Austria

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

Comments & Activities

  • Issue created by @drunken monkey
  • 🇪🇸Spain fjgarlin

    I believe that the behaviour comes because of this line in the core phpunit.xml.dist: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/phpunit.xml.d...
    failOnWarning="true"

    You'd need to override that value to false for your module somehow.

  • 🇪🇸Spain fjgarlin

    Given that the core's default value is set to fail and that each module can add their own phpunit.xml(.dist) file, I'm closing this as "Work as designed".

  • 🇬🇧United Kingdom jonathan1055

    @drunken monkey If the aim is to see the deprecations but not make your pipeline fail, then an alternative if you don't want your project to have its own phpunit.xml(.dist) as mentioned in #3, is to allow the pipeline job to end with an amber warning not a red failure

    phpunit:
      allow_failure: true
    

    Even with the warning the overall status of the pipeline will be green (providing there are no other red failures).

    The downside of this is that real test failures would also be classed and 'OK' and not make the pipeline fail. So another way would be to leave your 'current' phpunit without showing deprecations, but use OPT_IN_TEST_NEXT_MINOR:1 and show the deprecations there instead. All of the 'next minor' variants are allowed to fail so you do not need to specify that in the job.

Production build 0.71.5 2024