How
- Enable
Builds
in your GitLab project by going to theEdit Project
page - Setup a GitLab CI Runner using docker image
php
(I use https://githost.io for this, which is ran by GitLab) - Add the files below to the root of your repo
composer install
- Change the included directories in
phpcs.xml
- Add/commit all new files
- Push, and watch the magic happen in the new
Pipelines
area of your GitLab project
Files
.gitlab-ci.yml
before_script:
- apt-get update && apt-get install -y git
- php bin/composer.phar install --dev --prefer-dist
stages:
- syntax
phpcs:
stage: syntax
script:
- ./vendor/bin/phpcs --error-severity=1 --warning-severity=8 --extensions=php
phpcs.xml
<?xml version="1.0"?>
<ruleset name="ASH2">
<description>The ASH2 coding standard.</description>
<rule ref="PSR2"/>
<file>codebase/src/</file>
<file>codebase/tests/</file>
<file>codebase/api/</file>
<exclude-pattern>vendor</exclude-pattern>
</ruleset>
composer.json
{
"require": {
"squizlabs/php_codesniffer": "~2.7"
}
}
Final thoughts
This would be much faster if we didn't have to install git for composer usage - either by having composer not use git, or by using a different docker image.