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

fix DB connection issue on composer install #4

Closed

Conversation

nishalgurung4
Copy link

There was an issue with the database connection while installing the package.

Screen Shot 2021-09-16 at 10 32 08 PM

In this workflow configuration, it also throws a DB exception

Screen Shot 2021-09-16 at 9 08 44 PM

I've set up a test repo with the github workflows installed. Please check the outcome of workflows form here.
.

@rahulhaque
Copy link
Owner

@nishalgurung4 Thanks for the pull request. I will have to stale this for now as the code was intentional to check if fileponds table exists for those who are updating from previous versions. For the time being, can you provide the steps to reproduce this problem in the local environment. For example -

  • Your Laravel version?
  • Is this new install? If yes, then did you configure the db connection before installing the package?
  • Anything you may want to add.

@nishalgurung4
Copy link
Author

Hello, and thank you for your response.

Yes, this is the new Laravel 8 installation. Configuring the database connection before installing the package solved the problem in the local setup. Because Schema::hasTable() is used in the ServiceProvider, the package always requires a database connection.

However, the problem for me is with the github workflow. I used the following configuration and attempted to set up the database as follows.

name: Testing Laravel with MySQL
on: [push, pull_request]
jobs:
  laravel:
    name: Laravel (PHP ${{ matrix.php-versions }})
    runs-on: ubuntu-latest
    env:
      DB_DATABASE: actiontest
      DB_USERNAME: root
      DB_HOST: 127.0.0.1
      DB_PASSWORD: 
      BROADCAST_DRIVER: log
      CACHE_DRIVER: redis
      QUEUE_CONNECTION: redis
      SESSION_DRIVER: redis    
    services:
      mysql:
        image: mysql:5.7
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: false
          MYSQL_ROOT_PASSWORD: 
          MYSQL_DATABASE: actiontest
        ports:
          - 3306/tcp
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      redis:
        image: redis
        ports:
          - 6379/tcp
        options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
    strategy:
      fail-fast: false
      matrix:
        php-versions: ['8.0']
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup PHP, with composer and extensions
        uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
        with:
          php-version: ${{ matrix.php-versions }}
          extensions: mbstring, dom, fileinfo, mysql
          coverage: xdebug #optional
      - name: Start mysql service
        run: sudo /etc/init.d/mysql start
      - name: Get composer cache directory
        id: composer-cache
        run: echo "::set-output name=dir::$(composer config cache-files-dir)"
      - name: Cache composer dependencies
        uses: actions/cache@v2
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          # Use composer.json for key, if composer.lock is not committed.
          # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: ${{ runner.os }}-composer-
      - name: Install Composer dependencies
        run: composer install --no-progress --prefer-dist --optimize-autoloader
      - name: Prepare the application
        run: |
          php -r "file_exists('.env') || copy('.env.example', '.env');"
          php artisan key:generate
      - name: Clear Config
        run: php artisan config:clear
      - name: Run Migration
        run: php artisan migrate -v
        env:
          DB_PORT: ${{ job.services.mysql.ports['3306'] }}
          REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
      - name: Test with phpunit
        run: vendor/bin/phpunit --coverage-text
        env:
          DB_PORT: ${{ job.services.mysql.ports['3306'] }}
          REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

Unfortunately, this isn't working. You can look into the error trace here.

@rahulhaque
Copy link
Owner

@nishalgurung4 thanks for testing it out. I have just pushed a fix in the dev branch. Can you please uninstall the current version of the package and install the dev one with composer require rahulhaque/laravel-filepond:dev-dev and run the tests. I can then go forward with the release.

@nishalgurung4
Copy link
Author

@rahulhaque Thank you, it's working now. The log can be found here

@rahulhaque
Copy link
Owner

@nishalgurung4 thanks a lot for the heads up. I will release new version with the fix. Update as soon as I release. And also thanks for the pull request. I would merge it if not for the changes in my action workflow. So cheers. Be sure to close the issue after updating to the latest version. Happy coding.

@rahulhaque rahulhaque closed this Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants