Hi all!
I’m currently trying to setup a great continuous integration, but it’s my first time doing it.
I’m not really sure how to do it, so I’ll try to explain how I did it.
I have a file “.env.test” with this :
APP_ENV=test APP_SECRET=asecretkey MAILER_URL=null://localhost DATABASE_URL=mysql://runner:password@127.0.0.1:3306/database
And a “.gitlab-ci.yml” file with this content :
image: php:7.2-cli services: - mysql:latest cache: paths: - vendor/ stages: - connect - test - deploy variables: # Configure mysql service (https://hub.docker.com/_/mysql/) MYSQL_DATABASE: database MYSQL_USER: runner MYSQL_ROOT_PASSWORD: password MYSQL_PASSWORD: password before_script: - apt-get update -yqq - apt-get install git -yqq zlib1g-dev # Install mysql driver - docker-php-ext-install pdo_mysql zip # Install composer - curl -sS https://getcomposer.org/installer | php # Install all project dependencies - php composer.phar install test: stage: test script: - cp .env.test .env - php bin/console doctrine:database:create -e test - php bin/console make:migration -e test - php bin/console doctrine:fixture:load -no-interaction -e test - php composer.phar test deploy: stage: deploy script: - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - eval $(ssh-agent -s) - ssh-add <(echo "$SSH_PRIVATE_KEY") - mkdir -p ~/.ssh - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
At the moment, in the “test” job, I have this error :
Error thrown while running command "doctrine:database:create -e test". Message: "An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused" In AbstractMySQLDriver.php line 113: An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused In PDOConnection.php line 50: SQLSTATE[HY000] [2002] Connection refused In PDOConnection.php line 46: SQLSTATE[HY000] [2002] Connection refused
I’m forced to create my database because I have functionnal test (that check if I have 200 HTTP answer). If there’s no database, it won’t be possible to have 200 answers, or maybe I’m wrong?
I’m kind of lost about this, is this possible for you to help me?
Have a good day!