From 8104a67e3eb0267854e63a6c63685bfdb8524649 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Thu, 1 Aug 2019 19:25:38 +0200 Subject: [PATCH] travis builds with mysql (#924) --- .travis.yml | 75 ++++++++++++++++-------- public/.htaccess | 9 +++ src/Migrations/Version20180715160326.php | 2 +- 3 files changed, 61 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index bed8a004..2a3bacbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,63 @@ +dist: xenial language: php -sudo: false cache: directories: - $HOME/.composer/cache/files -addons: - mariadb: '10.2' - services: - mysql -env: - global: - - CODECOVERAGE=0 - matrix: - fast_finish: true include: - - php: 7.2 - - php: 7.3 - env: CODECOVERAGE=1 + - stage: Code quality + env: CODECOVERAGE=0 DB=sqlite + php: '7.2' + script: + - composer validate --no-check-all --strict + - composer kimai:codestyle + - composer kimai:phpstan + - stage: Test + php: '7.2' + env: CODECOVERAGE=0 DB=mysql + sudo: required + services: + - mysql + - stage: Test + php: '7.3' + env: CODECOVERAGE=0 DB=mysql + sudo: required + services: + - mysql + - stage: Test + php: '7.2' + env: CODECOVERAGE=0 DB=sqlite + - stage: Test + #php: '7.4snapshot' + php: '7.3' + env: CODECOVERAGE=0 DB=sqlite + - stage: Test + php: '7.2' + env: CODECOVERAGE=0 DB=mariadb + addons: + mariadb: '10.2' + before_script: + - mysql -u root -e 'CREATE USER IF NOT EXISTS travis@localhost; GRANT ALL ON *.* TO travis@localhost;' + - stage: Test + php: '7.3' + env: CODECOVERAGE=0 DB=mariadb + addons: + mariadb: '10.2' + before_script: + - mysql -u root -e 'CREATE USER IF NOT EXISTS travis@localhost; GRANT ALL ON *.* TO travis@localhost;' + - stage: Code coverage + php: '7.3' + env: CODECOVERAGE=1 DB=sqlite + after_success: + - if [[ $CODECOVERAGE == 1 ]]; then bash <(curl -s https://codecov.io/bash); fi before_install: -# - phpenv config-rm xdebug.ini + - if [[ $CODECOVERAGE == 0 ]]; then phpenv config-rm xdebug.ini; fi; - composer self-update - php -i - php -m @@ -33,18 +67,11 @@ install: - composer require zendframework/zend-ldap script: - - composer validate --no-check-all --strict - - composer kimai:codestyle - - composer kimai:phpstan - - if [[ $CODECOVERAGE == 1 ]]; then vendor/bin/phpunit tests/ --coverage-clover=coverage.xml; else vendor/bin/phpunit tests/; fi; - - cp tests/.env.dist.sqlite .env - - bin/console doctrine:database:create -n - - bin/console doctrine:migrations:migrate -n - - bin/console doctrine:migrations:migrate first -n - - cp tests/.env.dist.mysql .env + - if [[ $CODECOVERAGE == 1 ]]; then vendor/bin/phpunit tests/ --coverage-clover=coverage.xml; fi; + - if [[ $CODECOVERAGE == 0 ]]; then vendor/bin/phpunit tests/; fi; + - if [[ $DB == 'sqlite' ]]; then cp tests/.env.dist.sqlite .env; fi; + - if [[ $DB == "mysql" || $DB == "mariadb" ]]; then cp tests/.env.dist.mysql .env; fi; - bin/console doctrine:database:create -n - bin/console doctrine:migrations:migrate -n - bin/console doctrine:migrations:migrate first -n -after_success: - - if [[ $CODECOVERAGE == 1 ]]; then bash <(curl -s https://codecov.io/bash); fi diff --git a/public/.htaccess b/public/.htaccess index b9e7f527..416790f4 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -5,6 +5,15 @@ # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl). DirectoryIndex index.php +# Do NOT use Kimai with http, this is a huge security risk! +# Activate these lines if you configured SSL and certificates: + +# +# RewriteEngine On +# RewriteCond %{SERVER_PORT} 80 +# RewriteRule ^(.*)$ https://kimai.example.com/$1 [R,L] +# + RewriteEngine On diff --git a/src/Migrations/Version20180715160326.php b/src/Migrations/Version20180715160326.php index 7e7a4755..a3d29b65 100644 --- a/src/Migrations/Version20180715160326.php +++ b/src/Migrations/Version20180715160326.php @@ -106,7 +106,7 @@ final class Version20180715160326 extends AbstractMigration $this->addSql('INSERT INTO ' . $users . ' (id, name, mail, active, password, roles, alias, registration_date, title, avatar) SELECT id, username, email, enabled, password, roles, alias, registration_date, title, avatar FROM __temp__' . $users); $this->addSql('DROP TABLE __temp__' . $users); } else { - $this->addSql('ALTER TABLE ' . $users . ' CHANGE username name VARCHAR(60) NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE email mail VARCHAR(160) NOT NULL COLLATE utf8mb4_unicode_ci, DROP username_canonical, DROP email_canonical, DROP salt, DROP last_login, DROP confirmation_token, DROP password_requested_at, CHANGE password password VARCHAR(254) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE roles roles JSON NOT NULL COLLATE utf8mb4_bin COMMENT \'(DC2Type:json_array)\', CHANGE alias alias VARCHAR(60) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE registration_date registration_date DATETIME DEFAULT NULL, CHANGE title title VARCHAR(50) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE avatar avatar VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE enabled active TINYINT(1) NOT NULL'); + $this->addSql('ALTER TABLE ' . $users . ' CHANGE username name VARCHAR(60) NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE email mail VARCHAR(160) NOT NULL COLLATE utf8mb4_unicode_ci, DROP username_canonical, DROP email_canonical, DROP salt, DROP last_login, DROP confirmation_token, DROP password_requested_at, CHANGE password password VARCHAR(254) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE roles roles JSON NOT NULL COMMENT \'(DC2Type:json_array)\', CHANGE alias alias VARCHAR(60) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE registration_date registration_date DATETIME DEFAULT NULL, CHANGE title title VARCHAR(50) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE avatar avatar VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, CHANGE enabled active TINYINT(1) NOT NULL'); } $this->addSql('UPDATE ' . $users . ' SET roles = \'["ROLE_SUPER_ADMIN"]\' WHERE roles LIKE "%ROLE_SUPER_ADMIN%"');