Problem/Motivation

#2870194: Ensure that process-isolated tests can use Symfony's PHPunit bridge to catch usages of deprecated code surfaced a lot of technical debt in core. By default, deprecation errors cause test failures.

Conversations in #2607260: [meta] Core deprecation message introduction, contrib testing etc. lead us to understand that we need to hide some of this technical debt (in the form of test failures) from contrib.

Proposed resolution

Have the testbot run run-tests.sh with --suppress-deprecations for contrib projects, but not for core.

Remaining tasks

Figure out a more sustainable solution to deprecation error contrib workflows.

Potentially allow individual projects to maintain their own build file so they can have granular control over deprecations. #2901677: Allow projects to contain their own drupalci.yml file

User interface changes

API changes

Data model changes

Comments

Mile23 created an issue. See original summary.

  • Mile23 committed 8d94586 on 2926314-contrib-should-suppress-deprecations
    Issue #2926314: Contrib should run with --suppress-deprecations
    
mile23’s picture

Status: Active » Needs review

Added branch 2926314-contrib-should-suppress-deprecations

This refactors building the run-tests.sh command into its own method, so that we can unit test it. And then adds a unit test.

It figures out whether we're on core or contrib based on $this->configuration['extension_test'] == TRUE; and then also figures out whether we're on core 8.5.x based on DCI_CoreBranch.

In order to figure out the branch version, it uses composer/semver, which is now an explicit dependency. I also bumped up the composer/composer requirement so we're not stuck at 1.3.0-dev.

Minor CS changes in the Simpletest plugin.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

I've had a look at the code and it seems sane. Given we have the flag $this->configuration['extension_test'] already and the patch copes with the fact that --suppress-deprecations is only available on 8.5.x in a good way (ie. using the semver dependency) +1 to the approach.

mile23’s picture

Status: Reviewed & tested by the community » Needs work

Thanks.

I was thinking about this today and it needs to more formally add the --suppress-deprecations flag as an environmental variable similar to the others, and only apply it if the core branch is ^8.5.

  • Mile23 committed e60dd3e on 2926314-contrib-should-suppress-deprecations
    Issue #2926314: Added DCI_RTSuppressDeprecations
    
mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new12.89 KB

Added DCI_RTSuppressDeprecations, and getRunTestsFlagValues() is now responsible for figuring out if core is ^8.5.

Since the commits are hard to read in order, there's a patch attached, diff against dev.

alexpott’s picture

StatusFileSize
new4.77 KB
new18.08 KB

I think it is worthwhile expanding the test coverage because the code is not quite as straightforward as before. Something like this:

diff --git a/tests/DrupalCI/Tests/Plugin/BuildTask/BuildStep/Testing/SimpletestTest.php b/tests/DrupalCI/Tests/Plugin/BuildTask/BuildStep/Testing/SimpletestTest.php
index 37a081a9..23bad150 100644
--- a/tests/DrupalCI/Tests/Plugin/BuildTask/BuildStep/Testing/SimpletestTest.php
+++ b/tests/DrupalCI/Tests/Plugin/BuildTask/BuildStep/Testing/SimpletestTest.php
@@ -17,7 +17,15 @@ class SimpletestTest extends DrupalCITestCase {
     return [
       'core' => [
         'cd exec-container-source-dir && sudo -u www-data php exec-container-source-dir/core/scripts/run-tests.sh --color --keep-results --values=value --all',
-        [],
+        ['core_branch' => '8.5.x'],
+      ],
+      'core-8.5.x-suppress-deprecations' => [
+        'cd exec-container-source-dir && sudo -u www-data php exec-container-source-dir/core/scripts/run-tests.sh --color --keep-results --suppress-deprecations --values=value --all',
+        ['core_branch' => '8.5.x', 'suppress-deprecations' => TRUE],
+      ],
+      'core-8.4.x-suppress-deprecations-flag' => [
+        'cd exec-container-source-dir && sudo -u www-data php exec-container-source-dir/core/scripts/run-tests.sh --color --keep-results --values=value --all',
+        ['core_branch' => '8.4.x', 'suppress-deprecations' => TRUE],
       ],
       'contrib-default' => [
         'cd exec-container-source-dir && sudo -u www-data php exec-container-source-dir/core/scripts/run-tests.sh --color --keep-results --values=value --directory true-extension-subdirectory',

Because the core_branch flag is always set and the code now supports a suppress-deprecations flag (at least for core).

+++ b/src/DrupalCI/Plugin/BuildTask/BuildStep/Testing/Simpletest.php
@@ -141,12 +135,42 @@ class Simpletest extends BuildTaskBase implements BuildStepInterface, BuildTaskI
+    if ($is_extension_test) {
+      // Always add --suppress-deprecations for contrib. getRunTestsFlagValues()
+      // will determine whether to add it based on core version.
+      // @todo Turn this off when some other solution is decided in
+      //   https://www.drupal.org/project/drupal/issues/2607260
+      $this->configuration['suppress-deprecations'] = TRUE;
+    }

I think here we should trust the flag if it is set.

Patch attached does the two things mentioned in this review.

mile23’s picture

+++ b/src/DrupalCI/Plugin/BuildTask/BuildStep/Testing/Simpletest.php
@@ -204,7 +205,8 @@ class Simpletest extends BuildTaskBase implements BuildStepInterface, BuildTaskI
-      'suppress-deprecations' => FALSE,
+      // NULL means that this has not been configured.
+      'suppress-deprecations' => NULL,

The policy with testbot plugins is that default config values should support core. So moving forward we want suppress-deprecations to be FALSE unless we hear otherwise from the environmental variable.

If the plan is to tell contrib builds to ignore the deprecation errors by sending DCI_RTSuppressDeprecations from D.O, then we want to honor it. But I don't see an issue about it.

alexpott’s picture

@Mile23 re #9 that's exactly the way it works. It allows a flag to overrule instead of always setting based on $is_extension_test so when we do allow contrib maintainers to configure this via the UI it just works without any code change.

mile23’s picture

Status: Needs review » Postponed

Talked with @mixologic about this in slack.

Basically we don't want to care about core versions in the testbot.

Since the phpunit-bridge is in both 8.4.x and 8.5.x, there should be a backport of --suppress-deprecations to 8.4.x before we can add it as an argument to the simpletest plugin here.

@Mixologic will add a band-aid fix at the Jenkins level to turn off deprecation fails for contrib, using SYMFONY_DEPRECATIONS_HELPER=disabled, and that will be the temporary fix we should try to replace with something more sustainable.

So this issue is now postponed on #2927636: Backport --supress-deprecations to run-tests.sh 8.4.x

And other sustainable CI strategies should be discussed in #2607260: [meta] Core deprecation message introduction, contrib testing etc.

Woot.

samuel.mortenson’s picture

@mile23 Is there an issue to track for the "band-aid" fix? I'm seeing a module I just published have test failures for deprecation notices in its dependencies (https://www.drupal.org/pift-ci-job/827146). Thanks for working on this!

samuel.mortenson’s picture

I don't usually re-ping issues but this seems pretty bad - modules I contribute to have failing branch tests and issues cannot get out of Needs Work, which makes review difficult.

mile23’s picture

Status: Postponed » Needs work

#2927636: Backport --supress-deprecations to run-tests.sh 8.4.x is in, so this needs work. It should remove the version checking part of the simpletest plugin and leave support for --suppress-deprecations which is now in both 8.4.x and 8.5.x.

I believe the plan is also to add the suppression flag at the Jenkins level, so we should also remove logic about whether or not we're dealing with contrib.

Mixologic’s picture

Assigned: Unassigned » Mixologic

I did a bunch of work on this yesterday, I'll be able to deploy soon.

  • Mile23 committed fcd2cce on 2926314-contrib-should-suppress-deprecations
    Issue #2926314: Removed core/contrib/semver stuff, should just pass...

  • Mile23 committed a2c9944 on 2926314-contrib-should-suppress-deprecations
    Issue #2926314: Remaining semver stuff gone
    
Mixologic’s picture

Assigned: Mixologic » Unassigned
Status: Needs work » Fixed

Okay, finally got this massaged into a state where we dont have to do any version dependent twiddling. It just does a basic grep for suppress to gather whether or not the capability exists.

Contrib tests should now be run without failing due to using deprecations.

Mixologic’s picture

This is an example of one that had a deprecation warning that no longer does.

https://www.drupal.org/pift-ci-job/836319

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.