-
-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e7cbf1
commit 2e1c37b
Showing
17 changed files
with
180 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ | |
/.php_cs.cache | ||
/.travis.yml | ||
/composer.lock | ||
/tests/app/runtime | ||
/tests/runtime/* | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ max_line_length = 80 | |
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[Makefile] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
init: clean build | ||
docker-compose run php72 true | ||
docker-compose down | ||
|
||
test: test-php72 test-php71 test-php70 test-php56 | ||
test-php72: | ||
docker-compose run php72 vendor/bin/phpunit --verbose | ||
docker-compose down | ||
test-php71: | ||
docker-compose run php71 vendor/bin/phpunit --verbose | ||
docker-compose down | ||
test-php70: | ||
docker-compose run php70 vendor/bin/phpunit --verbose | ||
docker-compose down | ||
test-php56: | ||
docker-compose run php56 vendor/bin/phpunit --verbose | ||
docker-compose down | ||
|
||
benchmark: benchmark-php72 benchmark-php71 benchmark-php70 benchmark-php56 | ||
benchmark-php72: | ||
docker-compose run php72 tests/yii benchmark/waiting | ||
docker-compose down | ||
benchmark-php71: | ||
docker-compose run php71 tests/yii benchmark/waiting | ||
docker-compose down | ||
benchmark-php70: | ||
docker-compose run php70 tests/yii benchmark/waiting | ||
docker-compose down | ||
benchmark-php56: | ||
docker-compose run php56 tests/yii benchmark/waiting | ||
docker-compose down | ||
|
||
check-cs: | ||
docker-compose run php72 php-cs-fixer fix --diff --dry-run | ||
docker-compose down | ||
|
||
build: | ||
docker-compose pull | ||
docker-compose build | ||
|
||
clean: | ||
docker-compose down | ||
sudo rm -rf runtime/* | ||
sudo rm -f ../.php_cs.cache | ||
sudo rm -f ../composer.lock | ||
sudo rm -rf ../vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
flock tests/runtime/composer-install.lock composer install --prefer-dist --no-interaction \ | ||
&& tests/yii sqlite-migrate/up --interactive=0 \ | ||
&& tests/docker/wait-for-it.sh $MYSQL_HOST:$MYSQL_PORT -t 180 \ | ||
&& tests/docker/php/mysql-lock.php tests/yii mysql-migrate/up --interactive=0 \ | ||
&& tests/docker/wait-for-it.sh $POSTGRES_HOST:$POSTGRES_PORT -t 180 \ | ||
&& tests/docker/php/mysql-lock.php tests/yii pgsql-migrate/up --interactive=0 \ | ||
&& tests/docker/wait-for-it.sh $REDIS_HOST:$REDIS_PORT -t 180 \ | ||
&& tests/docker/wait-for-it.sh $RABBITMQ_HOST:$RABBITMQ_PORT -t 180 \ | ||
&& tests/docker/wait-for-it.sh $BEANSTALK_HOST:$BEANSTALK_PORT -t 180 \ | ||
&& tests/docker/wait-for-it.sh $GEARMAN_HOST:$GEARMAN_PORT -t 180 \ | ||
&& exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* Запуск команды с сетевой синхронизацией через MySQL. | ||
* | ||
* Когда запускается сеть из docker-контейнеров каждый php-контейнер в числе | ||
* прочих запускает команду миграции БД. И, чтобы исключить высокую вероятность, | ||
* запуска нескольких таких процессов одновременно, используется синхронизация | ||
* на уровне блокировок MySQL. Это гарантирует, что одновременно будет работать | ||
* только одна из запущенных команд, а остальные будут ждать завершения. | ||
* | ||
* @author Roman Zhuravlev <[email protected]> | ||
*/ | ||
|
||
$params = $_SERVER['argv']; | ||
array_shift($params); | ||
$command = implode(' ', $params); | ||
|
||
$mysql = new PDO( | ||
sprintf( | ||
'mysql:host=%s;port=%s;dbname=%s', | ||
getenv('MYSQL_HOST'), | ||
getenv('MYSQL_PORT'), | ||
getenv('MYSQL_DATABASE') | ||
), | ||
getenv('MYSQL_USER'), | ||
getenv('MYSQL_PASSWORD') | ||
); | ||
|
||
// Waiting a lock for the command | ||
$query = $mysql->prepare('SELECT GET_LOCK(?, -1)'); | ||
$query->execute([md5($command)]); | ||
if (!$query->fetch(PDO::FETCH_NUM)[0]) { | ||
throw new Exception('Cannot get the lock.'); | ||
} | ||
|
||
// Executes the command | ||
passthru($command, $exitCode); | ||
|
||
// Releases the lock | ||
$query = $mysql->prepare('SELECT RELEASE_LOCK(?)'); | ||
$query->execute([md5($command)]); | ||
if (!$query->fetch(PDO::FETCH_NUM)[0]) { | ||
throw new Exception('Cannot release the lock.'); | ||
} | ||
|
||
exit($exitCode); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.