Successfull PHPUnit test exit with exit code 1

I have a workflow which runs tests with PHPUnit. The last runs of the workflow was successfull, the latest run as exited with exit code 1, but the PHPUnit tests was successfull.

Any idea whats happened wrong?

Run php bin/phpunit -c phpunit.xml
PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

.....                                                               5 / 5 (100%)

Time: 00:03.946, Memory: 54.50 MB

OK (5 tests, 27 assertions)

Remaining indirect deprecation notices (16)

  5x: Since symfony/doctrine-bridge 5.3: Method "Symfony\Bridge\Doctrine\Security\User\EntityUserProvider::loadUserByUsername()" is deprecated, use loadUserByIdentifier() instead.
    1x in CountryTest::testGetCollection from App\Tests\Api
    1x in CountryTest::testCreateCountry from App\Tests\Api
    1x in CountryTest::testCreateInvalidCountry from App\Tests\Api
    1x in CountryTest::testUpdateCountry from App\Tests\Api
    1x in CountryTest::testDeleteCountry from App\Tests\Api

  2x: Since doctrine/doctrine-bundle 2.4: Setting the "doctrine.dbal.dbname" option while the "url" one is defined is deprecated
    2x in CountryTest::testGetCollection from App\Tests\Api

  2x: Since symfony/security-bundle 5.3: The child node "encoders" at path "security" is deprecated, use "password_hashers" instead.
    2x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-bundle 5.3: Not setting the "security.enable_authenticator_manager" config option to true is deprecated.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-http 5.3: The "Symfony\Component\Security\Http\Firewall\AnonymousAuthenticationListener" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-guard 5.3: The "Symfony\Component\Security\Guard\Firewall\GuardAuthenticationListener" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-http 5.3: The "Symfony\Component\Security\Http\Firewall\UsernamePasswordJsonAuthenticationListener" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface" interface is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-guard 5.3: The "Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

    1x in CountryTest::testCreateInvalidCountry from App\Tests\Api
    1x in CountryTest::testUpdateCountry from App\Tests\Api
    1x in CountryTest::testDeleteCountry from App\Tests\Api

  5x: Since symfony/security-bundle 5.3: The "security.authentication.listener.anonymous.api" service is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api
    1x in CountryTest::testCreateCountry from App\Tests\Api
    1x in CountryTest::testCreateInvalidCountry from App\Tests\Api
    1x in CountryTest::testUpdateCountry from App\Tests\Api
    1x in CountryTest::testDeleteCountry from App\Tests\Api

  1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Event\AuthenticationFailureEvent" class is deprecated, use "Symfony\Component\Security\Http\Event\LoginFailureEvent" with the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-guard 5.3: The "Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

  1x: Since symfony/security-guard 5.3: The "Symfony\Component\Security\Guard\GuardAuthenticatorHandler" class is deprecated, use the new authenticator system instead.
    1x in CountryTest::testGetCollection from App\Tests\Api

Error: Process completed with exit code 1.

My workflow file:

name: unit-tests

on:
  push:

env:
  fail-fast: true
  PHPUNIT_FLAGS: "-v"
  SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit"
  SYMFONY_REQUIRE: ">=5.3"
  # 40x: Since symfony/monolog-bridge 5.2:
  # Passing an actionLevel (int|string) as constructor's 3rd argument of
  # "Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy"
  # is deprecated, "Monolog\Handler\FingersCrossed\ActivationStrategyInterface" expected.
  SYMFONY_DEPRECATIONS_HELPER: 40

jobs:
  test:
    name: "${{ matrix.operating-system }} / PHP ${{ matrix.php-version }}"
    runs-on: ${{ matrix.operating-system }}
    continue-on-error: false

    strategy:
      matrix:
        operating-system: ['ubuntu-latest']
        php-version: ['8.0']

    steps:
      - name: "Checkout code"
        uses: actions/checkout@v2.3.3

      - uses: mirromutth/mysql-action@v1.1
        with:
          character set server: 'utf8' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
          collation server: 'utf8_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld
          mysql version: '8.0' # Optional, default value is "latest". The version of the MySQL
          mysql database: 'symfony' # Optional, default value is "test". The specified database which will be create
          mysql root password: ${{ secrets.RootPassword }} # Required if "mysql user" is empty, default is empty. The root superuser password
          mysql user: 'symfony' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too
          mysql password: 'symfony' # Required if "mysql user" exists. The password for the "mysql user"

      - name: "Install PHP with extensions"
        uses: shivammathur/setup-php@2.7.0
        with:
          coverage: "none"
          extensions: "intl, mbstring, pdo_sqlite"
          php-version: ${{ matrix.php-version }}
          tools: composer:v2

      - name: "Add PHPUnit matcher"
        run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

      - name: "Set composer cache directory"
        id: composer-cache
        run: echo "::set-output name=dir::$(composer config cache-files-dir)"

      - name: "Cache composer"
        uses: actions/cache@v2.1.2
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}
          restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-

      - name: "Require symfony/flex"
        run: composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-main

      - run: composer update

      - name: "Install PHPUnit"
        run: vendor/bin/simple-phpunit install

      - name: "PHPUnit version"
        run: vendor/bin/simple-phpunit --version

      - name: "ls -la"
        run: ls -la

      - name: "pwd"
        run: pwd

      - name: "Generate JWT SSL keys"
        run: php bin/console lexik:jwt:generate-keypair

      - name: "DB config"
        run: echo 'DATABASE_URL="mysql://symfony:symfony@127.0.0.1:3306/symfony?serverVersion=8"' > env.test

      - name: "create database"
        run: php bin/console doctrine:migrations:migrate -n

      - name: "load fixtures"
        run: php bin/console doctrine:fixtures:load -n

      - name: "Run tests"
        run: php bin/phpunit -c phpunit.xml

      - name: dev-log
        run: cat var/log/dev.log
1 Like

Are the deprecation warnings new?

No, there was also deprecation warnings in previous runs.

After disabling the deprecations warning output, the workflow works without an error.

Not sure, but something might have changed, and now sets a non-zero exit code if there are warnings.
Maybe check if there is an option to control this behavior. Or try to ignore/override the exit code (see Actions Workflow - Complete Job part terminating my process - #2 by Simran-B)