dimanche 26 février 2017

php testing on gitlab ci composer

I'm tryning to do some basic static analysis with my little php code. I want to use: phploc phpcpd phpcs

my project folder structure is as follows:

    .
    |-- ci
    |   `-- docker_install.sh
    |-- css
    |   `-- css.css
    |-- index.php
    |-- js
    |   |-- icons.json
    |   `-- script.js
    `-- process.php

I created shell script docker_install.sh with the following code:

# Install git (the php image doesn't have it) and other tools
apt-get update -yqq
apt-get install git phploc phpcpd phpmd php-pear -yqq

#install composer
curl -s http://ift.tt/SI3ujS | php
mv composer.phar /usr/local/bin/composer  

and my build file:

  image: php:7.0
  before_script:
    #insatll needed packeges
    - bash ci/docker_install.sh > /dev/null
  test:app:
    script:
      #Static analysis
      - phploc .
      #phpmd check coding style
      - phpmd . text naming
      #checking Coding Standards with PHP Code Sniffer
      - phpcpd .
      #Viewing Coding Standards Violations
      - phpcs --standard=PEAR --report=summaryy

The build file with the following error:

  ....
  $ phpcpd .

  Warning: require_once(Symfony/Component/ClassLoader/ClassLoader.php): failed to open stream: No such file or directory in /usr/share/php/SebastianBergmann/PHPCPD/autoload.php on line 2

  Fatal error: require_once(): Failed opening required 'Symfony/Component/ClassLoader/ClassLoader.php' (include_path='.:/usr/local/lib/php') in /usr/share/php/SebastianBergmann/PHPCPD/autoload.php on line 2
  ERROR: Build failed: exit code 1

My questions: How to enhance this, and how to make it works ?

Thanks !

Aucun commentaire:

Enregistrer un commentaire