繁体   English   中英

Gitlab CI - 测试正常,但作业失败

[英]Gitlab CI - Test are OK but the job fail

我是 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

I want to test my project in php 7.4 and php 8.0 (and if possible testing Symfony 5.4 and 6.0 in php 8.0 buit not sure how to do that for now)

对于 Job(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 时我没有它们)弃用是否会导致作业失败? 如果这是问题所在,我可以让他们沉默吗?

是 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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM