Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comments
Comment #3
Mile23Mostly 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.
Comment #5
MixologicThe patchfactory addition and all the other bits is great, the problem, however, is that the patch returning 0 right now is deliberately broken:
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:
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.
Comment #6
Mile23OK. How about this? #2843592: [plan] Normalize on signal and error reporting
Basically postponing on this issue until that's more settled.
Comment #9
MixologicWe 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.
Comment #11
Mixologichowdy. This is now deployed, and patches fail the build properly. Yay.