Page MenuHomePhabricator

Craft a Jenkins job that runs PHP_CodeSniffer for mw/core using composer
Closed, ResolvedPublic

Description

We could use a Jenkins job that runs PHP_CodeSniffer for the mediawiki/core master branch and make it voting.

phpcs is quite slow and goes beyond the composer 300 seconds timeout. We also need to raise the PHP memory limit which phpcs supports (phpcs -d option which conflicts with composer -d option). In the end the command should be:

time COMPOSER_PROCESS_TIMEOUT=600 PHPCS_ARGS="-v -d memory_limit=1G" composer phpcs .

timeout / memory limit subject to change.

Event Timeline

hashar raised the priority of this task from to Needs Triage.
hashar updated the task description. (Show Details)
hashar added subscribers: hashar, polybuildr.

I think going through composer is going to be unnecessary overhead and make it more complicated. We can just call "vendor/bin/phpcs" directly..

Another thing to look into is having a job that only runs it against the files changed in the patchset for the "test" pipeline, and have the gate pipeline actually run the full phpcs.

Is there a reason to run it against the entire codebase at all? Wouldn't just running it against changed files suffice? (Once everything actually passes, that is.)

Also, @Legoktm, shouldn't T102609 block this, instead of the other way around?

hashar set Security to None.

I took a stab at this today by creating a job that runs vendor/bin/phpcs -v --extensions=php,php5,inc,sample . except it doesn't work :(

https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs/4/console

For some reason it's using the default PEAR sniffs instead of our phpcs.xml...

IIRC, it uses our phpcs.xml only if we don't specify any files to check. Try doing the same thing without specifying the . at the end.

Change 241071 had a related patch set uploaded (by Legoktm):
Replace mediawiki-core-phpcs-HEAD with mediawiki-core-phpcs

https://gerrit.wikimedia.org/r/241071

Change 241071 merged by jenkins-bot:
Replace mediawiki-core-phpcs-HEAD with mediawiki-core-phpcs

https://gerrit.wikimedia.org/r/241071

Legoktm claimed this task.

Patches:

I didn't bother trying to create a job that only runs on changed files because right now the job takes 2-3 minutes, which is fast enough.

I didn't bother trying to create a job that only runs on changed files because right now the job takes 2-3 minutes, which is fast enough.

The average is currently around 3 minutes, but if it has to also clone MW core, it can hit 6 or 7 minutes.

Chart: https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs/buildTimeTrend