laravel-url-shortener icon indicating copy to clipboard operation
laravel-url-shortener copied to clipboard

Bitbucket Pipeline error

Open HappySoft opened this issue 3 years ago • 6 comments

Unfortunately after adding the package "magarrent/laravel-url-shortener" I've encountered the following problem with Bitbucket Pipeline build:

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php https://bitbucket.org/censored/src/6d017547e680cb4ff20585b5647ceda95eb7dc16/artisan package:discover --ansi

   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [1045] Access denied for user 'forge'@'127.0.0.1' (using password: NO) (SQL: select * from information_schema.tables where table_schema = forge and table_name = url_shorteners and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

  1   [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Magarrent\LaravelUrlShortener\LaravelUrlShortenerServiceProvider))

      [2m+23 vendor frames [22m
  25  [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Magarrent\LaravelUrlShortener\LaravelUrlShortenerServiceProvider))
Script @php https://bitbucket.org/censored/src/6d017547e680cb4ff20585b5647ceda95eb7dc16/artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Any suggestions how to stop it hitting database during artisan package:discover call?

HappySoft avatar Aug 05 '22 00:08 HappySoft

Hey @HappySoft , the package needs to store data to the BD, so you need a connection

magarrent avatar Aug 05 '22 08:08 magarrent

@magarrent , The package hits DB before I have chance to run php artisan test. At this moment DB is blank and schema is created before tests run. Looking into the package source code, I am afraid unit testing was not considered at all :(

HappySoft avatar Aug 05 '22 08:08 HappySoft

@magarrent , The package hits DB before I have chance to run php artisan test. At this moment DB is blank and schema is created before tests run. Looking into the package source code, I am afraid unit testing was not considered at all :(

Did you run the migrations in your tests?

magarrent avatar Aug 05 '22 08:08 magarrent

@magarrent , php artisan test loads DB schema for testing database, no need to run any migrations manually.

HappySoft avatar Aug 05 '22 08:08 HappySoft

@HappySoft yes, but you attached a DB connection error:

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'127.0.0.1'

Did you configure the Mysql Connection in the Test environment?

magarrent avatar Aug 05 '22 09:08 magarrent

@magarrent , basically what pipeline build does is:

composer install # the error happens here
cp .env.example .env
php artisan test --without-tty

I tried to set up .env file before running composer install - no luck too, because DB is empty yet.

HappySoft avatar Aug 05 '22 09:08 HappySoft