PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 12, 2022

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

 March 12, 2022     gitlab, gitlab-ci, php, phpunit, symfony     No comments   

Issue

I'm new to Gitlab CI (and CI in general)

The Unit test pass but the gitlab Job fails

Here is my .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)

For both Job (7.4 and 8.0) I have this in the last lines of the log

$ 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

Both the deprecation doesn't seem to come from my code so I don't know how I can fix them (and I don't have them when I launch phpunit from PHPStorm) Are deprecations cause a Job to fail ? If that's the problem, can I silence them ?


Solution

It's a php unit configuration problem https://phpunit.readthedocs.io/en/9.5/configuration.html

try this create in your project phpunit config file "phpunit.xml" with content like this

<PHP>
  <ini name="error_reporting" value="-1" />
  <env name="KERNEL_CLASS" value="App\Kernel" />
  <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
</php>

or

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


Answered By - MichaƂ G
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing