审查员ci:MySQL是否可以更改/设置用户?

时间:2019-02-08 08:20:08

标签: scrutinizer

在Laravel中,我使用Travis和Scrutinizer CI。

对于travis,使用.yml,我可以强制它使用与测试相同的MySQL用户(在我的情况下,用户为“ forge”,密码为“ forge”,而db为“ test”)。 / p>

使用Scrutinizer,我无法获得相同的行为:它抱怨

[Illuminate\Database\QueryException (1045)]                                  
  SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using pa  
  ssword: NO) (SQL: select * from information_schema.tables where table_schem  
  a = forge and table_name = migrations)    

这是我的.scrutinizer.yml文件

build:
    environment:
        php: '7.2'
        mysql: '5.7'
        node: '8.1'
        hosts:
            laravel.dev: '127.0.0.1'
        variables:
            APP_KEY: 'base64:OYl4Bk9ekouOUIRXyeTD0FVi+cJ9D+HMyDJBgSBSUuI='
            APP_ENV: 'testing'
            APP_URL: 'http://laravel.dev'
            API_HOST: 'laravel.dev'
            #DB_HOST: '127.0.0.1'
            #DB_TEST_DATABASE: 'test'
            #DB_TEST_USERNAME: 'root'
            #DB_TEST_PASSWORD: ''
            MAIL_DRIVER: 'log'
    cache:
        directories:
            #- node_modules
            - vendor/
            - ~/.composer/cache/
    dependencies:
        before:
            - mysql -uroot -e "CREATE DATABASE IF NOT EXISTS test"
            - mysql -uroot -e "GRANT ALL ON test.* TO 'forge'@'localhost' IDENTIFIED BY 'forge'";
    tests:
        before:
            - chmod -R 777 storage
            - chmod -R 777 bootstrap/cache
            - composer dump-autoload
            #- php artisan migrate --no-interaction -vvv
            #- php artisan db:seed --no-interaction -vvv
            - php artisan migrate:refresh --seed --no-interaction -vvv #This will clean, migrate, then seed the db
            - rm -rf node_modules
            - npm install
            #- npm run
            - npm run production
        override:
            -
                command: vendor/bin/phpunit --coverage-clover=clover-coverage
                coverage:
                    file: clover-coverage
                    format: clover

(请注意,我确实评论了DB_xx部分,“由于未在Scrutinizer中使用,因此我添加了mysql指令)。

这是config/database.php中的“配置测试数据库”部分:

'testing' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_TEST_DATABASE', 'test'),
            'username' => env('DB_TEST_USERNAME', 'forge'),
            'password' => env('DB_TEST_PASSWORD', 'forge'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null
        ],

检查器仅创建“测试”数据库,似乎已执行“ GRANT”,但最终退出并出现错误。

这是日志:https://scrutinizer-ci.com/g/sineverba/domotic-panel/inspections/a459bd50-4785-4a79-8184-074362631df4/log

所以,我的问题是:如何强制审查程序为mysql使用另一个用户,而不是没有密码的root用户?

0 个答案:

没有答案