Problem/Motivation

Currently, if a patch fails or doesn't validate or is malformed in some way, the Patch plugin swallows the error and returns 0.

This signals the build that it can continue along.

Proposed resolution

  • Create a PatchFactory service so we can inject mock patch workers for testing.
  • Have the catch block in run() re-throw the exception after it creates a report.
  • Adjust all the other code that is thrown off by this changed behavior.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Mile23 created an issue. See original summary.

  • Mile23 committed ae0e961 on 2843562-fix-patch
    Issue #2843562 by Mile23: Patch plugin doesn't signal an application...
Mile23’s picture

Status: Active » Needs review

Mostly done here...

Added vfsStream as a dev dependency so we can unit test the Patch plugin.

Added a patch_factory service so we can unit test Patch plugin.

Mostly this amounts to moving the try/catch around in Patch::run(), and improving the signatures of some functions so we can unit test with interfaces.

Todo: Add @covers stuff to the test, whatever you add to the list below.

  • Mile23 committed 0c2f1bf on 2843562-fix-patch
    Issue #2843562: Cleanup.
    
Mixologic’s picture

The patchfactory addition and all the other bits is great, the problem, however, is that the patch returning 0 right now is deliberately broken:

-        //throw $e;
-        return 0;
+        throw $e;

This is because right now if jenkins sees any return code other than 0 from drupal ci, it marks the build as FAILED - which in turn gets converted into a "CI Error" by d.o. when it retrieves the results via the API. So to fix *that*, we need to make sure that our buildstate.json actually has something worth telling drupal.org about in it. i.e. if a patch fails, we can/should be putting the exception message into buildstate.json. Once that file has something d.o. can rely on, it wont have to report "CI Error" when it sees a FAILED. Ic an simply report whatever it sees in that file (which is either structured, or *just* has the "short statement that fills the red pill on d.o. testing results"

Since we launched drupalci improved, we have the following error messages in buildstate.json:

4 "Ancillary require failure.  Error Code: 2"
2670 "Build Successful"
  94 "Composer require failure.  Error Code: 2"
  13 "Composer require failure.  Error Code: 255"
   1 "PHPLint Failed: \n\nEXECUTING: cd \/var\/www\/html && xargs -P 31 -a \/var\/lib\/drupalci\/artifacts\/lintable_files.txt -I {} php -l '{}'\n\nPHP Parse error:  syntax error, unexpected '$this' (T_VARIABLE) in \/var\/www\/html\/core\/modules\/views\/tests\/src\/FunctionalJavascript\/ExposedFilterAJAXTest.php on line 118\nxargs: php: exited with status 255; aborting\n"
   2 "PHPLint Failed: \n\nEXECUTING: cd \/var\/www\/html && xargs -P 31 -a \/var\/lib\/drupalci\/artifacts\/lintable_files.txt -I {} php -l '{}'\n\nPHP Parse error:  syntax error, unexpected ')' in \/var\/www\/html\/core\/modules\/block_content\/src\/Tests\/BlockContentListViewsTest.php on line 106\nxargs: php: exited with status 255; aborting\n"
  10 "PHPLint Failed: \n\nEXECUTING: cd \/var\/www\/html && xargs -P 31 -a \/var\/lib\/drupalci\/artifacts\/lintable_files.txt -I {} php -l '{}'\n\nPHP Parse error:  syntax error, unexpected ')' in \/var\/www\/html\/modules\/contrib\/panels\/src\/Plugin\/DisplayBuilder\/StandardDisplayBuilder.php on line 69\nxargs: php: exited with status 255; aborting\n"
   1 "PHPLint Failed: \n\nEXECUTING: cd \/var\/www\/html && xargs -P 31 -a \/var\/lib\/drupalci\/artifacts\/lintable_files.txt -I {} php -l '{}'\n\nPHP Parse error:  syntax error, unexpected '[' in \/var\/www\/html\/sites\/all\/modules\/examples\/dbtng_example\/dbtng_example.module on line 634\nxargs: php: exited with status 255; aborting\n"
   1 "PHPLint Failed: \n\nEXECUTING: cd \/var\/www\/html && xargs -P 31 -a \/var\/lib\/drupalci\/artifacts\/lintable_files.txt -I {} php -l '{}'\n\nPHP Parse error:  syntax error, unexpected '}' in \/var\/www\/html\/modules\/webform\/src\/WebformElementBase.php on line 1426\nxargs: php: exited with status 255; aborting\n"

So I see a couple things wrong there. We're saying too much in the Lint Exceptions, the Error codes from composer dont tell us anything, and the ancillary require failures are like , uh, what?.

Also, patch fails arent showing up there at all.. Even from before the time when it was throwing exceptions, so I think the exception message got swallowed on the first catch, and the second throw didnt say much. Its almost as if catching and rethrowing drained it of its exception message somehow.

So, step one is Fix what ends up in buildstate.json (and yeah, name to buildoutcome.json or buildresult.json. the state isnt going to change once its over.).
Step two is massage d.o's project issue file test to care about buildresult.json when it sees FAILURE at jenkinsland.
Step three, then would be to make patch properly throw an exception, and remove any notion that it needs to spew out some xml in order to trick jenkins into making an UNSTABLE build with one failed test.

Finally we can then add some other exception situations on our side like look for missing @group, look for 'No tests found', and set the buildstate accordingly. (essentially anything that yields a CI error now).

We pretty much want to get to a world where CI error only ever happens when something totally craps the bed, like we push a broken drupacl branch to production or something.

Mile23’s picture

OK. How about this? #2843592: [plan] Normalize on signal and error reporting

Basically postponing on this issue until that's more settled.

  • Mixologic committed 335d25e on 2843562-fix-patch
    Issue #2843562: resolves merge conflicts with dev
    
  • Mixologic committed b6281db on 2843562-fix-patch
    Issue #2843562: Adjusts for current workflow
    

  • Mixologic committed 3894dcb on 2843562-fix-patch
    Issue #2843562: Updates test to proper postponement
    
Mixologic’s picture

Assigned: Unassigned » Mixologic

We have liftoff. Drupal.org is now properly introspecting buildoutcome.json.

We can now do proper signaling throughout the application, and that the patch plugin no longer needs to fake an xml test result.

  • Mile23 committed 0c2f1bf on 2843562-fix-patch-part-deux
    Issue #2843562: Cleanup.
    
  • Mixologic committed 335d25e on 2843562-fix-patch-part-deux
    Issue #2843562: resolves merge conflicts with dev
    
  • Mixologic committed 3894dcb on 2843562-fix-patch-part-deux
    Issue #2843562: Updates test to proper postponement
    
  • Mile23 committed ae0e961 on 2843562-fix-patch-part-deux
    Issue #2843562 by Mile23: Patch plugin doesn't signal an application...
  • Mixologic committed b6281db on 2843562-fix-patch-part-deux
    Issue #2843562: Adjusts for current workflow
    
  • Mixologic committed 3609910 on 2843562-fix-patch-part-deux
    Issue #2843562: Patches now fail the way everything else does
    
Mixologic’s picture

Status: Needs review » Fixed

howdy. This is now deployed, and patches fail the build properly. Yay.

Status: Fixed » Closed (fixed)

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