在gitlab ci作曲家上测试php
问题描述:
我试着用我的小php代码做一些基本的静态分析。 我想用: phploc phpcpd phpcs在gitlab ci作曲家上测试php
我的项目文件夹结构如下:
.
|-- ci
| `-- docker_install.sh
|-- css
| `-- css.css
|-- index.php
|-- js
| |-- icons.json
| `-- script.js
`-- process.php
我创建shell脚本docker_install.sh用下面的代码:
# 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 https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
和我的构建文件:
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
,出现以下错误的构建文件:
....
$ 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
我的问题: 如何加强这方面的,以及如何工作的?
谢谢!
答
你已经安装了作曲家,但你永远不会运行composer install
。只需将其添加到docker_install.sh文件的末尾即可。
感谢@Jakub卡尼亚,但现在它失败,以下错误: ... + MV composer.phar在/ usr/local/bin目录/作曲家 +作曲家安装 不要运行作曲家根/超级用户!有关详细信息,请参见https://getcomposer.org/root 作曲家在/ builds/test中找不到composer.json文件 要初始化项目,请创建一个composer.json文件,如https:// getcomposer中所述。 org /“入门”部分 错误:生成失败:退出代码1 – Zatla00