diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 439e9ab..bb8c0c1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,21 +1,91 @@ -image: framasoft/framadate-ci +variables: + TESTING_IMAGE: framasoft/framadate-ci:php-7.2 + +image: ${TESTING_IMAGE} + +cache: + key: "${TESTING_IMAGE}:${CI_PROJECT_ID}" + paths: + - vendor/ + +before_script: + - composer install -o --no-interaction --no-progress --prefer-dist + stages: - test - deploy - beta - funky -# Run php-cs-fixer and phpunit on all branches +# Run phpunit on all branches test: stage: test script: - - composer install -o --no-interaction --no-progress --prefer-dist - - php vendor/bin/php-cs-fixer fix --verbose --dry-run - - APP_ENV=test bin/doctrine migrations:migrate --no-interaction -vvv - vendor/bin/phpunit --bootstrap app/tests/bootstrap.php --debug app/tests - cache: - paths: - - vendor/ + +# Run php-cs-fixer on all branches +lint: + stage: test + script: + - php vendor/bin/php-cs-fixer fix --verbose --dry-run + +# Run doctrine migrations with MySQL +.db:migration:mysql: + stage: test + variables: + APP_ENV: "test" + MYSQL_DATABASE: "fd_test" + MYSQL_ROOT_PASSWORD: "coucou" + FRAMADATE_DB_DRIVER: 'pdo_mysql' + FRAMADATE_DB_HOST: "mysql" + FRAMADATE_DB_NAME: "${MYSQL_DATABASE}" + FRAMADATE_DB_USER: "root" + FRAMADATE_DB_PASSWORD: "${MYSQL_ROOT_PASSWORD}" + script: + - docker-php-ext-install "${FRAMADATE_DB_DRIVER}" + - bin/doctrine migrations:status -vvv + - bin/doctrine migrations:migrate --no-interaction -vvv + - bin/doctrine migrations:status -vvv + +db:migration:mysql:5.6: + extends: .db:migration:mysql + services: + - 'mysql:5.6' + +db:migration:mysql:5.7: + extends: .db:migration:mysql + services: + - 'mysql:5.7' + +db:migration:mysql:8: + extends: .db:migration:mysql + services: + - name: 'mysql:8' + command: ['--default-authentication-plugin=mysql_native_password'] + +# Run doctrine migrations with PostgreSQL +.db:migration:postgresql: + stage: test + variables: + APP_ENV: "test" + POSTGRES_DB: "fd_test" + POSTGRES_USER: "marmotte" + POSTGRES_PASSWORD: "sleeping" + FRAMADATE_DB_DRIVER: 'pdo_pgsql' + FRAMADATE_DB_HOST: "postgres" + FRAMADATE_DB_NAME: "${POSTGRES_DB}" + FRAMADATE_DB_USER: "${POSTGRES_USER}" + FRAMADATE_DB_PASSWORD: "${POSTGRES_PASSWORD}" + script: + - docker-php-ext-install "${FRAMADATE_DB_DRIVER}" + - bin/doctrine migrations:status -vvv + - bin/doctrine migrations:migrate --no-interaction -vvv + - bin/doctrine migrations:status -vvv + +db:migration:postgresql:9.6: + extends: .db:migration:postgresql + services: + - 'postgres:9.6' check:missing:trads: stage: test @@ -65,7 +135,6 @@ pages: beta: stage: beta script: - - git checkout develop - composer install -o --no-interaction --no-progress --prefer-dist --no-dev - composer dump-autoload --optimize --no-dev --classmap-authoritative # - if [ ! -z ${ZANATA_CONFIG_FRAMABOT+x} ]; then mkdir -p ${HOME}/.config; echo -e "${ZANATA_CONFIG_FRAMABOT}" > ${HOME}/.config/zanata.ini; fi @@ -87,7 +156,6 @@ beta: funky: stage: funky script: - - git checkout funky - composer install - mkdir tpl_c - mkdir .public diff --git a/README.md b/README.md index 8c8b245..de315d6 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Follow the instructions on skipIf($commentTable->hasColumn('date'), 'Column date in comment table already exists'); + // The default for datetime types is only available for MySQL 5.6 + // See the "Functionality Added or Changed" section, + // "Important Change: In MySQL, the TIMESTAMP data type" element, on + // https://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-6.html $commentTable->addColumn('date', 'datetime', ['default' => 0]); } diff --git a/app/inc/config.test.php b/app/inc/config.test.php index c642b2d..5a1efff 100644 --- a/app/inc/config.test.php +++ b/app/inc/config.test.php @@ -32,22 +32,22 @@ const ADRESSEMAILADMIN = 'admin@app.tld'; const ADRESSEMAILREPONSEAUTO = 'no@reply'; // Database driver -const DB_DRIVER = 'pdo_sqlite'; +const DB_DRIVER = FRAMADATE_DB_DRIVER; // Database name -const DB_NAME = 'framadate'; +const DB_NAME = FRAMADATE_DB_NAME; // Database host -const DB_HOST = ''; +const DB_HOST = FRAMADATE_DB_HOST; // Database port -const DB_PORT = ''; +const DB_PORT = FRAMADATE_DB_PORT; // Database user -const DB_USER = ''; +const DB_USER = FRAMADATE_DB_USER; // Database password -const DB_PASSWORD = ''; +const DB_PASSWORD = FRAMADATE_DB_PASSWORD; // Table name prefix const TABLENAME_PREFIX = 'fd_'; diff --git a/app/inc/init.php b/app/inc/init.php index ed973be..47a7bd7 100644 --- a/app/inc/init.php +++ b/app/inc/init.php @@ -40,6 +40,13 @@ define('ROOT_DIR', __DIR__ . '/../../'); $path = '/app/inc/config.php'; if (getenv('APP_ENV') === 'test') { $path = '/app/inc/config.test.php'; + // Read DB connection params from Environment Variables if possible + define('FRAMADATE_DB_DRIVER', getenv('FRAMADATE_DB_DRIVER') ? getenv('FRAMADATE_DB_DRIVER') : 'pdo_sqlite'); + define('FRAMADATE_DB_NAME', getenv('FRAMADATE_DB_NAME') ? getenv('FRAMADATE_DB_NAME') : 'framadate'); + define('FRAMADATE_DB_HOST', getenv('FRAMADATE_DB_HOST') ? getenv('FRAMADATE_DB_HOST') : ''); + define('FRAMADATE_DB_PORT', getenv('FRAMADATE_DB_PORT') ? getenv('FRAMADATE_DB_PORT') : ''); + define('FRAMADATE_DB_USER', getenv('FRAMADATE_DB_USER') ? getenv('FRAMADATE_DB_USER') : ''); + define('FRAMADATE_DB_PASSWORD', getenv('FRAMADATE_DB_PASSWORD') ? getenv('FRAMADATE_DB_PASSWORD') : ''); } define('CONF_FILENAME', ROOT_DIR . $path); diff --git a/bin/doctrine b/bin/doctrine index 5bcd655..68e23ad 100755 --- a/bin/doctrine +++ b/bin/doctrine @@ -55,4 +55,5 @@ try { $cli->run($input, $output); } catch (\Exception $e) { $style->error($e->getMessage()); + exit(1); }