DrupalCI is now codesniffing submitted patches, producing two types of reports, and a patch for any sniffs that can automatically be fixed:
https://dispatcher.drupalci.org/job/drupal_patches/2094/artifact/jenkins...

[02/12/2017 -:- 11:23:15 AM] <alexpott> Mixologic: having the patch there is amazing
[02/12/2017 -:- 11:23:35 AM] <alexpott> Mixologic: once there is a comment in the issue to it - this is game changing for committers
[02/12/2017 -:- 11:23:37 AM] <alexpott> Mixologic++
[02/12/2017 -:- 11:30:32 AM] <Mixologic> alexpott: cool. I can work with drumm to make that happen. should be trivial.
[02/12/2017 -:- 11:25:27 AM] <alexpott> Mixologic: nice the comment should link to the patch and the report
[02/12/2017 -:- 11:37:02 AM] <Mixologic> alexpott: which report, this: https://dispatcher.drupalci.org/job/drupal_patches/2094/artifact/jenkins... or this: https://dispatcher.drupalci.org/job/drupal_patches/2094/checkstyleResult/

So I never got a response from alexpott on that, but basically we have a few options: we can utilize the api to get at the checkstyle data, and have a report formatted exactly how we want it, or we can link directly to the command line output: https://dispatcher.drupalci.org/job/drupal_patches/2094/artifact/jenkins...

The patch is only going to be able to autofix those rules that have an autofixer created for them in coder, so it wont be a be-all end all, but will still be useful.

So not sure what the best design would be here, but we've got some options.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mixologic created an issue. See original summary.

klausi’s picture

Ideally proposed patches should be auto-fixed. If a patch is posted by a user with coding standard problems then the testbot should post a new patch with a comment "There, fixed some coding standard bullshit for you".

That would of course trigger another testrun - not sure how problematic it is that the testbot can trigger itself. It should probably only autofix patches that have not been posted by itself.

Mixologic’s picture

Status: Active » Postponed

So I think the ideal situation for a phpcs comprises the following:

1. a report of all the problems detected in the patch.
2. The submitted patch, with any problems autofixed
3. A patch of *just* the problems that were autofixed (i.e. an interdiff for review)
4. A report of any problems not autofixable - because there could still be problems.

#2. would allow us to not have to reroll patches, and should probably not be autotested, but should still have ad hoc testing buttons available.

We should probably consider what sort of output we would see if there were *more* linting/standards fixers ran (js/css/yaml/twig etc)

Im going to postpone this now until we have that second patch available in drupalci.

drumm’s picture

should probably not be autotested, but should still have ad hoc testing buttons available

Split that part off into #2852640: Allow not-previously-tested files to be tested.

drumm’s picture

drumm’s picture

Status: Postponed » Active

The patches are ready for the taking now.

For branch tests, we should grab a copy of the file locally, and display a simple link to it. We don’t want to increase our reliance on Jenkins as a front-end.

For issue tests, we should either post a new comment as system message with the patch, or edit it into the existing comment next to the tested patch. I’m leaning toward existing comment, so the files don’t get too free-range.

drumm’s picture

We should post the files from each tool (phpcs, eslint, csslint) separately.

Mixologic’s picture

css lint cant make patches fwiw, and I've gotta do some gyrations with eslint to produce a patch

Wim Leers’s picture

We're working on fixing this during Acquia Build Week's hackathon :) Sister issue for DrupalCI: #2881456: Phpcs: automatically generate patch to fix coding standards violations.

csg’s picture

Status: Active » Needs review
FileSize
3.24 KB

This is what I have so far. Feedback is welcome.

Wim Leers’s picture

Status: Needs review » Needs work
+++ b/includes/pift_ci_job.inc
@@ -202,10 +202,20 @@ class PiftCiJob extends Entity {
+            $cs_patch_url = $this->ci_url . '/artifact/jenkins-drupal_patches-' . $this->job_id . '/artifacts/phpcs/codesniffer_fixes.patch';
+            $cs_interdiff = $this->ci_url . '/artifact/jenkins-drupal_patches-' . $this->job_id . '/artifacts/phpcs/codesniffer_autofix.patch';

These should be the other way around. "autofix" is the actual patch, "fixes" is the interdiff.

Also, they're both URLs, so let's make them both have a _url suffix.

csg’s picture

FileSize
3.27 KB

Fixed. Thanks for the review!

drumm’s picture

Do we want these patches to be testable by DrupalCI? From comment #3:

should probably not be autotested, but should still have ad hoc testing buttons available.

This would be done by putting the files in field_issue_files along with user-submitted patches. #2852640: Allow not-previously-tested files to be tested is the issue to make those and other untested patches testable.

Mixologic’s picture

Issue summary: View changes
Mixologic’s picture

Issue summary: View changes
Mixologic’s picture

Issue summary: View changes
Mixologic’s picture

Issue summary: View changes
Mixologic’s picture

Issue summary: View changes
xjm’s picture

@drumm, for the MVP, we wanted the artifacts to just be linked and the issue marked NW with the early fail, so that contributors could find them on issues as soon as possible, since that will have immediate positive impact. Then we envisioned maybe posting and testing them as described a next step, since that has some more detailed requirements for repeated test runs, user expectation/design, etc. Do you think that would be doable? The sooner we help contributors find the artifacts directly on issue, the better, and then we can iterate based on actual contributor experiences. :)

xjm’s picture

Status: Needs work » Needs review

For #12.

xjm’s picture

Just to reiterate, it'd be really valuable to have just the NW comment linking the artifacts at first, so we can start changing our process for core contribution to match that. (Trivial issue credits are causing a lot of angst in the community right now and that angst in turn sucks up committers' time.)

I think once we adapt community process around that MVP, then we can work on and deploy making the reroll a testable attachment, with more scenarios and more complete design, to further reduce the manual steps needed.

Wim Leers’s picture

Oops, yes, I forgot to mark #12 NR again. I have no more comments on this patch.

The text was proposed by @xjm, implemented by @csg.

  • drumm committed 9880c50 on 7.x-3.x authored by csg
    Issue #2851916 by csg, Mixologic, drumm, Wim Leers, xjm: Expose phpcs...
Mile23’s picture

drumm’s picture

Status: Needs review » Fixed

Committed & deployed with a couple changes:

  • Check if each file is present individually. Currently DrupalCI isn’t outputting both files in production. (That’s happening soon it is in dev.) This is implemented as a list of interesting filenames and descriptions, so it is relatively straightforward to change those to keep up with DrupalCI changes.
  • Also check if the patch isn’t empty. Linking to empty files would be frustrating.
  • Since this is a more-generic list of files, update the comment rendering to match.
xjm’s picture

Looks good to me; thanks @drumm! Now to finish things from the CI side...

jonathan1055’s picture

This is great, thanks everyone. It worked nicely on a core coding standards error in #2068063-267: Change "Save and keep un-/published" buttons to a "Published" checkbox and an included "Save" button where a previous passing patch (which was about to be committed) had one cs fault.

Now I am looking forward to seeing this on contrib patches - currently we have no cs checking - #2870645: PHPCS is failing on contrib modules

xjm’s picture

Yay it works!

@jonathan1055, the marking issues NW solely for coding standards is not happening yet; that will be a part of deploying #2881456: Phpcs: automatically generate patch to fix coding standards violations once it is ready.

@drumm, one thing we noticed in testing, that could also have been part of the confusion above, is that the System Message comment does not link the CI result for the test fail, only a link to the comment which is disorienting and can be further confusing when there are multiple patches attached to a comment. Can we use this same mini-list to add a first bullet linking the actual test result? Posted #2883814: Link failing test result in System Message comment for failed patches for this.

jonathan1055’s picture

FileSize
81.71 KB

the marking issues NW solely for coding standards is not happening yet

OK, but here is the comment, with link to the newly generated patch.
codesniffer patch

Maybe the NW was generated by one of the random test fails we have been getting, but we certainly did get the codesniffer patch, with a single fix for coding standards, and when this was included in the patch it passed again - so that part is working nicely.

xjm’s picture

@jonathan1055, yep, it was a random failure that caused it to be mark NW, and that happy coincidence surfaced the coding standards interdiff that's already available with the formatting that's just been deployed. :) That's why I proposed #2883814: Link failing test result in System Message comment for failed patches, so it would point people to the actual fails in the same comment as the coding standards info.

It's great to have part of it working already!

Wim Leers’s picture

YAY! This is a small step, yet a big milestone :)

Status: Fixed » Closed (fixed)

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