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

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

这是一个php单位配置问题 https://phpunit.readthedocs.io/en/9.5/configuration.html

试试这个 在您的项目中创建 php 单元配置文件“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>