Merge branch 'ci-migration-testing' into 'develop'

ci: some cleanup of the gitlab-ci file and testing migrations on MySQL

See merge request framasoft/framadate/framadate!388
This commit is contained in:
Thomas Citharel 2019-04-19 14:32:56 +02:00
commit 705abe6cd6
6 changed files with 97 additions and 17 deletions

View File

@ -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

View File

@ -23,7 +23,7 @@ Follow the instructions on <https://framagit.org/framasoft/framadate/framadate/w
* PHP [PHP 5.6](http://php.net)
* Templating [Smarty](http://www.smarty.net/),
* I18N [o80-i18n](https://github.com/olivierperez/o80-i18n)
* Database: PostgreSQL ou [MySQL 5.5](https://dev.mysql.com/downloads/mysql/5.5.html)
* Database: PostgreSQL 9.6 or [MySQL 5.6+](https://dev.mysql.com/downloads/mysql/5.6.html)/[MariaDB 10.1+](https://www.debian.org/releases/stable/mips/release-notes/ch-whats-new.en.html#mariadb-replaces-mysql)
---

View File

@ -53,6 +53,10 @@ class Version20151012082600 extends AbstractMigration
$this->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]);
}

View File

@ -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_';

View File

@ -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);

View File

@ -55,4 +55,5 @@ try {
$cli->run($input, $output);
} catch (\Exception $e) {
$style->error($e->getMessage());
exit(1);
}