我是Gitlab CI的新手(一般也是CI )。
单元测试通过,但gitlab作业失败
这是我的.gitlab-ci.yml
test:php-7.4:
image: php:7.4
before_script:
- bash ci/docker_install.sh > /dev/null
# Install composer dependencies
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- php composer.phar install
script:
- phpunit
- exit 0
test:php-8.0:
image: php:8.0
before_script:
- bash ci/docker_install.sh > /dev/null
# Install composer dependencies
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- php composer.phar install
script:
- phpunit
- exit 0我想用php 7.4和php 8.0测试我的项目(如果可能的话,在php 8.0中测试Symfony 5.4和6.0,但目前还不确定如何做到这一点)
对于作业(7.4和8.0),我在日志的最后一行中有这样的内容
$ phpunit
PHPUnit 9.5.13 by Sebastian Bergmann and contributors.
Testing
..... 5 / 5 (100%)
Time: 00:00.065, Memory: 24.00 MB
OK (5 tests, 16 assertions)
Other deprecation notices (2)
1x: The "PHPUnit\DeepCopy\TypeFilter\Spl\SplDoublyLinkedListFilter" class is considered final. It may change without further notice as of its next major version. You should not extend it from "PHPUnit\DeepCopy\TypeFilter\Spl\SplDoublyLinkedList".
1x in EtshyGitlabApiExtensionTest::testCreateClientsWithDefault from Etshy\Gitlabapibundle\Test\DependencyInjection
1x: Method "Iterator::current()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "PHPUnit\PharIo\Manifest\ElementCollection" now to avoid errors or add an explicit @return annotation to suppress this message.
1x in EtshyGitlabApiExtensionTest::testCreateClientsWithDefault from Etshy\Gitlabapibundle\Test\DependencyInjection
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1这两种反对意见似乎都不是我的代码造成的,所以我不知道如何修复它们(当我从PHPStorm启动phpunit时,我也没有它们),这些不推荐都会导致作业失败吗?如果这是问题所在,我能让他们闭嘴吗?
发布于 2022-02-01 07:47:00
这是一个php单元配置问题https://phpunit.readthedocs.io/en/9.5/configuration.html
尝试在项目phpunit配置文件"phpunit.xml“中创建以下内容
<PHP>
<ini name="error_reporting" value="-1" />
<env name="KERNEL_CLASS" value="App\Kernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
</php>或
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd">
<php>
<server name="KERNEL_CLASS" value="App\Kernel"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="/foobar/"/>
</php>
</phpunit>https://stackoverflow.com/questions/70934441
复制相似问题