edbizarro / gitlab-ci-pipeline-php

:coffee: Docker images for test PHP applications with Gitlab CI (or any other CI platform!)
https://hub.docker.com/r/edbizarro/gitlab-ci-pipeline-php
MIT License
529 stars 167 forks source link

How to use PHP Code Sniffer #42

Closed molerat619 closed 6 years ago

molerat619 commented 6 years ago

Hey there,

thanks for this great package. I was fighting with the .yml files for days and yours just worked.

How can I use PHP Code Sniffer with this? I have the following configuration, but it won't work.

# Variables
variables:
  MYSQL_ROOT_PASSWORD: root
  MYSQL_USER: homestead
  MYSQL_PASSWORD: secret
  MYSQL_DATABASE: homestead
  DB_HOST: mysql

stages:
  - syntax
  - tests

phpcs:
  stage: syntax
  script:
    - ./vendor/bin/phpcs --error-severity=1 --warning-severity=8 --extensions=php

test:
  stage: test
  services:
    - mysql:5.7
  image: edbizarro/gitlab-ci-pipeline-php:7.2-alpine
  script:
    - yarn
    - cp .env.example .env
    - composer install --prefer-dist --no-ansi --no-interaction --no-progress
    - php artisan key:generate
    - php artisan migrate:refresh --seed
    - ./vendor/phpunit/phpunit/phpunit -v --coverage-text --colors=never --stderr

But of course I get /bin/bash: line 69: ./vendor/bin/phpcs: No such file or directory.

edbizarro commented 6 years ago

hi @molerat619

Accordingly to phpcs repo you need to require the package in your dev dependencies

{
    "require-dev": {
        "squizlabs/php_codesniffer": "3.*"
    }
}
molerat619 commented 6 years ago

Yeah that worked fine. Thanks.. sorry it's so simple. I just don't feel comfortable with the whole CI configurations yet.