Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDO Exception: could not find driver #854

Closed
3 of 5 tasks
f-laino opened this issue Jun 17, 2024 · 1 comment
Closed
3 of 5 tasks

PDO Exception: could not find driver #854

f-laino opened this issue Jun 17, 2024 · 1 comment
Assignees
Labels
workflow-edit Issue can be fixed by editing the GitHub Action workflow

Comments

@f-laino
Copy link

f-laino commented Jun 17, 2024

Describe the bug
Throws PDO Exception when run phpunit tests on Laravel 5.8 (php 7.4) and external database connection.

Version

  • I have checked releases, and the bug exists in the latest patch version of v1 or v2.
  • v2
  • v1

Runners

  • GitHub Hosted
  • Self Hosted

Operating systems
Ubuntu 20.04

PHP versions
7.4

To Reproduce

name: Laravel

on:
  push:
    branches: [ "staging" ]
  pull_request:
    branches: [ "staging" ]

jobs:
  laravel-tests:

    runs-on: ubuntu-20.04

    env:
      DB_HOST: ${{ secrets.DB_HOST }}
      DB_DATABASE: ${{ secrets.DB_DATABASE }}
      DB_USERNAME: ${{ secrets.DB_USERNAME }}
      DB_PASSWORD: ${{ secrets.DB_PASSWORD }}

    steps:
    - name: Clear any existing tool cache
      run: |
        rm -rf "${{ runner.tool_cache }}" || true
    - uses: shivammathur/setup-php@verbose
      with:
        php-version: '7.4'
        extensions: dom, curl, intl, gd, exif, mbstring, xml, libxml, ctype, iconv, mysql, pdo, pdo_mysql, pdo_pgsql, pgsql, phar, fileinfo, sqlite3
    - uses: actions/checkout@v4
    - name: Copy .env
      run: php -r "copy('.env.test', '.env');"
    - name: Install Dependencies
      run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
    - name: Directory Permissions
      run: mkdir -p storage/framework/cache/data storage/framework/cache/laravel-excel storage/framework/session storage/framework/views && chmod -R 777 storage bootstrap/cache
    - uses: php-actions/phpunit@v3
      name: Install PHPUnit and run test
      with:
        version: 9.5.4
        php_version: 7.4
        configuration: phpunit.xml
    - name: Setup PHPStan Action
      uses: NxtLvLSoftware/[email protected]
      env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        install-path: './bin'

Expected behavior
Setup stack don't fail. I tried several configurations.

Screenshots/Logs

Run shivammathur/setup-php@verbose
  with:
    php-version: 7.4
    extensions: dom, curl, intl, gd, exif, mbstring, xml, libxml, ctype, iconv, mysql, pdo, pdo_mysql, pdo_pgsql, pgsql, phar, fileinfo, sqlite[3](https://github.com/DAICAR/iDeal/pull/292/checks#step:3:3)
    ini-file: production
  env:
    DB_HOST: ***
    DB_DATABASE: ***
    DB_USERNAME: ***
    DB_PASSWORD: ***
/usr/bin/bash /home/runner/work/_actions/shivammathur/setup-php/verbose/src/scripts/run.sh

==> Setup PHP
update-alternatives: using /usr/bin/phar7.[4](https://github.com/DAICAR/iDeal/pull/292/checks#step:3:4) to provide /usr/bin/phar (phar) in manual mode
update-alternatives: using /usr/bin/php-config7.4 to provide /usr/bin/php-config (php-config) in manual mode
update-alternatives: using /usr/bin/phpdbg[7](https://github.com/DAICAR/iDeal/pull/292/checks#step:3:7).4 to provide /usr/bin/phpdbg (phpdbg) in manual mode
update-alternatives: using /usr/bin/phpize7.4 to provide /usr/bin/phpize (phpize) in manual mode
update-alternatives: using /usr/bin/php7.4 to provide /usr/bin/php (php) in manual mode
update-alternatives: using /usr/bin/phar.phar7.4 to provide /usr/bin/phar.phar (phar.phar) in manual mode
update-alternatives: using /usr/lib/cgi-bin/php7.4 to provide /usr/lib/cgi-bin/php (php-cgi-bin) in manual mode
update-alternatives: using /usr/bin/php-cgi7.4 to provide /usr/bin/php-cgi (php-cgi) in manual mode
update-alternatives: error: alternative /run/php/php7.4-fpm.sock for php-fpm.sock not registered; not setting
update-alternatives: error: no alternatives for php-fpm
update-alternatives: using /usr/sbin/php-fpm7.4 to provide /usr/sbin/php-fpm (php-fpm) in auto mode
Reading package lists...
Building dependency tree...
Reading state information...

production
date.timezone=UTC
memory_limit=-1
xdebug.mode=coverage
php-version=7.4.33
cp: target '/opt/hostedtoolcache/' is not a directory
✓ PHP Found PHP 7.4.33

==> Setup Extensions
✓ dom Enabled
✓ curl Enabled
✓ intl Enabled
✓ gd Enabled
✓ exif Enabled
✓ mbstring Enabled
✓ xml Enabled
✓ libxml Enabled
✓ ctype Enabled
✓ iconv Enabled
✓ mysql Enabled
✓ pdo Enabled
✓ pdo_mysql Enabled
✓ pdo_pgsql Enabled
✓ pgsql Enabled
✓ phar Enabled
✓ fileinfo Enabled
✓ sqlite3 Enabled
Run php-actions/phpunit@v3
  with:
    version: 9.5.4
    php_version: 7.4
    configuration: phpunit.xml
    test_suffix: Test.php,.phpt
  env:
    DB_HOST: ***
    DB_DATABASE: ***
    DB_USERNAME: ***
    DB_PASSWORD: ***
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    COMPOSER_NO_AUDIT: 1
Run set -e
  set -e
  bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/cee5b9fa9fbc4c888e7a6[2](https://github.com/DAICAR/iDeal/pull/292/checks#step:8:2)bbb7b8eade18e[3](https://github.com/DAICAR/iDeal/pull/292/checks#step:8:3)c56b/php-build.bash) phpunit
  /home/runner/work/_actions/php-actions/phpunit/v3/phpunit-action.bash
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    DB_HOST: ***
    DB_DATABASE: ***
    DB_USERNAME: ***
    DB_PASSWORD: ***
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    COMPOSER_NO_AUDIT: 1
    ACTION_TOKEN: ***
    ACTION_VERSION: 9.5.[4](https://github.com/DAICAR/iDeal/pull/292/checks#step:8:4)
    ACTION_PHP_VERSION: 7.4
    ACTION_PHP_EXTENSIONS: 
    ACTION_PHPUNIT_PATH: 
    ACTION_CONFIGURATION: phpunit.xml
    ACTION_LOG_JUNIT: 
    ACTION_TESTDOX_HTML: 
    ACTION_TESTDOX_TEXT: 
    ACTION_BOOTSTRAP: 
    ACTION_FILTER: 
    ACTION_TESTSUITE: 
    ACTION_GROUP: 
    ACTION_EXCLUDE_GROUP: 
    ACTION_TEST_SUFFIX: Test.php,.phpt
    ACTION_WHITELIST: 
    ACTION_MEMORY_LIMIT: 
    ACTION_COVERAGE_CLOVER: 
    ACTION_COVERAGE_COBERTURA: 
    ACTION_COVERAGE_CRAP4J: 
    ACTION_COVERAGE_HTML: 
    ACTION_COVERAGE_PHP: 
    ACTION_COVERAGE_TEXT: 
    ACTION_COVERAGE_XML: 
    ACTION_ARGS: 
  
PHPUnit 9.5.4 by Sebastian Bergmann and contributors.
........EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE  3 / 113 ( 55%)
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE              113 / 113 (100%)
Time: 00:00.855, Memory: 60.50 MB
There were 105 errors:
1) Tests\Unit\FeeTest::testFlatLeader
Doctrine\DBAL\Driver\PDO\Exception: could not find driver
/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18
/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:42
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:46
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php:24
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
/app/vendor/laravel/framework/src/Illuminate/Database/Connection.php:919
/app/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:109
/app/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:93
/app/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTransactions.php:17
/app/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:122
/app/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:81
/app/tests/Unit/FeeTest.php:40
Caused by
PDOException: could not find driver
@f-laino f-laino added the bug Something isn't working label Jun 17, 2024
@shivammathur
Copy link
Owner

shivammathur commented Jun 17, 2024

Please do not run setup-php with actions that run in their own containers as they use their own php in the container. Please considering running phpunit directly by installing it as a composer dependency or using the tools input in setup-php action.

@shivammathur shivammathur added workflow-edit Issue can be fixed by editing the GitHub Action workflow and removed bug Something isn't working labels Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workflow-edit Issue can be fixed by editing the GitHub Action workflow
Projects
None yet
Development

No branches or pull requests

2 participants